Skip to content

Commit

Permalink
Add all unread numbers from chat categories for tray icon
Browse files Browse the repository at this point in the history
  • Loading branch information
mquevill committed Feb 22, 2024
1 parent 8ea4bee commit 977ccfb
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions source/browser/conversation-list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -260,12 +260,20 @@ function countUnread(mutationsList: MutationRecord[]): void {
}

async function updateTrayIcon(): Promise<void> {
const chatsIcon = await elementReady(selectors.chatsIcon, {
stopOnDomReady: false,
});
let messageCount = 0;

await elementReady(selectors.chatsIcon, {stopOnDomReady: false});

// Count unread messages in Chats, Marketplace, etc.
for (const element of document.querySelectorAll<HTMLElement>(selectors.chatsIcon)) {
// Extract messageNumber from ariaLabel
const messageNumber = element?.ariaLabel?.match(/\d+/g);

if (messageNumber) {
messageCount += parseInt(messageNumber[0]);

Check failure on line 273 in source/browser/conversation-list.ts

View workflow job for this annotation

GitHub Actions / tests

Prefer `Number.parseInt()` over `parseInt()`.

Check failure on line 273 in source/browser/conversation-list.ts

View workflow job for this annotation

GitHub Actions / tests

Missing radix parameter.
}
}

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

Expand Down

0 comments on commit 977ccfb

Please sign in to comment.