🚸 feat: Optimize file extra display
This commit is contained in:
parent
9b35f8ad39
commit
9db72eeb32
1 changed files with 23 additions and 9 deletions
|
|
@ -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) {
|
export default function FileExtra({ file, rowHeight }: FileExtraProps) {
|
||||||
if (rowHeight === "s") {
|
if (rowHeight === "s") {
|
||||||
return (
|
const renderOrder = [
|
||||||
<TooltipProvider>
|
{ key: "fileName", Component: FileName },
|
||||||
{file.fileName ? (
|
{ key: "caption", Component: FileCaption },
|
||||||
<FileName file={file} />
|
{ key: "localPath", Component: FilePath },
|
||||||
) : (
|
{ key: "default", Component: FileTime },
|
||||||
<FileCaption file={file} rowHeight={rowHeight} />
|
];
|
||||||
)}
|
|
||||||
</TooltipProvider>
|
for (const item of renderOrder) {
|
||||||
);
|
if (
|
||||||
|
item.key === "default" ||
|
||||||
|
hasValue(file[item.key as keyof typeof file] as string)
|
||||||
|
) {
|
||||||
|
return (
|
||||||
|
<TooltipProvider>
|
||||||
|
<item.Component file={file} rowHeight={rowHeight} />
|
||||||
|
</TooltipProvider>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue