aboutsummaryrefslogtreecommitdiffstats
path: root/clients/www/src/lib/components
diff options
context:
space:
mode:
Diffstat (limited to 'clients/www/src/lib/components')
-rw-r--r--clients/www/src/lib/components/ReloadPrompt.svelte32
1 files changed, 32 insertions, 0 deletions
diff --git a/clients/www/src/lib/components/ReloadPrompt.svelte b/clients/www/src/lib/components/ReloadPrompt.svelte
new file mode 100644
index 0000000..e6effbb
--- /dev/null
+++ b/clients/www/src/lib/components/ReloadPrompt.svelte
@@ -0,0 +1,32 @@
+<script lang="ts">
+ import { getToastStore } from '@skeletonlabs/skeleton'
+ import { useRegisterSW } from 'virtual:pwa-register/svelte'
+
+ const toastStore = getToastStore()
+
+ const { updateServiceWorker } = useRegisterSW({
+ onRegisteredSW(r) {
+ console.log('SW Registered: ', r)
+ },
+ onNeedRefresh() {
+ toastStore.trigger({
+ message: 'A new version of the application is available.',
+ autohide: false,
+ action: {
+ label: 'Refresh',
+ response: updateServiceWorker,
+ },
+ })
+ },
+ onOfflineReady() {
+ toastStore.trigger({
+ background: 'variant-filled-success',
+ message: 'Now ready for offline use!',
+ timeout: 5000,
+ })
+ },
+ onRegisterError(err) {
+ console.error('SW Registration Error: ', err)
+ },
+ })
+</script>