From b30607df3f4d3bf21aaa74e885a3510ab0e98464 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=BB=D0=B5=D0=BA=D1=81=D0=B5=D0=B9=20=D0=A1=D0=B0?= =?UTF-8?q?=D0=B1=D0=B8=D0=BB=D0=B8=D0=BD?= Date: Mon, 13 Jul 2026 17:18:22 +0300 Subject: [PATCH] =?UTF-8?q?fix(ws):=20=D0=BD=D0=B5=20=D0=BF=D0=BE=D0=BA?= =?UTF-8?q?=D0=B0=D0=B7=D1=8B=D0=B2=D0=B0=D1=82=D1=8C=20replay-=D1=83?= =?UTF-8?q?=D0=B2=D0=B5=D0=B4=D0=BE=D0=BC=D0=BB=D0=B5=D0=BD=D0=B8=D1=8F=20?= =?UTF-8?q?=D0=BF=D1=80=D0=B8=20=D0=BF=D0=BE=D0=B4=D0=BA=D0=BB=D1=8E=D1=87?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Refs EventHub/EventHubFrontAdmin#9 Co-authored-by: Cursor --- src/hooks/useAdminWebSocket.ts | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/hooks/useAdminWebSocket.ts b/src/hooks/useAdminWebSocket.ts index c11ec7e..3f6ac7e 100644 --- a/src/hooks/useAdminWebSocket.ts +++ b/src/hooks/useAdminWebSocket.ts @@ -67,6 +67,7 @@ export const useAdminWebSocket = () => { shouldReconnectRef.current = true; let isMounted = true; + const sessionStartSecondsRef = { current: 0 }; const connect = () => { if (!isMounted || !shouldReconnectRef.current) return; @@ -82,6 +83,7 @@ export const useAdminWebSocket = () => { ws.onopen = () => { if (!isMounted || !shouldReconnectRef.current) return; + sessionStartSecondsRef.current = Math.floor(Date.now() / 1000); wsLog('[WS] Connected'); if (canAccessRoute('/reports', role)) { ws.send(JSON.stringify({ action: 'subscribe', channel: 'reports' })); @@ -115,9 +117,14 @@ export const useAdminWebSocket = () => { return; } - window.dispatchEvent( - new CustomEvent('admin-ws-message', { detail: msg }) - ); + const isLiveEvent = + !msg.timestamp || msg.timestamp >= sessionStartSecondsRef.current; + + if (isLiveEvent) { + window.dispatchEvent( + new CustomEvent('admin-ws-message', { detail: msg }) + ); + } if (msg.type === 'report_created') { queryClient.invalidateQueries({ queryKey: ['reports'] });