0
0
mirror of https://github.com/go-gitea/gitea.git synced 2026-04-12 18:40:23 +02:00

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 <noreply@anthropic.com>
This commit is contained in:
Epid 2026-04-02 08:05:00 +03:00
parent 111ca0cd4f
commit 10f8e1ec06
2 changed files with 4 additions and 13 deletions

View File

@ -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
}
});

View File

@ -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));
}
});