Skip to content
This repository has been archived by the owner on Sep 6, 2023. It is now read-only.

Set badge icon for unread channels #156

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
19 changes: 15 additions & 4 deletions app/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -274,12 +274,23 @@ function openMainWindow(opts) {
mainWindow.on('page-title-updated', function(event) {
var title = mainWindow.getTitle();
if (title && is.macOS()) {
var unread = "";
var matches = title.match(/^\((\d+)\)/);
var matches = title.match(/^(?:\((\d+)\)|([*+]))/);
var badge = "";
if (matches) {
unread = matches[1];
if (matches[1]) {
badge = matches[1];
} else {
var current = app.dock.getBadge();
if (/^\d+$/.test(current)) badge = current;

// '+' means active channel has a notification
if (current === '+') badge = current;

// '*' means a channel has a notification
badge = matches[2];
}
}
app.dock.setBadge(unread);
app.dock.setBadge(badge);
}
});

Expand Down