Skip to content

Commit

Permalink
fix: embed content ordering
Browse files Browse the repository at this point in the history
  • Loading branch information
ImLunaHey committed Jan 6, 2025
1 parent c8e078e commit 218a72c
Showing 1 changed file with 33 additions and 38 deletions.
71 changes: 33 additions & 38 deletions src/components/PostEmbed/app-bsky-embed-record-view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,38 +26,44 @@ export const AppBskyEmbedRecordView = ({ embed }: { embed: BSkyPostEmbed }) => {
);
}

if (embed.record.$type === 'app.bsky.embed.record#viewRecord' && embed.record.embeds && embed.record.embeds.length >= 1) {
return <PostEmbed embed={embed.record.embeds?.[0]} />;
}

return (
<div className="p-4 rounded-lg shadow border border-neutral-200 dark:border-neutral-800">
{embed.record.$type === 'app.bsky.embed.record#viewRecord' && (
<div className="flex items-center space-x-3 mb-2">
<Avatar handle={author.handle} avatar={author.avatar} />
<div>
<div className="font-medium text-gray-900 dark:text-gray-100">
<Link to="/profile/$handle" params={{ handle: author.handle }}>
{author.displayName || author.handle}
</Link>
</div>
<div className="text-gray-500 dark:text-gray-400 text-sm">
<Link to="/profile/$handle" params={{ handle: author.handle }}>
<Handle handle={author.handle} />
</Link>
{' · '}
<Link
to="/profile/$handle/post/$postId"
params={{
handle: author.handle,
postId: embed.record.uri.split('/').pop()!,
}}
>
<TimeAgo date={embed.record.indexedAt} />
</Link>
<>
<div className="flex items-center space-x-3 mb-2">
<Avatar handle={author.handle} avatar={author.avatar} />
<div>
<div className="font-medium text-gray-900 dark:text-gray-100">
<Link to="/profile/$handle" params={{ handle: author.handle }}>
{author.displayName || author.handle}
</Link>
</div>
<div className="text-gray-500 dark:text-gray-400 text-sm">
<Link to="/profile/$handle" params={{ handle: author.handle }}>
<Handle handle={author.handle} />
</Link>
{' · '}
<Link
to="/profile/$handle/post/$postId"
params={{
handle: author.handle,
postId: embed.record.uri.split('/').pop()!,
}}
>
<TimeAgo date={embed.record.indexedAt} />
</Link>
</div>
</div>
</div>
</div>
<p className="text-gray-800 dark:text-gray-200">
{embed.record.facets ? (
<FacetedText text={embed.record.value.text} facets={embed.record.facets} key={embed.record.uri} />
) : (
<FormattedText text={embed.record.value.text} key={embed.record.uri} />
)}
</p>
<PostEmbed embed={embed.record.embeds?.[0]} />
</>
)}
{embed.record.$type === 'app.bsky.graph.defs#starterPackViewBasic' && (
<div className="text-gray-800 dark:text-gray-200">
Expand Down Expand Up @@ -106,17 +112,6 @@ export const AppBskyEmbedRecordView = ({ embed }: { embed: BSkyPostEmbed }) => {
</div>
</div>
)}
{embed.record.$type !== 'app.bsky.graph.defs#starterPackViewBasic' &&
embed.record.$type !== 'app.bsky.feed.defs#generatorView' &&
embed.record.$type !== 'app.bsky.graph.defs#listView' && (
<p className="text-gray-800 dark:text-gray-200">
{embed.record.facets ? (
<FacetedText text={embed.record.value.text} facets={embed.record.facets} key={embed.record.uri} />
) : (
<FormattedText text={embed.record.value.text} key={embed.record.uri} />
)}
</p>
)}
</div>
);
};

0 comments on commit 218a72c

Please sign in to comment.