From ab19d2419f44dcb26b53d7a13a58ff0f39aef460 Mon Sep 17 00:00:00 2001 From: Louis Date: Thu, 19 Dec 2024 18:42:43 +0700 Subject: [PATCH] chore: clean file info retrieval api --- .../TextMessage/DocMessage.tsx | 17 +++-------------- web/utils/file.ts | 9 --------- 2 files changed, 3 insertions(+), 23 deletions(-) diff --git a/web/screens/Thread/ThreadCenterPanel/TextMessage/DocMessage.tsx b/web/screens/Thread/ThreadCenterPanel/TextMessage/DocMessage.tsx index 161c17dd67..9e00d2b836 100644 --- a/web/screens/Thread/ThreadCenterPanel/TextMessage/DocMessage.tsx +++ b/web/screens/Thread/ThreadCenterPanel/TextMessage/DocMessage.tsx @@ -1,9 +1,8 @@ -import { memo, useEffect, useState } from 'react' +import { memo } from 'react' import { usePath } from '@/hooks/usePath' import { toGibibytes } from '@/utils/converter' -import { getFileInfo } from '@/utils/file' import Icon from '../FileUploadPreview/Icon' @@ -15,16 +14,6 @@ const DocMessage = ({ metadata: Record | undefined }) => { const { onViewFile } = usePath() - const [fileInfo, setFileInfo] = useState< - { filename: string; id: string } | undefined - >() - useEffect(() => { - if (!fileInfo) { - getFileInfo(id).then((data) => { - setFileInfo(data) - }) - } - }, [fileInfo, id]) return (
@@ -38,12 +27,12 @@ const DocMessage = ({
{metadata && 'filename' in metadata ? (metadata.filename as string) - : fileInfo?.filename} + : id}

{metadata && 'size' in metadata ? toGibibytes(Number(metadata.size)) - : (fileInfo?.id ?? id)} + : id}

diff --git a/web/utils/file.ts b/web/utils/file.ts index e20a75dc37..83c9107c64 100644 --- a/web/utils/file.ts +++ b/web/utils/file.ts @@ -47,12 +47,3 @@ export const uploader = () => { }) return uppy } - -/** - * Get the file information from the server. - */ -export const getFileInfo = (id: string) => { - return fetch(`${API_BASE_URL}/v1/files/${id}`) - .then((e) => e.json()) - .catch(() => undefined) -}