aboutsummaryrefslogtreecommitdiffstats
path: root/app/src/lib
diff options
context:
space:
mode:
authorMatt Strapp <matt@mattstrapp.net>2023-09-29 09:05:42 -0500
committerMatt Strapp <matt@mattstrapp.net>2023-09-29 09:05:42 -0500
commitc8b8dd263e331245356b8b32e6a8396f27b478d1 (patch)
tree6a7cd29f31d584f810a66a8d0c5d4ba612ba03eb /app/src/lib
parentFix centering of content (diff)
downloadtrinkets-c8b8dd263e331245356b8b32e6a8396f27b478d1.tar
trinkets-c8b8dd263e331245356b8b32e6a8396f27b478d1.tar.gz
trinkets-c8b8dd263e331245356b8b32e6a8396f27b478d1.tar.bz2
trinkets-c8b8dd263e331245356b8b32e6a8396f27b478d1.tar.lz
trinkets-c8b8dd263e331245356b8b32e6a8396f27b478d1.tar.xz
trinkets-c8b8dd263e331245356b8b32e6a8396f27b478d1.tar.zst
trinkets-c8b8dd263e331245356b8b32e6a8396f27b478d1.zip
Add a reload prompt instead of an auto-update
Signed-off-by: Matt Strapp <matt@mattstrapp.net>
Diffstat (limited to '')
-rw-r--r--app/src/lib/svelte/ReloadPrompt.svelte34
1 files changed, 34 insertions, 0 deletions
diff --git a/app/src/lib/svelte/ReloadPrompt.svelte b/app/src/lib/svelte/ReloadPrompt.svelte
new file mode 100644
index 0000000..1d5dbf6
--- /dev/null
+++ b/app/src/lib/svelte/ReloadPrompt.svelte
@@ -0,0 +1,34 @@
+<script lang="ts">
+ import { getToastStore, Toast } 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> \ No newline at end of file