aggiornamento
This commit is contained in:
@@ -1,5 +1,3 @@
|
||||
importScripts('https://storage.googleapis.com/workbox-cdn/releases/6.5.4/workbox-sw.js');
|
||||
|
||||
import { cleanupOutdatedCaches, precacheAndRoute } from 'workbox-precaching';
|
||||
import { registerRoute } from 'workbox-routing';
|
||||
import { clientsClaim, setCacheNameDetails, skipWaiting } from 'workbox-core';
|
||||
@@ -16,32 +14,16 @@ import { ExpirationPlugin } from 'workbox-expiration';
|
||||
|
||||
const isIOS = /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream;
|
||||
|
||||
|
||||
self.addEventListener('install', () => self.skipWaiting());
|
||||
self.addEventListener('activate', (event) => {
|
||||
// console.log('CLAIM');
|
||||
//event.waitUntil(self.clients.claim())
|
||||
|
||||
event.waitUntil(async () => {
|
||||
// Check for a new service worker version
|
||||
const registration = await navigator.serviceWorker.getRegistration();
|
||||
if (registration && registration.waiting) {
|
||||
// A new service worker is waiting, trigger a page reload
|
||||
await registration.waiting.postMessage({ type: 'SKIP_WAITING' });
|
||||
self.skipWaiting();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
const VersioneApp = '1.0.42';
|
||||
self.addEventListener('activate', (event) => event.waitUntil(self.clients.claim()));
|
||||
|
||||
const VersioneApp = '1.0.46';
|
||||
|
||||
console.log(' [ VER-' + VersioneApp + ' ] _---------________------ PAO: this is my custom service worker');
|
||||
|
||||
importScripts('js/idb.js', 'js/storage.js');
|
||||
importScripts('js/idb.js', 'js/storage.js', 'js/workbox-sw.js');
|
||||
|
||||
let port = self.location.hostname.startsWith('test') ? 3001 : 3000;
|
||||
console.log('SW- app ver ' + VersioneApp + ' on port ' + port);
|
||||
|
||||
// Function helpers
|
||||
async function writeData(table, data) {
|
||||
@@ -153,7 +135,7 @@ if (workbox) {
|
||||
const syncStore = {};
|
||||
self.addEventListener('message', event => {
|
||||
if (event.data && (event.data.type === 'SKIP_WAITING' || event.data.action === 'skipWaiting')) {
|
||||
window.location.reload();
|
||||
self.skipWaiting();
|
||||
}
|
||||
if (event.data.type === 'sync') {
|
||||
console.log('addEventListener - message');
|
||||
|
||||
Reference in New Issue
Block a user