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">
|
<script lang="ts">
|
||||||
import BottomAppBar from '$lib/components/BottomAppBar.svelte';
|
import BottomAppBar from '$lib/components/BottomAppBar.svelte';
|
||||||
// import Toast from '$lib/components/Toast.svelte';
|
import Toast from '$lib/components/Toast.svelte';
|
||||||
// import { onMount } from 'svelte';
|
import { onMount } from 'svelte';
|
||||||
|
|
||||||
let node;
|
let node: HTMLElement;
|
||||||
|
|
||||||
/**
|
|
||||||
onMount(() => {
|
onMount(() => {
|
||||||
if(import.meta.env.DEV) return;
|
if(import.meta.env.DEV) return;
|
||||||
|
|
||||||
|
@ -17,22 +16,19 @@
|
||||||
if (BroadcastChannel) {
|
if (BroadcastChannel) {
|
||||||
const channel = new BroadcastChannel('sw-messages');
|
const channel = new BroadcastChannel('sw-messages');
|
||||||
channel.addEventListener('message', (event) => {
|
channel.addEventListener('message', (event) => {
|
||||||
console.log(event.data);
|
|
||||||
new Toast({ target: node });
|
new Toast({ target: node });
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
navigator.serviceWorker.addEventListener('message', (evt) => {
|
navigator.serviceWorker.addEventListener('message', (evt) => {
|
||||||
console.log(evt.data);
|
|
||||||
new Toast({ target: node });
|
new Toast({ target: node });
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
navigator.serviceWorker.ready.then((registration) => {
|
navigator.serviceWorker.ready.then((registration) => {
|
||||||
registration.active.postMessage('Save client');
|
registration?.active?.postMessage('Save client');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
*/
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div bind:this={node}></div>
|
<div bind:this={node}></div>
|
||||||
|
|
Loading…
Reference in a new issue