Skip to content

Commit

Permalink
fix rendering of external in quote embeds (#2464)
Browse files Browse the repository at this point in the history
  • Loading branch information
haileyok authored Jan 11, 2024
1 parent 7ab4be6 commit 6ec6d52
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions src/view/com/util/post-embeds/QuoteEmbed.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
AppBskyEmbedImages,
AppBskyEmbedRecordWithMedia,
ModerationUI,
AppBskyEmbedExternal,
} from '@atproto/api'
import {AtUri} from '@atproto/api'
import {PostMeta} from '../PostMeta'
Expand Down Expand Up @@ -87,15 +88,19 @@ export function QuoteEmbed({
() => quote.text.trim().length === 0,
[quote.text],
)
const imagesEmbed = React.useMemo(
() =>
quote.embeds?.find(
embed =>
AppBskyEmbedImages.isView(embed) ||
AppBskyEmbedRecordWithMedia.isView(embed),
),
[quote.embeds],
)
const embed = React.useMemo(() => {
const e = quote.embeds?.[0]

if (AppBskyEmbedImages.isView(e) || AppBskyEmbedExternal.isView(e)) {
return e
} else if (
AppBskyEmbedRecordWithMedia.isView(e) &&
(AppBskyEmbedImages.isView(e.media) ||
AppBskyEmbedExternal.isView(e.media))
) {
return e.media
}
}, [quote.embeds])
return (
<Link
style={[styles.container, pal.borderDark, style]}
Expand All @@ -117,12 +122,7 @@ export function QuoteEmbed({
{quote.text}
</Text>
) : null}
{AppBskyEmbedImages.isView(imagesEmbed) && (
<PostEmbeds embed={imagesEmbed} moderation={{}} />
)}
{AppBskyEmbedRecordWithMedia.isView(imagesEmbed) && (
<PostEmbeds embed={imagesEmbed.media} moderation={{}} />
)}
{embed && <PostEmbeds embed={embed} moderation={{}} />}
</Link>
)
}
Expand Down

0 comments on commit 6ec6d52

Please sign in to comment.