From af901c094e132b574aa135bfb6c522c6865910ce Mon Sep 17 00:00:00 2001 From: Kalle <38327916+Sendouc@users.noreply.github.com> Date: Sun, 16 Aug 2026 17:42:29 +0300 Subject: [PATCH] Fix effect infinite loop --- .../src/lib/components/layout/Layout.svelte | 21 +++++++------------ packages/components/src/Select.svelte | 18 ++++++---------- 2 files changed, 14 insertions(+), 25 deletions(-) diff --git a/apps/web/src/lib/components/layout/Layout.svelte b/apps/web/src/lib/components/layout/Layout.svelte index b0e2d11a5..4f03c6058 100644 --- a/apps/web/src/lib/components/layout/Layout.svelte +++ b/apps/web/src/lib/components/layout/Layout.svelte @@ -51,25 +51,20 @@ let sideNavCollapsed = $state(initialCollapsed); let sideNavModalOpen = $state(false); let hydrated = $state(false); -let notifications = $state(null); - $effect(() => { hydrated = true; }); // the bell data loads lazily like the React app's NotificationsProvider: // after hydration, never blocking SSR -$effect(() => { - if (!user) { - notifications = null; - return; - } - void getNotifications().then((result) => { - notifications = result.notifications - ? toNotificationRows(result.notifications) - : null; - }); -}); +const notificationsQuery = $derived( + hydrated && user ? getNotifications() : null, +); +const notifications = $derived( + notificationsQuery?.current?.notifications + ? toNotificationRows(notificationsQuery.current.notifications) + : null, +); const unseenIds = $derived( notifications diff --git a/packages/components/src/Select.svelte b/packages/components/src/Select.svelte index ec2461276..368046ced 100644 --- a/packages/components/src/Select.svelte +++ b/packages/components/src/Select.svelte @@ -1,5 +1,6 @@