fix(pwa): defer update reloads until the intro cinematic finishes
All checks were successful
Demo images / Build & push demo images (push) Successful in 3m23s

A genuine service-worker update still reloaded the page the instant the
new worker claimed it. The kiosk and the public demo replay the intro on
every boot/visit, so an update landing mid-sequence restarted the whole
cinematic — the "typing intro resets to the start after several seconds"
report. Hold the reload until the splash is complete and the
dashboard-reveal cinematic is over, then apply it.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
archipelago 2026-07-16 16:48:56 -04:00
parent 92d221bbf1
commit 547f674ac8

View File

@ -25,10 +25,33 @@
<script setup lang="ts">
import { ref, onMounted } from 'vue'
import BaseModal from '@/components/BaseModal.vue'
import { useLoginTransitionStore } from '@/stores/loginTransition'
const showUpdatePrompt = ref(false)
let updateCallback: (() => Promise<void>) | null = null
// Reload for a genuine SW update but never mid-cinematic. The splash
// typing intro and the dashboard-reveal cinematic are the two moments a
// surprise reload reads as "the app just reset itself" (kiosk and demo
// replay the intro on every boot/visit, so an update landing during it
// restarted the whole sequence). Wait until both are over, then reload.
function reloadAfterCinematic() {
const loginTransition = useLoginTransitionStore()
const calm = () =>
document.body.classList.contains('splash-complete') &&
!loginTransition.introCinematicPlaying
if (calm()) {
window.location.reload()
return
}
const poll = setInterval(() => {
if (calm()) {
clearInterval(poll)
window.location.reload()
}
}, 1000)
}
onMounted(() => {
// Listen for service worker updates
if ('serviceWorker' in navigator) {
@ -44,7 +67,7 @@ onMounted(() => {
hadController = true
return
}
window.location.reload()
reloadAfterCinematic()
})
// Check for updates periodically