From 9db72eeb3246451528dda32b9ae7aa1c3fbe50d2 Mon Sep 17 00:00:00 2001
From: jarvis2f <137974272+jarvis2f@users.noreply.github.com>
Date: Fri, 7 Feb 2025 20:20:45 +0800
Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=B8=20feat:=20Optimize=20file=20extra?=
=?UTF-8?q?=20display?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
web/src/components/file-extra.tsx | 32 ++++++++++++++++++++++---------
1 file changed, 23 insertions(+), 9 deletions(-)
diff --git a/web/src/components/file-extra.tsx b/web/src/components/file-extra.tsx
index cb6ac22..6ab72d6 100644
--- a/web/src/components/file-extra.tsx
+++ b/web/src/components/file-extra.tsx
@@ -146,17 +146,31 @@ function FileTime({ file }: { file: TelegramFile }) {
);
}
+function hasValue(value: string | null | undefined): boolean {
+ return value !== null && value !== undefined && value.trim() !== "";
+}
+
export default function FileExtra({ file, rowHeight }: FileExtraProps) {
if (rowHeight === "s") {
- return (
-
- {file.fileName ? (
-
- ) : (
-
- )}
-
- );
+ const renderOrder = [
+ { key: "fileName", Component: FileName },
+ { key: "caption", Component: FileCaption },
+ { key: "localPath", Component: FilePath },
+ { key: "default", Component: FileTime },
+ ];
+
+ for (const item of renderOrder) {
+ if (
+ item.key === "default" ||
+ hasValue(file[item.key as keyof typeof file] as string)
+ ) {
+ return (
+
+
+
+ );
+ }
+ }
}
return (