Add initlal service-worker with basic offline handling. Manifest is not yet present.
This commit is contained in:
@@ -29,7 +29,7 @@
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
{#if $page.error?.owlCode === 'NETWORK_DISCONNECTED'}
|
||||
{#if page.error?.owlCode === 'NETWORK_DISCONNECTED'}
|
||||
<Button onclick={() => window.location.reload()} color={'accent'}>Retry</Button>
|
||||
{:else}
|
||||
<Button href={'/'} color={'accent'}>Return to Home</Button>
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
import { page } from '$app/state';
|
||||
import { slide, fade } from 'svelte/transition';
|
||||
import { onMount } from 'svelte';
|
||||
import { browser } from '$app/environment';
|
||||
import { navigating } from '$app/state';
|
||||
import { LOCATIONS } from '$lib/locations-object.svelte';
|
||||
import { nearestStationsState } from '$lib/geohash.svelte';
|
||||
|
||||
import Loading from '$lib/components/ui/Loading.svelte';
|
||||
import TimezoneWarning from '$lib/components/ui/TimezoneWarning.svelte';
|
||||
@@ -17,7 +17,19 @@
|
||||
|
||||
import { IconHome, IconDialpad, IconSettings, IconHelp, IconDots } from '@tabler/icons-svelte';
|
||||
|
||||
onMount(() => LOCATIONS.init());
|
||||
onMount(async () => {
|
||||
LOCATIONS.init();
|
||||
if (browser && 'serviceWorker' in navigator) {
|
||||
try {
|
||||
const registration = await navigator.serviceWorker.register('/service-worker.js', {
|
||||
type: 'module',
|
||||
});
|
||||
console.info('OwlBoard Service Worker registered', registration.scope);
|
||||
} catch (error) {
|
||||
console.error('Service Worker installation failed: ', error)
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
let { children } = $props();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user