fix(ws): не показывать replay-уведомления при подключении

Refs EventHub/EventHubFrontAdmin#9

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-07-13 17:18:22 +03:00
parent 9ff894988f
commit b30607df3f
+7
View File
@@ -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;
}
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'] });