Skip to content

Commit 60cb9fe

Browse files
Bugfix for shared event source (#12129)
For some reason our eslint configuration is not working correctly and a bug has become apparent when trying to backport this to 1.12. Signed-off-by: Andrew Thornton <[email protected]> Co-authored-by: techknowlogick <[email protected]>
1 parent 510e4bd commit 60cb9fe

File tree

2 files changed

+7
-17
lines changed

2 files changed

+7
-17
lines changed

web_src/js/features/eventsource.sharedworker.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ self.onconnect = (e) => {
8787
// How this has happened I don't understand...
8888
// deregister from that source
8989
const count = source.deregister(port);
90-
// Clean-up
90+
// Clean-up
9191
if (count === 0) {
9292
source.close();
9393
sourcesByUrl[source.url] = null;
@@ -98,11 +98,9 @@ self.onconnect = (e) => {
9898
source.register(port);
9999
sourcesByUrl[url] = source;
100100
sourcesByPort[port] = source;
101-
return;
102101
} else if (event.data.type === 'listen') {
103102
const source = sourcesByPort[port];
104103
source.listen(event.data.eventType);
105-
return;
106104
} else if (event.data.type === 'close') {
107105
const source = sourcesByPort[port];
108106

@@ -114,7 +112,6 @@ self.onconnect = (e) => {
114112
sourcesByUrl[source.url] = null;
115113
sourcesByPort[port] = null;
116114
}
117-
return;
118115
} else if (event.data.type === 'status') {
119116
const source = sourcesByPort[port];
120117
if (!source) {
@@ -125,14 +122,12 @@ self.onconnect = (e) => {
125122
return;
126123
}
127124
source.status(port);
128-
return;
129125
} else {
130126
// just send it back
131127
port.postMessage({
132128
type: 'error',
133129
message: `received but don't know how to handle: ${event.data}`,
134130
});
135-
return;
136131
}
137132
});
138133
port.start();

web_src/js/features/notification.js

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -57,29 +57,24 @@ export async function initNotificationCount() {
5757
type: 'start',
5858
url: `${window.location.origin}${AppSubUrl}/user/events`,
5959
});
60-
worker.port.addEventListener('message', (e) => {
61-
if (!e.data || !e.data.type) {
62-
console.error(e);
60+
worker.port.addEventListener('message', (event) => {
61+
if (!event.data || !event.data.type) {
62+
console.error(event);
6363
return;
6464
}
6565
if (event.data.type === 'notification-count') {
66-
receiveUpdateCount(e.data);
67-
return;
66+
receiveUpdateCount(event.data);
6867
} else if (event.data.type === 'error') {
69-
console.error(e.data);
70-
return;
68+
console.error(event.data);
7169
} else if (event.data.type === 'logout') {
72-
if (e.data !== 'here') {
70+
if (event.data !== 'here') {
7371
return;
7472
}
7573
worker.port.postMessage({
7674
type: 'close',
7775
});
7876
worker.port.close();
7977
window.location.href = AppSubUrl;
80-
return;
81-
} else {
82-
return;
8378
}
8479
});
8580
worker.port.addEventListener('error', (e) => {

0 commit comments

Comments
 (0)