Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
desktop_notifications: Store notification-type data in notice_memory.
Pratik Chandaff60d8c97ce0
diff --git a/web/src/desktop_notifications.ts b/web/src/desktop_notifications.tsindex b8e57f3ca62..eb2a7215f7f 100644--- a/web/src/desktop_notifications.ts+++ b/web/src/desktop_notifications.ts@@ -3,12 +3,13 @@ import assert from "minimalistic-assert";import {electron_bridge} from "./electron_bridge.ts";+export type NotificationData = {type: "message"; message_id: number; msg_count: number};+type NoticeMemory = Map<string,{obj: Notification | ElectronBridgeNotification;- msg_count: number;- message_id: number;+ data: NotificationData;}>;@@ -73,13 +74,11 @@ export function create_notification(opts: {notification_options: NotificationOptions;key: string;title: string;- message_id: number;- msg_count: number;+ data: NotificationData;desktop_notify: boolean;on_click?: (() => void) | undefined;}): void {- const {notification_options, key, title, message_id, msg_count, desktop_notify, on_click} =- opts;+ const {notification_options, key, title, data, desktop_notify, on_click} = opts;const existing_notification = notice_memory.get(key);if (existing_notification) {existing_notification.obj.close();@@ -92,8 +91,7 @@ export function create_notification(opts: {const notification_object = new NotificationAPI(title, notification_options);notice_memory.set(key, {obj: notification_object,- msg_count,- message_id,+ data,});if (typeof notification_object.addEventListener === "function") {@@ -146,7 +144,7 @@ export function permission_state(): string {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.data.message_id === message_id) {notice_mem_entry.obj.close();notice_memory.delete(key);}diff --git a/web/src/message_notifications.ts b/web/src/message_notifications.tsindex 808a93acd10..09952d06310 100644--- a/web/src/message_notifications.ts+++ b/web/src/message_notifications.ts@@ -175,7 +175,7 @@ export function process_notification(notification: {const notice_memory = desktop_notifications.notice_memory.get(key);if (notice_memory) {- msg_count = notice_memory.msg_count + 1;+ msg_count = notice_memory.data.msg_count + 1;}const title = get_notification_title(message, msg_count);@@ -204,8 +204,7 @@ export function process_notification(notification: {notification_options,key,title,- message_id: message.id,- msg_count,+ data: {type: "message", message_id: message.id, msg_count},desktop_notify: notification.desktop_notify,on_click,});