From 1aca79defc7f9b78123a5911472c6d4427edb4a1 Mon Sep 17 00:00:00 2001 From: Hayden Hargreaves Date: Thu, 6 Mar 2025 18:36:44 -0700 Subject: [PATCH] FIX: Spinner for the directory list. --- backend/src/server.ts | 4 ---- frontend/src/pages/Dashboard.jsx | 9 ++++++++- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/backend/src/server.ts b/backend/src/server.ts index ac42aad..fbbf948 100644 --- a/backend/src/server.ts +++ b/backend/src/server.ts @@ -97,10 +97,6 @@ v1.post("/login", (req: Request, res: Response): void => { v1.get("/children", (req: Request, res: Response): void => { // Get the path, if it was not provided, use the root const path: string = (req.query.path || ROOT) as string; - // if (!path) { - // res.status(400).json({error: "Please provide a path. E.g. /v1/children?path=/path/to/target", code: 400}); - // return; - // } // An array of names which are the children const children_paths: string[] = fs.readdirSync(path); diff --git a/frontend/src/pages/Dashboard.jsx b/frontend/src/pages/Dashboard.jsx index 8352d3b..2f9eacd 100644 --- a/frontend/src/pages/Dashboard.jsx +++ b/frontend/src/pages/Dashboard.jsx @@ -5,6 +5,7 @@ import PathDisplay from "../components/PathDisplay.jsx"; import Navbar from "../components/Navbar.jsx"; import Error from "../components/Error.jsx"; import Editor from "../components/Editor.jsx"; +import ChildrenLoading from "../components/ChildrenLoading.jsx"; export default function Dashboard() { // Store the default path @@ -26,6 +27,7 @@ export default function Dashboard() { const [files, setFiles] = useState([]); const [error, setError] = useState(null); const [editing, setEditing] = useState(""); + const [childrenLoading, setChildrenLoading] = useState(false); const navigate = useNavigate(); @@ -62,13 +64,17 @@ export default function Dashboard() { return await response.json(); } - // If the token doesnt exit, udpate it and use the return value. + setChildrenLoading(true); + + // If the token doesnt exit, update it and use the return value. // This is a silly work around to prevent the first render from not working // TODO: Fix this shit. let tkn = token ? token : updateToken(); getData(tkn).then((data) => { setFiles(data); + }).finally(() => { + setChildrenLoading(false); }); setSelected([]); @@ -277,6 +283,7 @@ export default function Dashboard() { defaultPath.length}/>
+ {childrenLoading && }