Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
desktop_notifications: Close notifications by message id.
Pratik Chanda11b7175b8ec2
diff --git a/web/src/desktop_notifications.ts b/web/src/desktop_notifications.tsindex 0dbe79052f0..76e923554f3 100644--- a/web/src/desktop_notifications.ts+++ b/web/src/desktop_notifications.ts@@ -2,7 +2,6 @@ import {$} from "jquery";import assert from "minimalistic-assert";import {electron_bridge} from "./electron_bridge.ts";-import type {Message} from "./message_store.ts";type NoticeMemory = Map<string,@@ -97,9 +96,9 @@ export function permission_state(): string {return "denied";}-export function close_notification(message: Message): void {+export function close_notification(message_id: number): void {for (const [key, notice_mem_entry] of notice_memory) {- if (notice_mem_entry.message_id === message.id) {+ if (notice_mem_entry.message_id === message_id) {notice_mem_entry.obj.close();notice_memory.delete(key);}diff --git a/web/src/unread_ops.ts b/web/src/unread_ops.tsindex 3ee354ce3e3..99f89caf23b 100644--- a/web/src/unread_ops.ts+++ b/web/src/unread_ops.ts@@ -401,7 +401,7 @@ function process_newly_read_message(for (const msg_list of message_lists.all_rendered_message_lists()) {msg_list.view.show_message_as_read(message, options);}- desktop_notifications.close_notification(message);+ desktop_notifications.close_notification(message.id);recent_view_ui.update_topic_unread_count(message);}diff --git a/web/tests/notifications.test.cjs b/web/tests/notifications.test.cjsindex 60f406643f8..3caebfec1da 100644--- a/web/tests/notifications.test.cjs+++ b/web/tests/notifications.test.cjs@@ -508,7 +508,7 @@ test("basic_notifications", () => {assert.equal(last_shown_message_id, stream_message_1.id.toString());// Remove notification.- desktop_notifications.close_notification(stream_message_1);+ desktop_notifications.close_notification(stream_message_1.id);n = desktop_notifications.get_notifications();assert.equal(n.has("channel:1:10:whatever"), false);assert.equal(n.size, 0);@@ -539,8 +539,8 @@ test("basic_notifications", () => {assert.equal(last_shown_message_id, stream_message_2.id.toString());// Remove notifications.- desktop_notifications.close_notification(stream_message_1);- desktop_notifications.close_notification(stream_message_2);+ desktop_notifications.close_notification(stream_message_1.id);+ desktop_notifications.close_notification(stream_message_2.id);n = desktop_notifications.get_notifications();assert.equal(n.has("channel:1:10:whatever"), false);assert.equal(n.size, 0);@@ -550,7 +550,7 @@ test("basic_notifications", () => {n = desktop_notifications.get_notifications();assert.equal(n.has("dm:2,3"), true);assert.equal(n.size, 1);- desktop_notifications.close_notification(direct_message);+ desktop_notifications.close_notification(direct_message.id);message_notifications.process_notification({message: test_notification_message,@@ -559,5 +559,5 @@ test("basic_notifications", () => {n = desktop_notifications.get_notifications();assert.equal(n.has("test:Notification Bot"), true);assert.equal(n.size, 1);- desktop_notifications.close_notification(test_notification_message);+ desktop_notifications.close_notification(test_notification_message.id);});