diff options
| -rw-r--r-- | loading/lifecycle.ts | 15 | ||||
| -rw-r--r-- | routes/+page.svelte | 11 |
2 files changed, 24 insertions, 2 deletions
diff --git a/loading/lifecycle.ts b/loading/lifecycle.ts new file mode 100644 index 0000000..ef9f2d8 --- /dev/null +++ b/loading/lifecycle.ts @@ -0,0 +1,15 @@ +let completed = false + +/** + * Whether the initial-load pipeline has finished during this browser + * session. Navigating away from the Begin screen and returning should + * not replay the progress bar — once it has run, it has run. + */ +export function hasCompletedInitialLoad(): boolean { + return completed +} + +/** Record that the initial load has finished. Idempotent. */ +export function markInitialLoadComplete(): void { + completed = true +} diff --git a/routes/+page.svelte b/routes/+page.svelte index c807b41..babf994 100644 --- a/routes/+page.svelte +++ b/routes/+page.svelte @@ -6,14 +6,21 @@ import InitialLoadScreen from '@hollowdark/lib/screens/InitialLoadScreen.svelte' import { runStubInitialLoad } from '@hollowdark/loading/stub' import { detectBeginState, type BeginState } from '@hollowdark/loading/session' + import { + hasCompletedInitialLoad, + markInitialLoadComplete + } from '@hollowdark/loading/lifecycle' type View = 'loading' | 'begin' - let view: View = $state('loading') + let view: View = $state(hasCompletedInitialLoad() ? 'begin' : 'loading') let beginState: BeginState = $state({ kind: 'first-ever' }) onMount(async () => { - await runStubInitialLoad() + if (!hasCompletedInitialLoad()) { + await runStubInitialLoad() + markInitialLoadComplete() + } beginState = await detectBeginState() view = 'begin' }) |
