mirror of
https://github.com/chinchang/web-maker.git
synced 2025-08-02 19:37:29 +02:00
preview/service-worker: remove useless code
This commit is contained in:
@@ -8,10 +8,6 @@ Hello
|
|||||||
// precaching requests don't degrade the first visit experience.
|
// precaching requests don't degrade the first visit experience.
|
||||||
// See https://developers.google.com/web/fundamentals/instant-and-offline/service-worker/registration
|
// See https://developers.google.com/web/fundamentals/instant-and-offline/service-worker/registration
|
||||||
window.addEventListener('load', function () {
|
window.addEventListener('load', function () {
|
||||||
// Your service-worker.js *must* be located at the top-level directory relative to your site.
|
|
||||||
// It won't be able to control pages unless it's located at the same level or higher than them.
|
|
||||||
// *Don't* register service worker file in, e.g., a scripts/ sub-directory!
|
|
||||||
// See https://github.com/slightlyoff/ServiceWorker/issues/468
|
|
||||||
navigator.serviceWorker
|
navigator.serviceWorker
|
||||||
.register('service-worker.js')
|
.register('service-worker.js')
|
||||||
.then(function (reg) {
|
.then(function (reg) {
|
||||||
@@ -25,23 +21,7 @@ Hello
|
|||||||
/* eslint-disable default-case */
|
/* eslint-disable default-case */
|
||||||
switch (installingWorker.state) {
|
switch (installingWorker.state) {
|
||||||
case 'installed':
|
case 'installed':
|
||||||
if (navigator.serviceWorker.controller) {
|
console.log('New or updated content is available.');
|
||||||
// At this point, the old content will have been purged and the fresh content will
|
|
||||||
// have been added to the cache.
|
|
||||||
// It's the perfect time to display a "New content is available; please refresh."
|
|
||||||
// message in the page's interface.
|
|
||||||
console.log('New or updated content is available.');
|
|
||||||
|
|
||||||
} else {
|
|
||||||
// At this point, everything has been precached.
|
|
||||||
// It's the perfect time to display a "Content is cached for offline use." message.
|
|
||||||
console.log('Content is now available offline!');
|
|
||||||
if (window.alertsService) {
|
|
||||||
window.alertsService.add(
|
|
||||||
'Web Maker is now ready to be used offline.'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'redundant':
|
case 'redundant':
|
||||||
|
Reference in New Issue
Block a user