From 6ec6d522e85fc8c84bb88a7ee377fb934de83dc3 Mon Sep 17 00:00:00 2001 From: Hailey <153161762+haileyok@users.noreply.github.com> Date: Wed, 10 Jan 2024 22:36:47 -0800 Subject: [PATCH] fix rendering of external in quote embeds (#2464) --- src/view/com/util/post-embeds/QuoteEmbed.tsx | 30 ++++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/view/com/util/post-embeds/QuoteEmbed.tsx b/src/view/com/util/post-embeds/QuoteEmbed.tsx index bb8375df67..e4a091e04f 100644 --- a/src/view/com/util/post-embeds/QuoteEmbed.tsx +++ b/src/view/com/util/post-embeds/QuoteEmbed.tsx @@ -6,6 +6,7 @@ import { AppBskyEmbedImages, AppBskyEmbedRecordWithMedia, ModerationUI, + AppBskyEmbedExternal, } from '@atproto/api' import {AtUri} from '@atproto/api' import {PostMeta} from '../PostMeta' @@ -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 ( ) : null} - {AppBskyEmbedImages.isView(imagesEmbed) && ( - - )} - {AppBskyEmbedRecordWithMedia.isView(imagesEmbed) && ( - - )} + {embed && } ) }