Fetch tree only when it's expanded

Signed-off-by: Rūdolfs Ošiņš <rudolfs@osins.org>
This commit is contained in:
Rūdolfs Ošiņš
2023-06-06 14:32:10 +02:00
parent ccc854dac1
commit 5b3c293293
+5 -3
View File
@@ -16,9 +16,11 @@
export let revision: string;
let expanded = currentPath.indexOf(prefix) === 0;
let tree: Promise<Tree | undefined> = fetchTree(prefix).then(tree => {
if (expanded) return tree;
});
let tree: Promise<Tree | undefined> = expanded
? fetchTree(prefix).then(tree => {
return tree;
})
: Promise.resolve(undefined);
const dispatch = createEventDispatcher<{ select: string }>();
const onSelectFile = ({ detail: path }: { detail: string }) =>