Back with sw.js
This commit is contained in:
parent
bd57812964
commit
9e7bfc5468
1 changed files with 4 additions and 8 deletions
|
@ -1,11 +1,10 @@
|
|||
<script lang="ts">
|
||||
import BottomAppBar from '$lib/components/BottomAppBar.svelte';
|
||||
// import Toast from '$lib/components/Toast.svelte';
|
||||
// import { onMount } from 'svelte';
|
||||
import Toast from '$lib/components/Toast.svelte';
|
||||
import { onMount } from 'svelte';
|
||||
|
||||
let node;
|
||||
let node: HTMLElement;
|
||||
|
||||
/**
|
||||
onMount(() => {
|
||||
if(import.meta.env.DEV) return;
|
||||
|
||||
|
@ -17,22 +16,19 @@
|
|||
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');
|
||||
registration?.active?.postMessage('Save client');
|
||||
});
|
||||
}
|
||||
});
|
||||
*/
|
||||
</script>
|
||||
|
||||
<div bind:this={node}></div>
|
||||
|
|
Loading…
Reference in a new issue