From 0c31d4e7b3a090c8c64bb7a86dd063fa0962aa73 Mon Sep 17 00:00:00 2001 From: Manuel Palenzuela Merino Date: Sat, 13 Jul 2024 09:40:39 +0200 Subject: Pages: File: Dont show if file doesnt exist --- src/pages/File.tsx | 46 +++++++++++++++++++++++++++------------------- 1 file changed, 27 insertions(+), 19 deletions(-) diff --git a/src/pages/File.tsx b/src/pages/File.tsx index be611eb..bbbdac2 100644 --- a/src/pages/File.tsx +++ b/src/pages/File.tsx @@ -13,6 +13,8 @@ export default function File(props: any) { const latestFile = files[0] as FSTracerFile | undefined + const maxFilesToShow = 20; + useEffect(() => { if (!props.session) { navigate('/login') @@ -26,7 +28,7 @@ export default function File(props: any) { .select() .eq('absolute_path', filepath) .order('timestamp', { ascending: false }) - .range(0, 20) + .range(0, maxFilesToShow) if (error) { console.error(error) return @@ -52,27 +54,33 @@ export default function File(props: any) {
-
- { - formatFilePathAsName(filepath as string)// TODO: Filepath could be null - } -
-
-
- {latestFile && + {filepath && latestFile ? <> +
+ { + formatFilePathAsName(filepath) }
-
-
-
- {files.map((file: FSTracerFile) => ( -
-

{file.absolute_path} - {file.timestamp}

-
- )) - } +
+
+ {latestFile && } +
+
+
+
+ {files.map((file: FSTracerFile) => ( +
+

{file.absolute_path} - {file.timestamp}

+
+ )) + } +
+
+ : <> +
+

File not found

-
+ + }
-- cgit 1.4.1