fix: resolve 404 on delete, reload UI properly for trash actions
All checks were successful
Automated Container Build / build-and-push (push) Successful in 39s
All checks were successful
Automated Container Build / build-and-push (push) Successful in 39s
This commit is contained in:
parent
854da9a50d
commit
9807ad6fe5
2 changed files with 17 additions and 5 deletions
|
|
@ -636,7 +636,11 @@ export default function FileExplorer({ onLogout }: FileExplorerProps) {
|
||||||
await api.deleteFile(path, isPermanent);
|
await api.deleteFile(path, isPermanent);
|
||||||
}
|
}
|
||||||
setSelectedFiles(new Set());
|
setSelectedFiles(new Set());
|
||||||
|
if (activeSection === 'trash') {
|
||||||
|
loadTrash();
|
||||||
|
} else {
|
||||||
loadFiles(undefined, true);
|
loadFiles(undefined, true);
|
||||||
|
}
|
||||||
setDeleteConfirm(null);
|
setDeleteConfirm(null);
|
||||||
showToast(isPermanent ? `Permanently deleted ${count} item${count > 1 ? 's' : ''}` : `Deleted ${count} item${count > 1 ? 's' : ''}`);
|
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) {
|
async function executeDeleteSingle(file: FileItem) {
|
||||||
const isPermanent = activeSection === 'trash';
|
const isPermanent = activeSection === 'trash';
|
||||||
await api.deleteFile(file.path, isPermanent);
|
await api.deleteFile(file.path, isPermanent);
|
||||||
|
if (isPermanent) {
|
||||||
|
loadTrash();
|
||||||
|
} else {
|
||||||
loadFiles(undefined, true);
|
loadFiles(undefined, true);
|
||||||
|
}
|
||||||
setDeleteConfirm(null);
|
setDeleteConfirm(null);
|
||||||
showToast(isPermanent ? `Permanently deleted ${file.name}` : `Deleted ${file.name}`);
|
showToast(isPermanent ? `Permanently deleted ${file.name}` : `Deleted ${file.name}`);
|
||||||
}
|
}
|
||||||
|
|
@ -687,7 +695,11 @@ export default function FileExplorer({ onLogout }: FileExplorerProps) {
|
||||||
|
|
||||||
async function handleRestore(file: FileItem) {
|
async function handleRestore(file: FileItem) {
|
||||||
await api.restoreFromTrash(file.path);
|
await api.restoreFromTrash(file.path);
|
||||||
|
if (activeSection === 'trash') {
|
||||||
loadTrash();
|
loadTrash();
|
||||||
|
} else {
|
||||||
|
loadFiles(undefined, true);
|
||||||
|
}
|
||||||
showToast(`Restored ${file.name}`);
|
showToast(`Restored ${file.name}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -202,8 +202,8 @@ class ApiClient {
|
||||||
}
|
}
|
||||||
|
|
||||||
async deleteFile(path: string, permanent: boolean = false) {
|
async deleteFile(path: string, permanent: boolean = false) {
|
||||||
const query = permanent ? '&permanent=true' : '';
|
const query = permanent ? '?permanent=true' : '';
|
||||||
const res = await this.request(`/api/files/?path=${encodeURIComponent(path)}${query}`, {
|
const res = await this.request(`/api/files/${encodeURIComponent(path)}${query}`, {
|
||||||
method: 'DELETE',
|
method: 'DELETE',
|
||||||
});
|
});
|
||||||
return res.json();
|
return res.json();
|
||||||
|
|
|
||||||
Reference in a new issue