From 79292e89f20280d5f506754a1e989779aa3baa86 Mon Sep 17 00:00:00 2001 From: Azalea Gui Date: Thu, 23 Feb 2023 15:18:06 -0500 Subject: [PATCH] [O] UI: file_type compatibility --- src/App.tsx | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index c2da293..3147913 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -15,12 +15,15 @@ import InfiniteScroll from 'solid-infinite-scroll-fork'; interface File { name: string - type: 'file' | 'directory' + type?: 'file' | 'directory' + file_type?: 'file' | 'directory' | 'link' size: number mtime: string mime?: string } +const getType = (f: File) => f.type ?? f.file_type + // Placeholder for nginx to replace let deployPath = "{DEPLOY-PATH-PLACEHOLDER}" let host = "{HOST-PLACEHOLDER}" @@ -43,7 +46,7 @@ const fetchApi = async () => function getIcon(f: File) { - if (f.type == "directory") return urlJoin(deployPath, "mime/folder.svg") + if (getType(f) == "directory") return urlJoin(deployPath, "mime/folder.svg") const sp = f.name.split(".") const m = f.mime ?? mime.getType(sp[sp.length - 1]) @@ -53,7 +56,8 @@ function getIcon(f: File) function getHref(f: File) { - return f.type == "directory" ? urlJoin(fullPath, f.name) : urlJoin(host, filePath, f.name) + return getType(f) == "directory" ? urlJoin(fullPath, f.name) : urlJoin(host, filePath, f.name) + // return urlJoin(fullPath, f.name) } const alpNum = new Set("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ")