fix: hold gif thumbnails until first frame is ready

Distinguish GIF frame loading from GIF frame failure in useFetchGifFirstFrame(), so thread and catalog thumbnails no longer render animated GIFs before the still frame arrives. Keep the existing animated fallback when the first-frame fetch actually fails.
This commit is contained in:
plebeius
2026-03-07 21:16:13 +08:00
parent b064cf0511
commit 34e2c2bc4d
7 changed files with 108 additions and 45 deletions
+3 -3
View File
@@ -39,11 +39,11 @@ export const LinkTypePreviewer = ({ link }: { link: string }) => {
const { t } = useTranslation();
const mediaInfo = getLinkMediaInfo(link);
let type = mediaInfo?.type;
const gifFrameUrl = useFetchGifFirstFrame(type === 'gif' ? mediaInfo?.url : undefined);
const { status: gifFrameStatus } = useFetchGifFirstFrame(type === 'gif' ? mediaInfo?.url : undefined);
if (type === 'gif' && gifFrameUrl !== null) {
if (type === 'gif' && gifFrameStatus === 'ready') {
type = t('animated_gif');
} else if (type === 'gif' && gifFrameUrl === null) {
} else if (type === 'gif') {
type = t('gif');
}