feat: use sveltekit pwa

This commit is contained in:
Xyphyn committed 2023-08-02 18:38:55 -07:00
1 parent fd29a7d1f8
commit 1ee2918031
10 files changed
+2362 -131

No files matched your search

+21
View File
@@ -7,6 +7,9 @@
import ToastContainer from '$lib/components/ui/toasts/ToastContainer.svelte'
import Moderation from '$lib/components/lemmy/moderation/Moderation.svelte'
import Sidebar from '$lib/components/ui/Sidebar.svelte'
import { onMount } from 'svelte'
// @ts-ignore
import { pwaInfo } from 'virtual:pwa-info'
nProgress.configure({
minimum: 0.4,
@@ -28,6 +31,24 @@
}
}
}
onMount(async () => {
if (pwaInfo) {
const { registerSW } = await import('virtual:pwa-register')
registerSW({
immediate: true,
onRegistered(r) {
console.log(`SW Registered: ${r}`)
r?.update()
},
onRegisterError(error) {
console.log('SW registration error', error)
},
})
}
})
$: webManifest = pwaInfo ? pwaInfo.webManifest.linkTag : ''
</script>
<div class="flex flex-col min-h-screen">