Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: utilize IncomingWebxdcNotify.chatId #4412

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 6 additions & 12 deletions packages/frontend/src/system-integration/notifications.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
Expand Down Expand Up @@ -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 = (
Expand Down
Loading