mirror of
https://github.com/amitwh/markdown-converter.git
synced 2026-08-02 10:00:17 +05:30
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:
@@ -86,7 +86,9 @@ export const useFileStore = create<FileState>()(
|
||||
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) => {
|
||||
s.tree = {
|
||||
@@ -117,7 +119,9 @@ export const useFileStore = create<FileState>()(
|
||||
|
||||
set((s) => {
|
||||
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;
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user