feat(offline): gate the offline toggle on dictionary readiness #205
Reference in New Issue
Block a user
Delete Branch "feature/offline-toggle-readiness"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Fast-follow (b) from the offline plan: the Settings offline toggle now enforces dictionary readiness before entering offline mode, so you cannot land in a half-baked offline (no dawg -> cannot create/play a local vs_ai game) when the background preload has not finished yet.
Behaviour (round-3 design): flipping to offline fetches the enabled variants dictionaries cache-first (instant when already warm) and waits at most ~5 s, greying the toggle meanwhile. Ready -> enters offline (deliberate, persisted). Not ready in time -> stays online with a needs internet note, while the fetch keeps warming the cache in the background so a later flip is instant. Leaving offline (-> online) is never gated.
Shape:
offline.tsraceOfflineReady(pure, injected sleep) — unit-tested red->green (ready / still-failed / timeout).dict/offlineready.tsensureOfflineDicts— cache-firstpreloadDicts, lazy chunk (kept out of the main bundle).offline.svelte.tsrequestOffline(+TOGGLE_READY_BUDGET_MS).Settings.svelte—checking/needsDatastate, disabled toggle during the wait, inline note.settings.offlineChecking/settings.offlineNeedsData(en+ru).Verified local: check 0 / unit 482 / e2e 196 / app entry 113.8/114 KB. Not reachable in the mock e2e (the toggle is PWA-gated) — contour review needed.