From d3e11bd48cf6480d331600b9c7640c7869058289 Mon Sep 17 00:00:00 2001 From: "Tom (plebeius.eth)" Date: Thu, 12 Dec 2024 16:41:18 +0100 Subject: [PATCH] refactor, don't allow click to enlarge on 404'd images --- .../comment-media/comment-media.tsx | 115 +++++++++++------- 1 file changed, 69 insertions(+), 46 deletions(-) diff --git a/src/components/comment-media/comment-media.tsx b/src/components/comment-media/comment-media.tsx index c81e97ba..78f6fe3c 100644 --- a/src/components/comment-media/comment-media.tsx +++ b/src/components/comment-media/comment-media.tsx @@ -29,18 +29,14 @@ interface MediaProps { const Thumbnail = ({ commentMediaInfo, deleted, displayHeight, displayWidth, isFloatingEmbed, isOutOfFeed, isReply, removed, spoiler, setShowThumbnail }: MediaProps) => { const isMobile = useIsMobile(); const { patternThumbnailUrl, thumbnail, type, url } = commentMediaInfo || {}; - const [hasError, setHasError] = useState(false); - const handleError = () => setHasError(true); let thumbnailComponent: React.ReactNode = null; const iframeThumbnail = patternThumbnailUrl || thumbnail; const gifFrameUrl = useFetchGifFirstFrame(type === 'gif' ? url : undefined); const hasThumbnail = getHasThumbnail(commentMediaInfo, url); - if (type === 'gif' && gifFrameUrl) { - thumbnailComponent = setShowThumbnail(false)} />; - } else if (type === 'image') { - thumbnailComponent = setShowThumbnail(false)} />; + if (type === 'gif') { + thumbnailComponent = setShowThumbnail(false)} />; } else if (type === 'video') { thumbnailComponent = thumbnail ? ( @@ -61,7 +57,7 @@ const Thumbnail = ({ commentMediaInfo, deleted, displayHeight, displayWidth, isF const linkWithoutThumbnail = url && new URL(url); - return hasError || deleted || removed ? ( + return deleted || removed ? ( File deleted ) : spoiler ? ( setShowThumbnail(false)} /> @@ -106,8 +102,6 @@ const Media = ({ commentMediaInfo, isReply, setShowThumbnail }: MediaProps) => { setShowThumbnail(true)} /> ) : type === 'video' ? (