chore: enhance PWA cache invalidation logic
This commit is contained in:
@@ -40,7 +40,11 @@ if ('serviceWorker' in navigator) {
|
||||
}
|
||||
navigator.serviceWorker.addEventListener('controllerchange', triggerReload)
|
||||
const checkForUpdate = () => {
|
||||
navigator.serviceWorker.getRegistration().then((registration) => registration?.update())
|
||||
navigator.serviceWorker.getRegistration().then((registration) => {
|
||||
if (registration) {
|
||||
registration.update()
|
||||
}
|
||||
})
|
||||
}
|
||||
window.addEventListener('visibilitychange', () => {
|
||||
if (document.visibilityState === 'visible') checkForUpdate()
|
||||
|
||||
Reference in New Issue
Block a user