summaryrefslogtreecommitdiffstats
path: root/web_src
diff options
context:
space:
mode:
authorzeripath <art27@cantab.net>2020-07-04 23:04:00 +0100
committerGitHub <noreply@github.com>2020-07-05 01:04:00 +0300
commit3c4388f668413dfcdc4b40501e7a554127599abb (patch)
treeea9c104b0a6cdcbac385dd68827e23c088622417 /web_src
parent60cb9fe44878f31e40bac7a9b64a77a9cffdc9f6 (diff)
downloadgitea-3c4388f668413dfcdc4b40501e7a554127599abb.tar.gz
gitea-3c4388f668413dfcdc4b40501e7a554127599abb.zip
Re-fix #12095 again (#12138)
Unfortunately some of the suggested changes to #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 <art27@cantab.net>
Diffstat (limited to 'web_src')
-rw-r--r--web_src/js/features/eventsource.sharedworker.js2
-rw-r--r--web_src/js/features/notification.js2
2 files changed, 2 insertions, 2 deletions
diff --git a/web_src/js/features/eventsource.sharedworker.js b/web_src/js/features/eventsource.sharedworker.js
index e3c60ce0db..bb4f628f6c 100644
--- a/web_src/js/features/eventsource.sharedworker.js
+++ b/web_src/js/features/eventsource.sharedworker.js
@@ -16,7 +16,7 @@ class Source {
}
register(port) {
- if (!this.clients.includes(port)) return;
+ if (this.clients.includes(port)) return;
this.clients.push(port);
diff --git a/web_src/js/features/notification.js b/web_src/js/features/notification.js
index aa1b48d183..b0cc1cda44 100644
--- a/web_src/js/features/notification.js
+++ b/web_src/js/features/notification.js
@@ -29,7 +29,7 @@ async function receiveUpdateCount(event) {
notificationCount.classList.add('hidden');
}
- notificationCount.text(`${data.Count}`);
+ notificationCount.textContent = `${data.Count}`;
await updateNotificationTable();
} catch (error) {
console.error(error, event);