fix(feed post): gif thumbnail could break persistently

This commit is contained in:
Tom (plebeius.eth)
2024-12-12 16:16:28 +01:00
parent ad483ed9f4
commit 2e86b3f2af
2 changed files with 9 additions and 4 deletions

View File

@@ -44,8 +44,8 @@ const Thumbnail = ({ cid, commentMediaInfo, expanded = false, isReply = false, l
mediaComponent = <img src={commentMediaInfo.thumbnail} alt='' />;
} else if (commentMediaInfo?.type === 'iframe') {
mediaComponent = iframeThumbnail ? <img src={iframeThumbnail} alt='' /> : null;
} else if (commentMediaInfo?.type === 'gif' && gifFrameUrl) {
mediaComponent = <img src={gifFrameUrl} alt='' />;
} else if (commentMediaInfo?.type === 'gif') {
mediaComponent = <img src={gifFrameUrl || commentMediaInfo.url} alt='' />;
}
return (

View File

@@ -75,8 +75,13 @@ const useFetchGifFirstFrame = (url: string | undefined) => {
try {
const cachedFrame = await getCachedGifFrame(url);
if (cachedFrame) {
if (isActive) setFrameUrl(cachedFrame);
return;
try {
const response = await fetch(cachedFrame);
if (response.ok) {
if (isActive) setFrameUrl(cachedFrame);
return;
}
} catch {}
}
const blob = typeof url === 'string' ? await parseGif(await fetchImage(url)) : await parseGif(await readImage(url as File));