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

Include Marketplace and other unread messages in tray icon number #2133

Merged
merged 3 commits into from
Feb 29, 2024
Merged
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: 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 += Number.parseInt(messageNumber[0], 10);
}
}

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

Expand Down
Loading