feat: implement PWA update prompt and manual reload

This commit is contained in:
2026-02-10 21:16:28 +01:00
parent 7a74eaff8b
commit 631628a554
5 changed files with 122 additions and 23 deletions

View File

@@ -31,23 +31,3 @@ app.directive('cell-hover', vCellHover)
app.mount('#app')
if ('serviceWorker' in navigator) {
let refreshing = false
const triggerReload = () => {
if (refreshing) return
refreshing = true
window.location.reload()
}
navigator.serviceWorker.addEventListener('controllerchange', triggerReload)
const checkForUpdate = () => {
navigator.serviceWorker.getRegistration().then((registration) => {
if (registration) {
registration.update()
}
})
}
window.addEventListener('visibilitychange', () => {
if (document.visibilityState === 'visible') checkForUpdate()
})
window.addEventListener('focus', checkForUpdate)
}