fix: resolve upload delay and refine trash functionality
All checks were successful
Automated Container Build / build-and-push (push) Successful in 1m22s
All checks were successful
Automated Container Build / build-and-push (push) Successful in 1m22s
This commit is contained in:
parent
45989ef97d
commit
db946461d7
3 changed files with 49 additions and 21 deletions
|
|
@ -631,20 +631,22 @@ export default function FileExplorer({ onLogout }: FileExplorerProps) {
|
|||
|
||||
async function executeDeleteSelected() {
|
||||
const count = selectedFiles.size;
|
||||
const isPermanent = activeSection === 'trash';
|
||||
for (const path of selectedFiles) {
|
||||
await api.deleteFile(path);
|
||||
await api.deleteFile(path, isPermanent);
|
||||
}
|
||||
setSelectedFiles(new Set());
|
||||
loadFiles(undefined, true);
|
||||
setDeleteConfirm(null);
|
||||
showToast(`Deleted ${count} item${count > 1 ? 's' : ''}`);
|
||||
showToast(isPermanent ? `Permanently deleted ${count} item${count > 1 ? 's' : ''}` : `Deleted ${count} item${count > 1 ? 's' : ''}`);
|
||||
}
|
||||
|
||||
async function executeDeleteSingle(file: FileItem) {
|
||||
await api.deleteFile(file.path);
|
||||
const isPermanent = activeSection === 'trash';
|
||||
await api.deleteFile(file.path, isPermanent);
|
||||
loadFiles(undefined, true);
|
||||
setDeleteConfirm(null);
|
||||
showToast(`Deleted ${file.name}`);
|
||||
showToast(isPermanent ? `Permanently deleted ${file.name}` : `Deleted ${file.name}`);
|
||||
}
|
||||
|
||||
async function handlePin(file: FileItem) {
|
||||
|
|
@ -880,16 +882,16 @@ export default function FileExplorer({ onLogout }: FileExplorerProps) {
|
|||
}
|
||||
await Promise.all(workers);
|
||||
|
||||
loadFiles(undefined, true);
|
||||
setTimeout(() => {
|
||||
setUploads(prev => prev.filter(u => u.id !== batchId));
|
||||
loadFiles(undefined, true);
|
||||
}, 3000);
|
||||
}
|
||||
|
||||
async function handleDrop(e: React.DragEvent) {
|
||||
e.preventDefault();
|
||||
setDragOver(false);
|
||||
if (draggedFile) return;
|
||||
if (draggedFile || activeSection === 'trash') return;
|
||||
|
||||
if (e.dataTransfer.items) {
|
||||
const filesToUpload: { file: File; path: string }[] = [];
|
||||
|
|
@ -968,7 +970,7 @@ export default function FileExplorer({ onLogout }: FileExplorerProps) {
|
|||
|
||||
async function handleFileUpload(e: React.ChangeEvent<HTMLInputElement>) {
|
||||
const uploadFiles = e.target.files;
|
||||
if (!uploadFiles) return;
|
||||
if (!uploadFiles || activeSection === 'trash') return;
|
||||
const filesArray = Array.from(uploadFiles).map(f => ({ file: f, path: '' }));
|
||||
|
||||
const fileNames = filesArray.map(f => f.file.name);
|
||||
|
|
@ -1777,18 +1779,20 @@ export default function FileExplorer({ onLogout }: FileExplorerProps) {
|
|||
>
|
||||
<Download className="w-4 h-4" />
|
||||
</button>
|
||||
<button
|
||||
className="p-2 hover:bg-white/5 rounded-lg transition-colors flex items-center gap-2 text-sm"
|
||||
style={{ color: 'var(--color-text-primary)' }}
|
||||
title="Move Selected"
|
||||
onClick={() => {
|
||||
setMovingFiles(Array.from(selectedFiles));
|
||||
setMoveModalPath('.');
|
||||
setShowMoveModal(true);
|
||||
}}
|
||||
>
|
||||
<Move className="w-4 h-4" />
|
||||
</button>
|
||||
{activeSection !== 'trash' && (
|
||||
<button
|
||||
className="p-2 hover:bg-white/5 rounded-lg transition-colors flex items-center gap-2 text-sm"
|
||||
style={{ color: 'var(--color-text-primary)' }}
|
||||
title="Move Selected"
|
||||
onClick={() => {
|
||||
setMovingFiles(Array.from(selectedFiles));
|
||||
setMoveModalPath('.');
|
||||
setShowMoveModal(true);
|
||||
}}
|
||||
>
|
||||
<Move className="w-4 h-4" />
|
||||
</button>
|
||||
)}
|
||||
<button
|
||||
className="p-2 hover:bg-red-500/10 rounded-lg transition-colors flex items-center gap-2 text-sm text-red-500"
|
||||
title="Delete Selected"
|
||||
|
|
@ -1839,6 +1843,16 @@ export default function FileExplorer({ onLogout }: FileExplorerProps) {
|
|||
label="Restore"
|
||||
onClick={() => { handleRestore(contextMenu.file); setContextMenu(null); }}
|
||||
/>
|
||||
<div className="h-px mx-2 my-1" style={{ backgroundColor: 'var(--color-border-subtle)' }} />
|
||||
<ContextMenuItem
|
||||
icon={<Trash2 className="w-4 h-4" />}
|
||||
label="Delete Permanently"
|
||||
danger
|
||||
onClick={() => {
|
||||
setDeleteConfirm({ type: 'single', file: contextMenu.file });
|
||||
setContextMenu(null);
|
||||
}}
|
||||
/>
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
|
|
|
|||
Reference in a new issue