update sw.ts and toast component

This commit is contained in:
Alessio Davoli 2023-07-22 19:57:47 +02:00
parent 0a2f580f30
commit 7d8f59dec7
2 changed files with 10 additions and 9 deletions

View file

@ -5,17 +5,15 @@
let nodeRef; let nodeRef;
onMount(() => { onMount(() => {
show = true;
setTimeout(() => { setTimeout(() => {
show = false; show = true;
setTimeout(() => { setTimeout(() => {
nodeRef.parentNode.removeChild(nodeRef); show = false;
setTimeout(() => {
nodeRef.parentNode.removeChild(nodeRef);
}, 5000);
}, 5000); }, 5000);
}, 5000); }, 0);
});
onDestroy(() => {
show = false;
}); });
</script> </script>

View file

@ -24,6 +24,9 @@ self.addEventListener('install', (event) => {
event.waitUntil(addFilesToCache()); event.waitUntil(addFilesToCache());
}); });
const channel = new BroadcastChannel('sw-messages');
self.addEventListener('activate', (event) => { self.addEventListener('activate', (event) => {
// Remove previous cached data from disk // Remove previous cached data from disk
async function deleteOldCaches() { async function deleteOldCaches() {
@ -33,7 +36,7 @@ self.addEventListener('activate', (event) => {
} }
event.waitUntil(deleteOldCaches()); event.waitUntil(deleteOldCaches());
postMessage("completed"); channel.postMessage({title: 'Cache downloaded!'});
}); });
self.addEventListener('fetch', (event) => { self.addEventListener('fetch', (event) => {