From 888479aaf0c1a6c02a05f069f4aeeea4d036a935 Mon Sep 17 00:00:00 2001 From: "Timothy J. Baek" Date: Wed, 25 Sep 2024 20:47:04 +0200 Subject: [PATCH] refac: update toast dismiss behaviour --- src/lib/components/layout/UpdateInfoToast.svelte | 1 + src/routes/(app)/+layout.svelte | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/lib/components/layout/UpdateInfoToast.svelte b/src/lib/components/layout/UpdateInfoToast.svelte index 3b8eb3020..266ed56dd 100644 --- a/src/lib/components/layout/UpdateInfoToast.svelte +++ b/src/lib/components/layout/UpdateInfoToast.svelte @@ -35,6 +35,7 @@ class=" hover:text-blue-900 dark:hover:text-blue-300 transition" on:click={() => { console.log('closeToast'); + localStorage.setItem('dismissedUpdateToast', Date.now().toString()); dispatch('closeToast'); }} > diff --git a/src/routes/(app)/+layout.svelte b/src/routes/(app)/+layout.svelte index a59d0bd53..794e6c383 100644 --- a/src/routes/(app)/+layout.svelte +++ b/src/routes/(app)/+layout.svelte @@ -195,10 +195,20 @@ temporaryChatEnabled.set(true); } + // Check for version updates if ($user.role === 'admin') { - checkForVersionUpdates(); - } + // Check if the user has dismissed the update toast in the last 24 hours + if (localStorage.dismissedUpdateToast) { + const dismissedUpdateToast = new Date(Number(localStorage.dismissedUpdateToast)); + const now = new Date(); + if (now - dismissedUpdateToast > 24 * 60 * 60 * 1000) { + await checkForVersionUpdates(); + } + } else { + await checkForVersionUpdates(); + } + } await tick(); }