From aa6e444b6554feb4033b2896d963d2695a156bec Mon Sep 17 00:00:00 2001 From: Justin Ridgewell Date: Thu, 2 Apr 2020 02:20:29 -0400 Subject: [PATCH] Better badge icon --- app/main.js | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/app/main.js b/app/main.js index 412eaf7..6493046 100644 --- a/app/main.js +++ b/app/main.js @@ -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); } });