From 5a5aa65990a17d55ed2ec395e93dc76761c5f71d Mon Sep 17 00:00:00 2001 From: WofWca Date: Tue, 17 Dec 2024 14:47:48 +0400 Subject: [PATCH] refactor: utilize `IncomingWebxdcNotify.chatId` Depends on https://github.com/deltachat/deltachat-core-rust/pull/6345. --- .../src/system-integration/notifications.ts | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/packages/frontend/src/system-integration/notifications.ts b/packages/frontend/src/system-integration/notifications.ts index c5ef4df9f..8b1ec592a 100644 --- a/packages/frontend/src/system-integration/notifications.ts +++ b/packages/frontend/src/system-integration/notifications.ts @@ -24,10 +24,12 @@ export function initNotifications() { BackendRemote.on('IncomingMsg', (accountId, { chatId, msgId }) => { incomingMessageHandler(accountId, chatId, msgId, false) }) - BackendRemote.on('IncomingWebxdcNotify', (accountId, { msgId, text }) => { - // we don't have the chatId yet, but it will be fetched in flushNotifications - incomingMessageHandler(accountId, -1, msgId, true, text) - }) + BackendRemote.on( + 'IncomingWebxdcNotify', + (accountId, { msgId, text, chatId }) => { + incomingMessageHandler(accountId, chatId, msgId, true, text) + } + ) BackendRemote.on('IncomingMsgBunch', accountId => { flushNotifications(accountId) }) @@ -247,14 +249,6 @@ async function flushNotifications(accountId: number) { let notifications = [...queuedNotifications[accountId]] queuedNotifications = [] - for await (const n of notifications) { - if (n.chatId === -1) { - // get real chatId of the webxdc message - const message = await BackendRemote.rpc.getMessage(accountId, n.messageId) - n.chatId = message.chatId - } - } - // filter out muted chats: const uniqueChats = [...new Set(notifications.map(n => n.chatId))] const mutedChats = (