From 44fbc4ebdcb6254ab87ddd6488019fd6221375ef Mon Sep 17 00:00:00 2001 From: igorrCarvalho Date: Fri, 7 Jun 2024 18:47:19 -0300 Subject: [PATCH] Fix: Image files displaying as normal files --- .../IOModal/components/chatView/fileComponent/index.tsx | 4 ++-- .../IOModal/components/chatView/filePreviewChat/index.tsx | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/frontend/src/modals/IOModal/components/chatView/fileComponent/index.tsx b/src/frontend/src/modals/IOModal/components/chatView/fileComponent/index.tsx index 6d013d52e..b62e0f763 100644 --- a/src/frontend/src/modals/IOModal/components/chatView/fileComponent/index.tsx +++ b/src/frontend/src/modals/IOModal/components/chatView/fileComponent/index.tsx @@ -8,7 +8,7 @@ import DownloadButton from "./components/downloadButton/downloadButton"; import getClasses from "./utils/get-classes"; import handleDownload from "./utils/handle-download"; -const imgTypes = new Set(["png", "jpg"]); +const imgTypes = new Set(["png", "jpg", "jpeg", "gif", "webp", "image"]); export default function FileCard({ fileName, @@ -29,7 +29,7 @@ export default function FileCard({ const imgSrc = `${BACKEND_URL.slice( 0, - BACKEND_URL.length - 1 + BACKEND_URL.length - 1, )}${BASE_URL_API}files/images/${content}`; if (showFile) { diff --git a/src/frontend/src/modals/IOModal/components/chatView/filePreviewChat/index.tsx b/src/frontend/src/modals/IOModal/components/chatView/filePreviewChat/index.tsx index 10b873a5c..f1ff169b0 100644 --- a/src/frontend/src/modals/IOModal/components/chatView/filePreviewChat/index.tsx +++ b/src/frontend/src/modals/IOModal/components/chatView/filePreviewChat/index.tsx @@ -5,6 +5,8 @@ import IconComponent, { import { Skeleton } from "../../../../../components/ui/skeleton"; import formatFileName from "./utils/format-file-name"; +const supImgFiles = ["png", "jpg", "jpeg", "gif", "bmp", "webp", "image"]; + export default function FilePreview({ error, file, @@ -16,7 +18,8 @@ export default function FilePreview({ error: boolean; onDelete: () => void; }) { - const isImage = file.type.toLowerCase().includes("image"); + const fileType = file.type.toLowerCase(); + const isImage = supImgFiles.some((type) => fileType.includes(type)); const [isHovered, setIsHovered] = useState(false);