fix(kiosk): no reload on first service-worker claim + patient boot health check
Two causes of the fresh-install 'loads, refreshes, loads again' jank: - The PWA autoUpdate service worker claims the page right after the very first load, firing controllerchange, which unconditionally reloaded the page. Now only a *replaced* controller (a real update) triggers reload. - A single 2s RPC echo decided server-down on first boot, flashing the BootScreen and then hard-reloading seconds later. A second, 6s attempt now runs before concluding the backend is down. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Fable 5
parent
fa91faa67c
commit
66fd121748
@@ -32,8 +32,18 @@ let updateCallback: (() => Promise<void>) | null = null
|
||||
onMounted(() => {
|
||||
// Listen for service worker updates
|
||||
if ('serviceWorker' in navigator) {
|
||||
// On the very first visit the page loads with no controlling SW; the
|
||||
// freshly-installed worker then activates and claims the page
|
||||
// (autoUpdate → clientsClaim), firing controllerchange. Reloading on
|
||||
// that first claim caused the fresh-install "loads, then reloads"
|
||||
// jank (worst on kiosk). Only reload when an existing controller is
|
||||
// REPLACED — i.e. a genuine update.
|
||||
let hadController = !!navigator.serviceWorker.controller
|
||||
navigator.serviceWorker.addEventListener('controllerchange', () => {
|
||||
// Service worker updated, reload the page
|
||||
if (!hadController) {
|
||||
hadController = true
|
||||
return
|
||||
}
|
||||
window.location.reload()
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user