From f461c3669c9bb85de2a0efe6388f113553a5d1d1 Mon Sep 17 00:00:00 2001 From: Gronod Date: Thu, 21 May 2026 01:23:30 +0100 Subject: [PATCH] Add client-side handler for history-update SSE events --- client/src/sse.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/client/src/sse.js b/client/src/sse.js index 1b505d9..25b24b0 100644 --- a/client/src/sse.js +++ b/client/src/sse.js @@ -3,6 +3,7 @@ import { state, SSE_RECONNECT_MS } from './state.js'; import { renderDownloads } from './ui/downloads.js'; import { hideError, hideLoading } from './ui/auth.js'; +import { loadHistory } from './ui/history.js'; export function startSSE() { stopSSE(); @@ -33,6 +34,19 @@ export function startSSE() { } }; + // Listen for history-update events from server + source.addEventListener('history-update', (event) => { + try { + const data = JSON.parse(event.data); + console.log('[SSE] History update received:', data.type); + // Trigger history reload + const historyReloadEvent = new CustomEvent('historyReload'); + document.dispatchEvent(historyReloadEvent); + } catch (err) { + console.error('[SSE] Failed to parse history-update message:', err); + } + }); + source.onerror = () => { // EventSource retries automatically; we just log and show a reconnecting indicator console.warn('[SSE] Connection lost, browser will retry...');