|
|
@@ -8,6 +8,7 @@ import {
|
|
|
createMemo,
|
|
|
For,
|
|
|
Match,
|
|
|
+ onCleanup,
|
|
|
Show,
|
|
|
splitProps,
|
|
|
Switch,
|
|
|
@@ -123,7 +124,28 @@ export default function FileTree(props: {
|
|
|
|
|
|
createEffect(() => {
|
|
|
const path = props.path
|
|
|
- untrack(() => void file.tree.list(path))
|
|
|
+ const state = { cancelled: false, timer: undefined as number | undefined }
|
|
|
+
|
|
|
+ const load = (attempt: number) => {
|
|
|
+ if (state.cancelled) return
|
|
|
+ if (file.tree.state(path)?.loaded) return
|
|
|
+
|
|
|
+ void untrack(() => file.tree.list(path)).finally(() => {
|
|
|
+ if (state.cancelled) return
|
|
|
+ if (file.tree.state(path)?.loaded) return
|
|
|
+ if (attempt >= 2) return
|
|
|
+
|
|
|
+ const wait = Math.min(2000, 250 * 2 ** attempt)
|
|
|
+ state.timer = window.setTimeout(() => load(attempt + 1), wait)
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ load(0)
|
|
|
+
|
|
|
+ onCleanup(() => {
|
|
|
+ state.cancelled = true
|
|
|
+ if (state.timer !== undefined) clearTimeout(state.timer)
|
|
|
+ })
|
|
|
})
|
|
|
|
|
|
const nodes = createMemo(() => {
|