From ea930d53ae47d874a45a8a8fb4fb6feb820ee83b Mon Sep 17 00:00:00 2001 From: lilia Date: Mon, 24 Apr 2017 17:00:17 -0700 Subject: [PATCH] Set badge count This is displayed on the launcher icon on linux/mac // FREEBIE --- js/panel_controller.js | 4 ++-- main.js | 4 ++++ preload.js | 3 +++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/js/panel_controller.js b/js/panel_controller.js index 532c2401f..7ff4fd845 100644 --- a/js/panel_controller.js +++ b/js/panel_controller.js @@ -41,10 +41,10 @@ window.setUnreadCount = function(count) { if (count > 0) { - extension.navigator.setBadgeText(count); + window.setBadgeCount(count); window.document.title = "Signal (" + count + ")"; } else { - extension.navigator.setBadgeText(""); + window.setBadgeCount(0); window.document.title = "Signal"; } }; diff --git a/main.js b/main.js index e1acff8a7..75d238500 100644 --- a/main.js +++ b/main.js @@ -173,3 +173,7 @@ app.on('activate', function () { // In this file you can include the rest of your app's specific main process // code. You can also put them in separate files and require them here. + +ipc.on('set-badge-count', function(event, count) { + app.setBadgeCount(count); +}); diff --git a/preload.js b/preload.js index dc8b5baf1..ce79ae6db 100644 --- a/preload.js +++ b/preload.js @@ -8,6 +8,9 @@ const ipc = electron.ipcRenderer window.config.locale_json = ipc.sendSync('locale-data'); + window.setBadgeCount = function(count) { + ipc.send('set-badge-count', count); + }; /** * Enables spell-checking and the right-click context menu in text editors. * Electron (`webFrame.setSpellCheckProvider`) only underlines misspelled words;