From 9c0d527af9770c88c65b3d0a4d8af5d66ceaee40 Mon Sep 17 00:00:00 2001 From: Robert Stanfield Date: Thu, 4 Aug 2016 23:07:59 -0400 Subject: [PATCH] Fix Web Skype bug --- views/preload.js | 11 +++++++++++ views/skype.js | 20 ++++---------------- 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/views/preload.js b/views/preload.js index 061182d..b43ab1b 100644 --- a/views/preload.js +++ b/views/preload.js @@ -32,6 +32,17 @@ setActivityHandle(settings.RefreshInterval); }); + setInterval(function() { + let hasNotifications = document.querySelector('.unseenNotifications'); + let count = 0; + + if (hasNotifications) { + count = 1; + } + + ipc.sendToHost('notification-count', count); + }, 1000); + window.addEventListener("DOMContentLoaded", function(event) { $ = require('../assets/jquery-2.2.3.min'); diff --git a/views/skype.js b/views/skype.js index 55ed78d..27a7772 100644 --- a/views/skype.js +++ b/views/skype.js @@ -39,21 +39,6 @@ function checkMicrosoftAccount(event, currentURL) { } } -/** - * Decides if the user has any unread notifications and - * provides the appropriate feedback to the tray icon - */ -function checkTrayIcon(event) { - let result = /^\((\d+)\)/.exec(event.title); - let count = 0; - - if (result !== null && result.length === 2) { - count = Number(result[1]); - } - - TrayIcon.setNotificationCount(count); -} - function boot() { skypeView.removeEventListener('dom-ready', boot); @@ -123,7 +108,6 @@ skypeView.addEventListener('page-title-updated', function(event) { title.innerHTML = event.title; checkMicrosoftAccount(event, currentURL); - checkTrayIcon(event); }); skypeView.addEventListener('new-window', function(event) { @@ -152,5 +136,9 @@ let ipcHandler = { // Open links in external browser electron.shell.openExternal(href); } + }, + + 'notification-count': function(count) { + TrayIcon.setNotificationCount(count); } }