Compare commits
No commits in common. "b2347b04663f600816e142c1199bbd7118a676a9" and "bec8fcdce1d385ba77edaa838f4ddf61c29371b1" have entirely different histories.
b2347b0466
...
bec8fcdce1
2 changed files with 9 additions and 28 deletions
|
@ -11,21 +11,14 @@
|
|||
navigator.serviceWorker.register('/service-worker.js');
|
||||
});
|
||||
|
||||
if (BroadcastChannel) {
|
||||
const channel = new BroadcastChannel('sw-messages');
|
||||
channel.addEventListener('message', (event) => {
|
||||
console.log(event.data);
|
||||
new Toast({ target: node });
|
||||
});
|
||||
} else {
|
||||
navigator.serviceWorker.addEventListener('message', (evt) => {
|
||||
console.log(evt.data);
|
||||
new Toast({ target: node });
|
||||
});
|
||||
}
|
||||
|
||||
navigator.serviceWorker.ready.then((registration) => {
|
||||
registration.active.postMessage('Save client');
|
||||
console.log(registration);
|
||||
console.log('registered service worker');
|
||||
});
|
||||
}
|
||||
});
|
||||
|
|
|
@ -14,12 +14,6 @@ const ASSETS = [
|
|||
...prerendered // dynamic routes
|
||||
];
|
||||
|
||||
let client;
|
||||
|
||||
addEventListener('message', event => {
|
||||
client = event.source;
|
||||
});
|
||||
|
||||
self.addEventListener('install', (event) => {
|
||||
// Create a new cache and add all files to it
|
||||
async function addFilesToCache() {
|
||||
|
@ -30,7 +24,7 @@ self.addEventListener('install', (event) => {
|
|||
event.waitUntil(addFilesToCache());
|
||||
});
|
||||
|
||||
|
||||
const channel = new BroadcastChannel('sw-messages');
|
||||
|
||||
|
||||
self.addEventListener('activate', (event) => {
|
||||
|
@ -42,13 +36,7 @@ self.addEventListener('activate', (event) => {
|
|||
}
|
||||
|
||||
event.waitUntil(deleteOldCaches());
|
||||
let channel;
|
||||
if(BroadcastChannel) {
|
||||
channel = new BroadcastChannel('sw-messages');
|
||||
channel.postMessage({title: 'Cache Downloaded'});
|
||||
} else {
|
||||
client.postMessage("Cache Downloaded")
|
||||
}
|
||||
channel.postMessage({title: 'Cache downloaded!'});
|
||||
});
|
||||
|
||||
self.addEventListener('fetch', (event) => {
|
||||
|
|
Loading…
Reference in a new issue