Skip to content

Commit 35e5eb8

Browse files
authored
feat: Include Marketplace and other unread messages in tray icon number (#2133)
* Add all unread numbers from chat categories for tray icon * Add radix to parseInt() * Use Number.parseInt
1 parent 50c57c3 commit 35e5eb8

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

source/browser/conversation-list.ts

+13-5
Original file line numberDiff line numberDiff line change
@@ -260,12 +260,20 @@ function countUnread(mutationsList: MutationRecord[]): void {
260260
}
261261

262262
async function updateTrayIcon(): Promise<void> {
263-
const chatsIcon = await elementReady(selectors.chatsIcon, {
264-
stopOnDomReady: false,
265-
});
263+
let messageCount = 0;
264+
265+
await elementReady(selectors.chatsIcon, {stopOnDomReady: false});
266+
267+
// Count unread messages in Chats, Marketplace, etc.
268+
for (const element of document.querySelectorAll<HTMLElement>(selectors.chatsIcon)) {
269+
// Extract messageNumber from ariaLabel
270+
const messageNumber = element?.ariaLabel?.match(/\d+/g);
271+
272+
if (messageNumber) {
273+
messageCount += Number.parseInt(messageNumber[0], 10);
274+
}
275+
}
266276

267-
// Extract messageCount from ariaLabel
268-
const messageCount = chatsIcon?.ariaLabel?.match(/\d+/g) ?? 0;
269277
ipc.callMain('update-tray-icon', messageCount);
270278
}
271279

0 commit comments

Comments
 (0)