fix: resolve folder drag-and-drop, add remember me, fix pinned folder navigation
All checks were successful
Automated Container Build / build-and-push (push) Successful in 1m18s

This commit is contained in:
Elijah 2026-05-23 13:08:13 -07:00
parent 7278008d7e
commit b668418951
5 changed files with 89 additions and 14 deletions

View file

@ -433,7 +433,7 @@ export default function FileExplorer({ onLogout }: FileExplorerProps) {
if (section === 'files') {
navigateTo('.');
loadFiles();
loadFiles('.');
} else if (section === 'trash') {
loadTrash();
}
@ -748,11 +748,12 @@ export default function FileExplorer({ onLogout }: FileExplorerProps) {
}
}
async function uploadFile(file: File) {
async function uploadFile(file: File, targetDir?: string) {
const id = `${Date.now()}-${file.name}`;
setUploads(prev => [...prev, { id, name: file.name, progress: 0, status: 'uploading' }]);
try {
await api.upload(file, currentPath, {
const uploadPath = targetDir ? (currentPath === '.' ? targetDir : `${currentPath}/${targetDir}`) : currentPath;
await api.upload(file, uploadPath, {
onProgress: (percent) => {
setUploads(prev => prev.map(u => u.id === id ? { ...u, progress: percent } : u));
},
@ -770,8 +771,56 @@ export default function FileExplorer({ onLogout }: FileExplorerProps) {
e.preventDefault();
setDragOver(false);
if (draggedFile) return;
const droppedFiles = Array.from(e.dataTransfer.files);
await Promise.all(droppedFiles.map(file => uploadFile(file)));
if (e.dataTransfer.items) {
const filesToUpload: { file: File; path: string }[] = [];
const promises: Promise<void>[] = [];
const processEntry = async (entry: any, path: string = '') => {
if (entry.isFile) {
const file = await new Promise<File>((resolve) => entry.file(resolve));
filesToUpload.push({ file, path });
} else if (entry.isDirectory) {
const dirReader = entry.createReader();
let entries: any[] = [];
const readAllEntries = async () => {
const batch = await new Promise<any[]>((resolve) => dirReader.readEntries(resolve));
if (batch.length > 0) {
entries = entries.concat(batch);
await readAllEntries();
}
};
await readAllEntries();
for (const child of entries) {
await processEntry(child, `${path}${entry.name}/`);
}
}
};
for (let i = 0; i < e.dataTransfer.items.length; i++) {
const item = e.dataTransfer.items[i];
if (item.kind === 'file') {
const entry = item.webkitGetAsEntry();
if (entry) {
promises.push(processEntry(entry));
}
}
}
await Promise.all(promises);
if (filesToUpload.length > 0) {
await Promise.all(filesToUpload.map(({file, path}) =>
uploadFile(file, path.replace(/\/$/, ''))
));
}
} else {
const droppedFiles = Array.from(e.dataTransfer.files);
await Promise.all(droppedFiles.map(file => uploadFile(file)));
}
loadFiles(undefined, true);
}