From 2114375e9b16bc60dc6da9675a0625185cdb58cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Fri, 24 Jul 2026 05:05:59 +0300 Subject: [PATCH] =?UTF-8?q?fix:=20=F0=9F=90=9B=20stop=20shell=20notifiers?= =?UTF-8?q?=20from=20blanking=20the=20whole=20page=20on=20refetch=20-=20No?= =?UTF-8?q?tificationCenter=20and=20RightNav=20sit=20beside=20=20i?= =?UTF-8?q?n=20AppShell=20and=20feed=20=20=20always-rendered=20unread/toda?= =?UTF-8?q?y=20badges=20from=20createResource=20reads=20-=20those=20badges?= =?UTF-8?q?=20read=20the=20resources=20OUTSIDE=20any=20,=20so=20?= =?UTF-8?q?a=20bare=20resource()=20=20=20re-suspends=20on=20every=2060s=20?= =?UTF-8?q?refreshAll()=20refetch=20(initialValue=20does=20not=20prevent?= =?UTF-8?q?=20=20=20this)=20and=20blanks=20the=20entire=20page=20for=20the?= =?UTF-8?q?=20whole=20fetch=20duration=20=E2=80=94=20a=20visible=20=20=20m?= =?UTF-8?q?ulti-second=20reload/blank=20on=20a=20real=20backend,=20recurri?= =?UTF-8?q?ng=20on=20the=20clock=20tick,=20=20=20panel=20opens,=20and=20HM?= =?UTF-8?q?R=20remounts=20-=20read=20resource.latest=20in=20the=20badge=20?= =?UTF-8?q?computeds:=20returns=20the=20last=20value=20without=20=20=20tri?= =?UTF-8?q?ggering=20Suspense,=20so=20refetch=20no=20longer=20suspends=20t?= =?UTF-8?q?he=20page=20-=20seed=20NotificationCenter's=20four=20resources?= =?UTF-8?q?=20with=20initialValue=20to=20match=20RightNav?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/layout/notification-center.tsx | 24 ++++++++++++------- src/components/layout/right-nav.tsx | 10 +++++--- 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/src/components/layout/notification-center.tsx b/src/components/layout/notification-center.tsx index 30c2034..4678a83 100644 --- a/src/components/layout/notification-center.tsx +++ b/src/components/layout/notification-center.tsx @@ -31,7 +31,12 @@ export function NotificationCenter() { const [open, setOpen] = createSignal(false); const [dismissedIds, setDismissedIds] = createSignal>(getDismissedNotificationIds()); - // Fetch data sources + // Fetch data sources. `initialValue` is required: the unread badge reads + // these via `unreadCount()` OUTSIDE the popover's , so a bare + // `resource()` would re-suspend on every 60s `refreshAll()` refetch and — since + // this component sits beside in AppShell — blank the whole page for + // the fetch duration. A seeded value keeps `resource()` non-suspending on + // refetch (matches RightNav). const [messagesRes, { refetch: refetchMessages }] = createResource( async () => { try { @@ -39,7 +44,8 @@ export function NotificationCenter() { } catch { return { items: [], total: 0 }; } - } + }, + { initialValue: { items: [], total: 0 } } ); const [eventsRes, { refetch: refetchEvents }] = createResource(async () => { @@ -48,7 +54,7 @@ export function NotificationCenter() { } catch { return { items: [], total: 0 }; } - }); + }, { initialValue: { items: [], total: 0 } }); const [examsRes, { refetch: refetchExams }] = createResource(async () => { try { @@ -56,7 +62,7 @@ export function NotificationCenter() { } catch { return { items: [], total: 0 }; } - }); + }, { initialValue: { items: [], total: 0 } }); const [homeworkRes, { refetch: refetchHomework }] = createResource(async () => { try { @@ -64,7 +70,7 @@ export function NotificationCenter() { } catch { return { items: [], total: 0 }; } - }); + }, { initialValue: { items: [], total: 0 } }); // Revalidate every source so an item deleted on another page stops // notifying: on the periodic clock tick (badge self-heals) and whenever @@ -96,7 +102,7 @@ export function NotificationCenter() { const list: NotificationItem[] = []; // 1. Unread Messages - const msgs = messagesRes()?.items ?? []; + const msgs = messagesRes.latest?.items ?? []; for (const m of msgs) { list.push({ id: `msg_${m.id}`, @@ -109,7 +115,7 @@ export function NotificationCenter() { } // 2. Events starting today or upcoming - const evts = eventsRes()?.items ?? []; + const evts = eventsRes.latest?.items ?? []; for (const e of evts) { if (!e.starts_at) continue; const t = new Date(e.starts_at).getTime(); @@ -133,7 +139,7 @@ export function NotificationCenter() { } // 3. Exams starting today or upcoming - const exms = examsRes()?.items ?? []; + const exms = examsRes.latest?.items ?? []; for (const ex of exms) { if (!ex.starts_at || ex.draft) continue; const t = new Date(ex.starts_at).getTime(); @@ -157,7 +163,7 @@ export function NotificationCenter() { } // 4. Homework due upcoming - const hws = homeworkRes()?.items ?? []; + const hws = homeworkRes.latest?.items ?? []; for (const hw of hws) { if (!hw.due_at) continue; if (hw.due_at >= nowMs()) { diff --git a/src/components/layout/right-nav.tsx b/src/components/layout/right-nav.tsx index 7e11c2c..a0f093b 100644 --- a/src/components/layout/right-nav.tsx +++ b/src/components/layout/right-nav.tsx @@ -91,7 +91,11 @@ export function RightNav() { }; // Computed message data - const allMessages = () => messagesRes().items; + // `.latest`, not `messagesRes()`: this feeds the always-rendered unread badge, + // which is outside any . A bare read re-suspends on every 60s refetch + // and — since RightNav sits beside in AppShell — blanks the whole page + // for the fetch duration. `.latest` keeps the last value without suspending. + const allMessages = () => messagesRes.latest.items; const unreadCount = createMemo(() => allMessages().filter((m: Message) => !m.read).length); const filteredMessages = createMemo(() => { @@ -127,11 +131,11 @@ export function RightNav() { }; const activeEvents = createMemo(() => { - return eventsRes().filter((e: Event) => notEnded(e.starts_at, e.ends_at)); + return eventsRes.latest.filter((e: Event) => notEnded(e.starts_at, e.ends_at)); }); const activeExams = createMemo(() => { - return examsRes().filter((e: Exam) => !e.draft && notEnded(e.starts_at, e.ends_at)); + return examsRes.latest.filter((e: Exam) => !e.draft && notEnded(e.starts_at, e.ends_at)); }); const hasTodayEvents = createMemo(() => activeEvents().length > 0);