From 3be80bc9fb5bf14df20740d36a843b9f36000b68 Mon Sep 17 00:00:00 2001 From: mbaharip <62494292+mbahArip@users.noreply.github.com> Date: Sun, 31 Mar 2024 00:51:04 +0700 Subject: [PATCH] Update file browser, file grid, file list, and password components --- src/app/@explorer.tsx | 2 +- src/app/@file.grid.tsx | 2 +- src/app/@file.list.tsx | 26 +++++++++++++++++++------- src/app/@password.tsx | 34 ++++++++++++++++++++++++++++------ 4 files changed, 49 insertions(+), 15 deletions(-) diff --git a/src/app/@explorer.tsx b/src/app/@explorer.tsx index 5d13054..ace1511 100644 --- a/src/app/@explorer.tsx +++ b/src/app/@explorer.tsx @@ -103,7 +103,7 @@ export default function FileBrowser({ files, nextPageToken }: Props) { key={file.encryptedId} data={file} /> - + ))} diff --git a/src/app/@file.grid.tsx b/src/app/@file.grid.tsx index 5aabf2a..8d6ab34 100644 --- a/src/app/@file.grid.tsx +++ b/src/app/@file.grid.tsx @@ -64,7 +64,7 @@ export default function FileGrid({ data }: Props) { <>
diff --git a/src/app/@file.list.tsx b/src/app/@file.list.tsx index 550f7a8..1e5a823 100644 --- a/src/app/@file.list.tsx +++ b/src/app/@file.list.tsx @@ -52,15 +52,27 @@ export default function FileList({ data }: Props) { >
{/* If it's media, show thumbnail */} -
+
{data.thumbnailLink && (data.mimeType.startsWith("video") || data.mimeType.startsWith("image")) ? ( - {data.name} + <> + {data.name} + + {data.mimeType.startsWith("video") && ( + <> + + + )} + ) : ( )}
diff --git a/src/app/@password.tsx b/src/app/@password.tsx index 9122bd8..0831685 100644 --- a/src/app/@password.tsx +++ b/src/app/@password.tsx @@ -1,7 +1,7 @@ "use client"; import { useRouter } from "next/navigation"; -import { useState } from "react"; +import { useEffect, useState } from "react"; import toast from "react-hot-toast"; import Icon from "~/components/Icon"; import { Button } from "~/components/ui/button"; @@ -18,10 +18,11 @@ export default function Password({ path, errorMessage }: Props) { const router = useRouter(); const [input, setInput] = useState(""); - const [loading, setLoading] = useState(false); + const [submitLoading, setSubmitLoading] = useState(false); + const [loading, setLoading] = useState(true); const onSubmit = async (e: React.FormEvent) => { e.preventDefault(); - setLoading(true); + setSubmitLoading(true); toast.loading("Checking password...", { id: "password", }); @@ -46,10 +47,31 @@ export default function Password({ path, errorMessage }: Props) { }); } finally { setInput(""); - setLoading(false); + setSubmitLoading(false); } }; + useEffect(() => { + setLoading(false); + }, []); + + if (loading) + return ( +
+ +

Checking password...

+
+ ); + return (
- {loading ? ( + {submitLoading ? ( <>