mirror of https://github.com/zulip/zulip.git
notifications: Check whether addEventListener is a function.
It's crazy that we need to do this; one would think that Electron apps whose sole purpose is to be used with multiple team chat tools would at least implement the standard desktop notification API correctly. But it seems worth making this tactical change to prevent every desktop notification throwing a traceback on those platforms, which if nothing else results in a lot of error spam. Fixes #15103.
This commit is contained in:
parent
d32e8276d2
commit
b840ec9491
|
@ -387,16 +387,23 @@ function process_notification(notification) {
|
|||
msg_count: msg_count,
|
||||
message_id: message.id,
|
||||
});
|
||||
notification_object.addEventListener("click", () => {
|
||||
notification_object.close();
|
||||
if (message.type !== "test-notification") {
|
||||
narrow.by_topic(message.id, {trigger: 'notification'});
|
||||
}
|
||||
window.focus();
|
||||
});
|
||||
notification_object.addEventListener("close", () => {
|
||||
notice_memory.delete(key);
|
||||
});
|
||||
|
||||
if (_.isFunction(notification_object.addEventListener)) {
|
||||
// Sadly, some third-party Electron apps like Franz/Ferdi
|
||||
// misimplement the Notification API not inheriting from
|
||||
// EventTarget. This results in addEventListener being
|
||||
// unavailable for them.
|
||||
notification_object.addEventListener("click", () => {
|
||||
notification_object.close();
|
||||
if (message.type !== "test-notification") {
|
||||
narrow.by_topic(message.id, {trigger: 'notification'});
|
||||
}
|
||||
window.focus();
|
||||
});
|
||||
notification_object.addEventListener("close", () => {
|
||||
notice_memory.delete(key);
|
||||
});
|
||||
}
|
||||
} else {
|
||||
in_browser_notify(message, title, content, raw_operators, opts);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue