From bcf752bf68e9ee4dcfaefcd75a599bb81ee48f66 Mon Sep 17 00:00:00 2001 From: Stephen Zhou <38493346+hyoban@users.noreply.github.com> Date: Thu, 17 Apr 2025 11:06:45 +0800 Subject: [PATCH] fix: use preview image url for video item, close #3485 --- .../entry-list/templates/EntrySocialItem.tsx | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/apps/mobile/src/modules/entry-list/templates/EntrySocialItem.tsx b/apps/mobile/src/modules/entry-list/templates/EntrySocialItem.tsx index bfd8a7df2..a8c4d43c1 100644 --- a/apps/mobile/src/modules/entry-list/templates/EntrySocialItem.tsx +++ b/apps/mobile/src/modules/entry-list/templates/EntrySocialItem.tsx @@ -104,11 +104,19 @@ export const EntrySocialItem = memo(({ entryId }: { entryId: string }) => { {media && media.length > 0 && ( - {media.map((image, index) => { + {media.map((mediaItem, index) => { + // TODO: support video + const imageUrl = + mediaItem.type === "video" + ? mediaItem.preview_image_url + : mediaItem.type === "photo" + ? mediaItem.url + : undefined const fullWidth = index === media.length - 1 && media.length % 2 === 1 + if (!imageUrl) return null return ( @@ -116,11 +124,13 @@ export const EntrySocialItem = memo(({ entryId }: { entryId: string }) => { proxy={{ width: fullWidth ? 400 : 200, }} - source={{ uri: image.url }} - blurhash={image.blurhash} + source={{ uri: imageUrl }} + blurhash={mediaItem.blurhash} className="border-secondary-system-background w-full rounded-lg border" aspectRatio={ - fullWidth && image.width && image.height ? image.width / image.height : 1 + fullWidth && mediaItem.width && mediaItem.height + ? mediaItem.width / mediaItem.height + : 1 } />