fix rendering of external in quote embeds (#2464)
parent
7ab4be6f7d
commit
6ec6d522e8
|
@ -6,6 +6,7 @@ import {
|
||||||
AppBskyEmbedImages,
|
AppBskyEmbedImages,
|
||||||
AppBskyEmbedRecordWithMedia,
|
AppBskyEmbedRecordWithMedia,
|
||||||
ModerationUI,
|
ModerationUI,
|
||||||
|
AppBskyEmbedExternal,
|
||||||
} from '@atproto/api'
|
} from '@atproto/api'
|
||||||
import {AtUri} from '@atproto/api'
|
import {AtUri} from '@atproto/api'
|
||||||
import {PostMeta} from '../PostMeta'
|
import {PostMeta} from '../PostMeta'
|
||||||
|
@ -87,15 +88,19 @@ export function QuoteEmbed({
|
||||||
() => quote.text.trim().length === 0,
|
() => quote.text.trim().length === 0,
|
||||||
[quote.text],
|
[quote.text],
|
||||||
)
|
)
|
||||||
const imagesEmbed = React.useMemo(
|
const embed = React.useMemo(() => {
|
||||||
() =>
|
const e = quote.embeds?.[0]
|
||||||
quote.embeds?.find(
|
|
||||||
embed =>
|
if (AppBskyEmbedImages.isView(e) || AppBskyEmbedExternal.isView(e)) {
|
||||||
AppBskyEmbedImages.isView(embed) ||
|
return e
|
||||||
AppBskyEmbedRecordWithMedia.isView(embed),
|
} else if (
|
||||||
),
|
AppBskyEmbedRecordWithMedia.isView(e) &&
|
||||||
[quote.embeds],
|
(AppBskyEmbedImages.isView(e.media) ||
|
||||||
)
|
AppBskyEmbedExternal.isView(e.media))
|
||||||
|
) {
|
||||||
|
return e.media
|
||||||
|
}
|
||||||
|
}, [quote.embeds])
|
||||||
return (
|
return (
|
||||||
<Link
|
<Link
|
||||||
style={[styles.container, pal.borderDark, style]}
|
style={[styles.container, pal.borderDark, style]}
|
||||||
|
@ -117,12 +122,7 @@ export function QuoteEmbed({
|
||||||
{quote.text}
|
{quote.text}
|
||||||
</Text>
|
</Text>
|
||||||
) : null}
|
) : null}
|
||||||
{AppBskyEmbedImages.isView(imagesEmbed) && (
|
{embed && <PostEmbeds embed={embed} moderation={{}} />}
|
||||||
<PostEmbeds embed={imagesEmbed} moderation={{}} />
|
|
||||||
)}
|
|
||||||
{AppBskyEmbedRecordWithMedia.isView(imagesEmbed) && (
|
|
||||||
<PostEmbeds embed={imagesEmbed.media} moderation={{}} />
|
|
||||||
)}
|
|
||||||
</Link>
|
</Link>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue