|
|
@@ -41,6 +41,7 @@ export function register(config) { |
|
|
|
// Add some additional logging to localhost, pointing developers to the |
|
|
|
// service worker/PWA documentation. |
|
|
|
navigator.serviceWorker.ready.then(() => { |
|
|
|
// eslint-disable-next-line no-console |
|
|
|
console.log( |
|
|
|
"This web app is being served cache-first by a service " + |
|
|
|
"worker. To learn more, visit https://bit.ly/CRA-PWA" |
|
|
@@ -60,7 +61,7 @@ function registerValidSW(swUrl, config) { |
|
|
|
.then(registration => { |
|
|
|
registration.onupdatefound = () => { |
|
|
|
const installingWorker = registration.installing; |
|
|
|
if (installingWorker == null) { |
|
|
|
if (installingWorker === null) { |
|
|
|
return; |
|
|
|
} |
|
|
|
installingWorker.onstatechange = () => { |
|
|
@@ -69,6 +70,7 @@ function registerValidSW(swUrl, config) { |
|
|
|
// At this point, the updated precached content has been fetched, |
|
|
|
// but the previous service worker will still serve the older |
|
|
|
// content until all client tabs are closed. |
|
|
|
// eslint-disable-next-line no-console |
|
|
|
console.log( |
|
|
|
"New content is available and will be used when all " + |
|
|
|
"tabs for this page are closed. See https://bit.ly/CRA-PWA." |
|
|
@@ -82,6 +84,7 @@ function registerValidSW(swUrl, config) { |
|
|
|
// At this point, everything has been precached. |
|
|
|
// It's the perfect time to display a |
|
|
|
// "Content is cached for offline use." message. |
|
|
|
// eslint-disable-next-line no-console |
|
|
|
console.log("Content is cached for offline use."); |
|
|
|
|
|
|
|
// Execute callback |
|
|
@@ -94,6 +97,7 @@ function registerValidSW(swUrl, config) { |
|
|
|
}; |
|
|
|
}) |
|
|
|
.catch(error => { |
|
|
|
// eslint-disable-next-line no-console |
|
|
|
console.error("Error during service worker registration:", error); |
|
|
|
}); |
|
|
|
} |
|
|
@@ -106,7 +110,7 @@ function checkValidServiceWorker(swUrl, config) { |
|
|
|
const contentType = response.headers.get("content-type"); |
|
|
|
if ( |
|
|
|
response.status === 404 || |
|
|
|
(contentType != null && contentType.indexOf("javascript") === -1) |
|
|
|
(contentType !== null && contentType.indexOf("javascript") === -1) |
|
|
|
) { |
|
|
|
// No service worker found. Probably a different app. Reload the page. |
|
|
|
navigator.serviceWorker.ready.then(registration => { |
|
|
@@ -120,6 +124,7 @@ function checkValidServiceWorker(swUrl, config) { |
|
|
|
} |
|
|
|
}) |
|
|
|
.catch(() => { |
|
|
|
// eslint-disable-next-line no-console |
|
|
|
console.log( |
|
|
|
"No internet connection found. App is running in offline mode." |
|
|
|
); |
|
|
|