overleaf/services/web/frontend/js/utils/service-worker-cleanup.js
Jakob Ackermann f11e1a83cd Merge pull request #8776 from overleaf/jpa-drop-service-worker
[web] goodbye service worker

GitOrigin-RevId: ce85d4850faba15c5877ce1f3e78026de30c6eae
2022-07-11 08:03:57 +00:00

17 lines
442 B
JavaScript

export function cleanupServiceWorker() {
try {
navigator.serviceWorker
.getRegistrations()
.catch(() => {
// fail silently if permission not given (e.g. SecurityError)
return []
})
.then(registrations => {
registrations.forEach(worker => {
worker.unregister()
})
})
} catch (e) {
// fail silently if service worker are not available (on the navigator)
}
}