Skip to content

Commit ff80872

Browse files
committed
Re-fix go-gitea#12095 again
Unfortunately some of the suggested changes to go-gitea#12095 introduced bugs which due to caching behaviour of sharedworkers were not caught on simple tests. These are as follows: * Changing from simple for loop to use includes here: ```js register(port) { if (!this.clients.includes(port)) return; this.clients.push(port); port.postMessage({ type: 'status', message: `registered to ${this.url}`, }); } ``` The additional `!` prevents any clients from being added and should read: ```js if (this.clients.includes(port)) return; ``` * Dropping the use of jQuery `$(...)` selection and using DOM `querySelector` here: ```js async function receiveUpdateCount(event) { try { const data = JSON.parse(event.data); const notificationCount = document.querySelector('.notification_count'); if (data.Count > 0) { notificationCount.classList.remove('hidden'); } else { notificationCount.classList.add('hidden'); } notificationCount.text() = `${data.Count}`; await updateNotificationTable(); } catch (error) { console.error(error, event); } } ``` Requires that `notificationCount.text()` be changed to use `textContent` instead. Signed-off-by: Andrew Thornton <[email protected]>
1 parent 60cb9fe commit ff80872

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

web_src/js/features/eventsource.sharedworker.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class Source {
1616
}
1717

1818
register(port) {
19-
if (!this.clients.includes(port)) return;
19+
if (this.clients.includes(port)) return;
2020

2121
this.clients.push(port);
2222

web_src/js/features/notification.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ async function receiveUpdateCount(event) {
2929
notificationCount.classList.add('hidden');
3030
}
3131

32-
notificationCount.text(`${data.Count}`);
32+
notificationCount.textContent = `${data.Count}`;
3333
await updateNotificationTable();
3434
} catch (error) {
3535
console.error(error, event);

0 commit comments

Comments
 (0)