From 10f8e1ec06bf9460b7f1e4d295a003ed73df24b5 Mon Sep 17 00:00:00 2001 From: Epid Date: Thu, 2 Apr 2026 08:05:00 +0300 Subject: [PATCH] chore(stopwatch): remove dead no-event-source code paths The shared worker no longer emits 'no-event-source' messages since the EventSource transport was removed. Clean up the unreachable branches in both notification.ts and stopwatch.ts. Co-Authored-By: Claude Sonnet 4.6 --- web_src/js/features/notification.ts | 6 +----- web_src/js/features/stopwatch.ts | 11 +++-------- 2 files changed, 4 insertions(+), 13 deletions(-) diff --git a/web_src/js/features/notification.ts b/web_src/js/features/notification.ts index acb1b68f28..8483a28299 100644 --- a/web_src/js/features/notification.ts +++ b/web_src/js/features/notification.ts @@ -21,10 +21,8 @@ async function receiveUpdateCount(event: MessageEvent<{type: string, data: strin export function initNotificationCount() { if (!document.querySelector('.notification_count')) return; - let usingPeriodicPoller = false; const startPeriodicPoller = (timeout: number, lastCount?: number) => { if (timeout <= 0 || !Number.isFinite(timeout)) return; - usingPeriodicPoller = true; lastCount = lastCount ?? getCurrentCount(); setTimeout(async () => { await updateNotificationCountWithCallback(startPeriodicPoller, timeout, lastCount); @@ -35,9 +33,7 @@ export function initNotificationCount() { // Try to connect to the event source via the shared worker first const worker = new UserEventsSharedWorker('notification-worker'); worker.addMessageEventListener((event: MessageEvent) => { - if (event.data.type === 'no-event-source') { - if (!usingPeriodicPoller) startPeriodicPoller(notificationSettings.MinTimeout); - } else if (event.data.type === 'notification-count') { + if (event.data.type === 'notification-count') { receiveUpdateCount(event); // no await } }); diff --git a/web_src/js/features/stopwatch.ts b/web_src/js/features/stopwatch.ts index fb878e4bba..c5d68c5595 100644 --- a/web_src/js/features/stopwatch.ts +++ b/web_src/js/features/stopwatch.ts @@ -60,8 +60,8 @@ export function initStopwatch() { const url = btn.getAttribute('data-url'); if (!url) return; - const startGroup = document.querySelector('.issue-start-buttons'); - const stopGroup = document.querySelector('.issue-stop-cancel-buttons'); + const startGroup = document.querySelector('.issue-start-buttons')!; + const stopGroup = document.querySelector('.issue-stop-cancel-buttons')!; const isStart = btn.classList.contains('issue-start-time'); btn.classList.add('is-loading'); @@ -81,10 +81,8 @@ export function initStopwatch() { } }); - let usingPeriodicPoller = false; const startPeriodicPoller = (timeout: number) => { if (timeout <= 0 || !Number.isFinite(timeout)) return; - usingPeriodicPoller = true; setTimeout(() => updateStopwatchWithCallback(startPeriodicPoller, timeout), timeout); }; @@ -93,10 +91,7 @@ export function initStopwatch() { // Try to connect to the event source via the shared worker first const worker = new UserEventsSharedWorker('stopwatch-worker'); worker.addMessageEventListener((event) => { - if (event.data.type === 'no-event-source') { - // browser doesn't support EventSource, falling back to periodic poller - if (!usingPeriodicPoller) startPeriodicPoller(notificationSettings.MinTimeout); - } else if (event.data.type === 'stopwatches') { + if (event.data.type === 'stopwatches') { updateStopwatchData(JSON.parse(event.data.data)); } });