From 9807ad6fe5344d16fe25cdab5b0a862d6a103c0d Mon Sep 17 00:00:00 2001 From: Elijah Date: Sat, 23 May 2026 14:26:56 -0700 Subject: [PATCH] fix: resolve 404 on delete, reload UI properly for trash actions --- frontend/src/components/FileExplorer.tsx | 18 +++++++++++++++--- frontend/src/lib/api.ts | 4 ++-- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/frontend/src/components/FileExplorer.tsx b/frontend/src/components/FileExplorer.tsx index a443bcc..8a36975 100644 --- a/frontend/src/components/FileExplorer.tsx +++ b/frontend/src/components/FileExplorer.tsx @@ -636,7 +636,11 @@ export default function FileExplorer({ onLogout }: FileExplorerProps) { await api.deleteFile(path, isPermanent); } setSelectedFiles(new Set()); - loadFiles(undefined, true); + if (activeSection === 'trash') { + loadTrash(); + } else { + loadFiles(undefined, true); + } setDeleteConfirm(null); showToast(isPermanent ? `Permanently deleted ${count} item${count > 1 ? 's' : ''}` : `Deleted ${count} item${count > 1 ? 's' : ''}`); } @@ -644,7 +648,11 @@ export default function FileExplorer({ onLogout }: FileExplorerProps) { async function executeDeleteSingle(file: FileItem) { const isPermanent = activeSection === 'trash'; await api.deleteFile(file.path, isPermanent); - loadFiles(undefined, true); + if (isPermanent) { + loadTrash(); + } else { + loadFiles(undefined, true); + } setDeleteConfirm(null); showToast(isPermanent ? `Permanently deleted ${file.name}` : `Deleted ${file.name}`); } @@ -687,7 +695,11 @@ export default function FileExplorer({ onLogout }: FileExplorerProps) { async function handleRestore(file: FileItem) { await api.restoreFromTrash(file.path); - loadTrash(); + if (activeSection === 'trash') { + loadTrash(); + } else { + loadFiles(undefined, true); + } showToast(`Restored ${file.name}`); } diff --git a/frontend/src/lib/api.ts b/frontend/src/lib/api.ts index dc26cb2..962c093 100644 --- a/frontend/src/lib/api.ts +++ b/frontend/src/lib/api.ts @@ -202,8 +202,8 @@ class ApiClient { } async deleteFile(path: string, permanent: boolean = false) { - const query = permanent ? '&permanent=true' : ''; - const res = await this.request(`/api/files/?path=${encodeURIComponent(path)}${query}`, { + const query = permanent ? '?permanent=true' : ''; + const res = await this.request(`/api/files/${encodeURIComponent(path)}${query}`, { method: 'DELETE', }); return res.json();