From 6e3be3881f600153ed98c06880965da62283a784 Mon Sep 17 00:00:00 2001 From: Bobby Date: Wed, 22 Apr 2026 09:18:25 +0530 Subject: Hold the initial-load progress bar to the first session entry and skip it on return --- loading/lifecycle.ts | 15 +++++++++++++++ routes/+page.svelte | 11 +++++++++-- 2 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 loading/lifecycle.ts 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' }) -- cgit v1.2.3