Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions web_src/js/features/eventsource.sharedworker.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ self.onconnect = (e) => {
// How this has happened I don't understand...
// deregister from that source
const count = source.deregister(port);
// Clean-up
// Clean-up
if (count === 0) {
source.close();
sourcesByUrl[source.url] = null;
Expand All @@ -98,11 +98,9 @@ self.onconnect = (e) => {
source.register(port);
sourcesByUrl[url] = source;
sourcesByPort[port] = source;
return;
} else if (event.data.type === 'listen') {
const source = sourcesByPort[port];
source.listen(event.data.eventType);
return;
} else if (event.data.type === 'close') {
const source = sourcesByPort[port];

Expand All @@ -114,7 +112,6 @@ self.onconnect = (e) => {
sourcesByUrl[source.url] = null;
sourcesByPort[port] = null;
}
return;
} else if (event.data.type === 'status') {
const source = sourcesByPort[port];
if (!source) {
Expand All @@ -125,14 +122,12 @@ self.onconnect = (e) => {
return;
}
source.status(port);
return;
} else {
// just send it back
port.postMessage({
type: 'error',
message: `received but don't know how to handle: ${event.data}`,
});
return;
}
});
port.start();
Expand Down
17 changes: 6 additions & 11 deletions web_src/js/features/notification.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,29 +57,24 @@ export async function initNotificationCount() {
type: 'start',
url: `${window.location.origin}${AppSubUrl}/user/events`,
});
worker.port.addEventListener('message', (e) => {
if (!e.data || !e.data.type) {
console.error(e);
worker.port.addEventListener('message', (event) => {
if (!event.data || !event.data.type) {
console.error(event);
return;
}
if (event.data.type === 'notification-count') {
receiveUpdateCount(e.data);
return;
receiveUpdateCount(event.data);
} else if (event.data.type === 'error') {
console.error(e.data);
return;
console.error(event.data);
} else if (event.data.type === 'logout') {
if (e.data !== 'here') {
if (event.data !== 'here') {
return;
}
worker.port.postMessage({
type: 'close',
});
worker.port.close();
window.location.href = AppSubUrl;
return;
} else {
return;
}
});
worker.port.addEventListener('error', (e) => {
Expand Down