notifications: Use addEventListener to register handlers.

Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
This commit is contained in:
Anders Kaseorg 2020-04-26 15:37:01 -07:00 committed by Tim Abbott
parent cb52f4d7fc
commit f277eb022c
2 changed files with 6 additions and 4 deletions

View File

@ -266,6 +266,8 @@ run_test('basic_notifications', () => {
last_shown_message_id = this.tag; last_shown_message_id = this.tag;
} }
addEventListener() {}
close() { close() {
last_closed_message_id = this.tag; last_closed_message_id = this.tag;
} }

View File

@ -385,16 +385,16 @@ function process_notification(notification) {
msg_count: msg_count, msg_count: msg_count,
message_id: message.id, message_id: message.id,
}); });
notification_object.onclick = function () { notification_object.addEventListener("click", () => {
notification_object.close(); notification_object.close();
if (message.type !== "test-notification") { if (message.type !== "test-notification") {
narrow.by_topic(message.id, {trigger: 'notification'}); narrow.by_topic(message.id, {trigger: 'notification'});
} }
window.focus(); window.focus();
}; });
notification_object.onclose = function () { notification_object.addEventListener("close", () => {
notice_memory.delete(key); notice_memory.delete(key);
}; });
} else { } else {
in_browser_notify(message, title, content, raw_operators, opts); in_browser_notify(message, title, content, raw_operators, opts);
} }