From 18824468d403d68e313d2223bd6083067d0c0ba4 Mon Sep 17 00:00:00 2001 From: "Tom (plebeius.eth)" Date: Wed, 29 May 2024 15:45:54 +0200 Subject: [PATCH] feat(post): add "file deleted" img on error --- .../comment-media/comment-media.module.css | 4 ++ .../comment-media/comment-media.tsx | 40 ++++++++----------- 2 files changed, 20 insertions(+), 24 deletions(-) diff --git a/src/components/comment-media/comment-media.module.css b/src/components/comment-media/comment-media.module.css index 1694db3c..f3732cba 100644 --- a/src/components/comment-media/comment-media.module.css +++ b/src/components/comment-media/comment-media.module.css @@ -112,4 +112,8 @@ .mediaDesktopOp img, .mediaDesktopOp video, .mediaDesktopOp iframe, .mediaDesktopOp audio { padding: 3px 20px 5px 0; +} + +.fileDeleted { + image-rendering: pixelated; } \ No newline at end of file diff --git a/src/components/comment-media/comment-media.tsx b/src/components/comment-media/comment-media.tsx index b147b1df..25f4c659 100644 --- a/src/components/comment-media/comment-media.tsx +++ b/src/components/comment-media/comment-media.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import React, { useState } from 'react'; import { useTranslation } from 'react-i18next'; import styles from './comment-media.module.css'; import { CommentMediaInfo, getDisplayMediaInfoType, getHasThumbnail } from '../../lib/utils/media-utils'; @@ -18,26 +18,10 @@ interface MediaProps { toggleExpanded?: () => void; } -interface ThumbnailProps { - style: React.CSSProperties; - children: React.ReactNode; - thumbnailSmallPadding?: string; -} - -const ThumbnailBig = ({ style, children }: ThumbnailProps) => ( - - {children} - -); - -const ThumbnailSmall = ({ style, children, thumbnailSmallPadding }: ThumbnailProps) => ( - - {children} - -); - const Thumbnail = ({ commentMediaInfo, isOutOfFeed, isReply, linkHeight, linkWidth, setShowThumbnail }: MediaProps) => { const { patternThumbnailUrl, thumbnail, type, url } = commentMediaInfo || {}; + const [hasError, setHasError] = useState(false); + const handleError = () => setHasError(true); let displayWidth, displayHeight; const isMobile = useWindowWidth() < 640; @@ -63,7 +47,7 @@ const Thumbnail = ({ commentMediaInfo, isOutOfFeed, isReply, linkHeight, linkWid const hasThumbnail = getHasThumbnail(commentMediaInfo, url); if (type === 'image') { - thumbnailComponent = setShowThumbnail(false)} />; + thumbnailComponent = setShowThumbnail(false)} />; } else if (type === 'video') { thumbnailComponent = thumbnail ? :