From 5793afc70971ad7e7aedfc7e1f3af0899b2ae9c4 Mon Sep 17 00:00:00 2001 From: Madhura68 Date: Tue, 5 May 2026 13:44:15 +0200 Subject: [PATCH] fix(m12): IdeaTimeline auto-refresh on new idea-questions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The /ideas/[id]?tab=timeline page is server-rendered: questions are a prop snapshot. Without a router.refresh, new questions only show after a manual page reload — and during a grill-session that's every ~20s. Fix: in use-notifications-realtime, after dispatching idea-question events to idea-store + re-syncing the bell, call \`router.refresh()\`. This re-runs the server-component for whichever page the user is on; on /ideas/[id] it pulls the new question. On other pages it's a no-op (no visible state change). Co-Authored-By: Claude Opus 4.7 (1M context) --- lib/realtime/use-notifications-realtime.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/realtime/use-notifications-realtime.ts b/lib/realtime/use-notifications-realtime.ts index 8bd3b00..b773861 100644 --- a/lib/realtime/use-notifications-realtime.ts +++ b/lib/realtime/use-notifications-realtime.ts @@ -11,6 +11,7 @@ 'use client' import { useEffect, useRef } from 'react' +import { useRouter } from 'next/navigation' import { useNotificationsStore, type NotificationQuestion } from '@/stores/notifications-store' import { useIdeaStore } from '@/stores/idea-store' @@ -66,6 +67,7 @@ export function useNotificationsRealtime() { const sourceRef = useRef(null) const backoffRef = useRef(BACKOFF_START_MS) const reconnectTimerRef = useRef | null>(null) + const router = useRouter() useEffect(() => { const init = useNotificationsStore.getState().init @@ -146,6 +148,11 @@ export function useNotificationsRealtime() { } else { remove(payload.id) } + // M12 hotfix: refresh de current page (server-component) zodat de + // IdeaTimeline-tab op /ideas/[id] de nieuwe vraag oppikt zonder + // dat de gebruiker handmatig moet refreshen. Geen-op als de + // gebruiker elders zit; goedkoop genoeg om altijd te triggeren. + router.refresh() return }