fix: handle list-directory return shape {entries} in openFolder/loadChildren

The main process list-directory handler returns {path, entries} but
the file store was calling .map() directly on result.data. Since
arrays have a .entries iterator method, the nullish coalescing
fallback didn't work. Now properly extracts the entries array with
Array.isArray check.
This commit is contained in:
2026-06-11 07:49:42 +05:30
parent 9ef5317d71
commit 50f4f62575
+6 -2
View File
@@ -86,7 +86,9 @@ export const useFileStore = create<FileState>()(
return; return;
} }
const children: FileNode[] = result.data!.map(entryToNode); const raw: any = result.data!;
const entries: any[] = Array.isArray(raw) ? raw : raw.entries;
const children: FileNode[] = entries.map(entryToNode);
set((s) => { set((s) => {
s.tree = { s.tree = {
@@ -117,7 +119,9 @@ export const useFileStore = create<FileState>()(
set((s) => { set((s) => {
updateNode(s.tree!, dirPath, (node) => { updateNode(s.tree!, dirPath, (node) => {
node.children = result.data!.map(entryToNode); const raw: any = result.data!;
const items: any[] = Array.isArray(raw) ? raw : raw.entries;
node.children = items.map(entryToNode);
node.loaded = true; node.loaded = true;
}); });
}); });