in src/registerServiceWorker.tsx [126:160]
function checkValidServiceWorker (swUrl: string, toasterSupplier: () => (Toaster | null)) {
// Check if the service worker can be found. If it can't reload the page.
fetch(swUrl)
.then((response) => {
// Ensure service worker exists, and that we really are getting a JS file.
if (
response.status === 404 ||
(response.headers.get('content-type') || '').indexOf('javascript') === -1
) {
// No service worker found. Probably a different app. Reload the page.
navigator.serviceWorker.ready.then((registration) => {
return registration.unregister().then(() => {
window.location.reload()
})
}).catch(() => {/* do nothing */})
} else {
// Service worker found. Proceed as normal.
registerValidSW(swUrl, toasterSupplier)
}
})
.catch(() => {
const toaster = toasterSupplier()
if (toaster) {
toaster.show({
icon: 'offline',
intent: Intent.PRIMARY,
message: (
<React.Fragment>
No internet connection found. The page is running in offline mode.
</React.Fragment>
)
})
}
})
}