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 (