Explorar o código

refac: update toast dismiss behaviour

Timothy J. Baek hai 7 meses
pai
achega
888479aaf0

+ 1 - 0
src/lib/components/layout/UpdateInfoToast.svelte

@@ -35,6 +35,7 @@
 			class=" hover:text-blue-900 dark:hover:text-blue-300 transition"
 			class=" hover:text-blue-900 dark:hover:text-blue-300 transition"
 			on:click={() => {
 			on:click={() => {
 				console.log('closeToast');
 				console.log('closeToast');
+				localStorage.setItem('dismissedUpdateToast', Date.now().toString());
 				dispatch('closeToast');
 				dispatch('closeToast');
 			}}
 			}}
 		>
 		>

+ 12 - 2
src/routes/(app)/+layout.svelte

@@ -195,10 +195,20 @@
 				temporaryChatEnabled.set(true);
 				temporaryChatEnabled.set(true);
 			}
 			}
 
 
+			// Check for version updates
 			if ($user.role === 'admin') {
 			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();
 			await tick();
 		}
 		}