From e2b3df0508751d982c76752435390e958eb73b13 Mon Sep 17 00:00:00 2001
From: Matt Strapp <matt@mattstrapp.net>
Date: Sat, 20 Jan 2024 11:27:31 -0600
Subject: Migrate repos

Signed-off-by: Matt Strapp <matt@mattstrapp.net>
---
 clients/www/src/lib/components/ReloadPrompt.svelte | 32 ++++++++++++++++++++++
 1 file changed, 32 insertions(+)
 create mode 100644 clients/www/src/lib/components/ReloadPrompt.svelte

(limited to 'clients/www/src/lib/components/ReloadPrompt.svelte')

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>
-- 
cgit v1.2.3

