From d6facc7aba8b1bfeda2d3392b47d61aabbf0a7cf Mon Sep 17 00:00:00 2001 From: Karl Ludwig Weise Date: Wed, 9 Sep 2026 20:10:22 +0200 Subject: [PATCH] Review changes --- .../components/notification-item.svelte | 11 +++++++++-- .../calendar/(components)/AppointmentPreview.svelte | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/lib/components/layouts/sidebar-layout/components/notification-item.svelte b/src/lib/components/layouts/sidebar-layout/components/notification-item.svelte index 0dbdc95..925e7b4 100644 --- a/src/lib/components/layouts/sidebar-layout/components/notification-item.svelte +++ b/src/lib/components/layouts/sidebar-layout/components/notification-item.svelte @@ -52,10 +52,10 @@ } }; - const decryptPayload = async () => { + const decryptPayload = async (retry = true) => { if (item.metaData?.encryptedPayload) { if (!$staffCrypto.isAuthenticated || !$staffCrypto.crypto) { - const maxWaitTime = 5000; // 5 seconds + const maxWaitTime = 5000; const startTime = Date.now(); while (!$staffCrypto.isAuthenticated && Date.now() - startTime < maxWaitTime) { @@ -63,6 +63,13 @@ } if (!$staffCrypto.isAuthenticated || !$staffCrypto.crypto) { + const user = $auth.user; + if (retry && user && user.tenantId) { + console.warn("Staff crypto not initialized, retrying notification item decryption..."); + await staffCrypto.authenticateAndWait(user.id, user.tenantId); + decryptPayload(false); + return; + } console.error("Staff crypto not initialized after waiting"); return; } diff --git a/src/routes/(pages)/dashboard/calendar/(components)/AppointmentPreview.svelte b/src/routes/(pages)/dashboard/calendar/(components)/AppointmentPreview.svelte index 4c58a0d..49e912d 100644 --- a/src/routes/(pages)/dashboard/calendar/(components)/AppointmentPreview.svelte +++ b/src/routes/(pages)/dashboard/calendar/(components)/AppointmentPreview.svelte @@ -60,7 +60,7 @@ // Wait for crypto to be initialized (max 5 seconds) if (!$staffCrypto.isAuthenticated || !$staffCrypto.crypto) { - const maxWaitTime = 2000; + const maxWaitTime = 5000; const startTime = Date.now(); while (!$staffCrypto.isAuthenticated && Date.now() - startTime < maxWaitTime) {