From cbd5d145dcc5a22c9b46f0426a1a7b1e830bbaad Mon Sep 17 00:00:00 2001 From: Lorenz H-S Date: Sun, 2 Feb 2014 13:00:17 +0000 Subject: [PATCH] Fix Favico Use one favico instance which is dynamically modified This uses a feature that is not yet part of the latest favico.js release, and needs a fix that isn't even merged yet. Both are included in commit 8e624ba7f089b39c549120ded9cd88956e676763 --- js/websockets.js | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/js/websockets.js b/js/websockets.js index 8a8ce48..9a4a76a 100644 --- a/js/websockets.js +++ b/js/websockets.js @@ -499,21 +499,25 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout', // Check if we should show nicklist or not $scope.showNicklist = $scope.updateShowNicklist(); }); + $scope.favico = new Favico({animation: 'none'}); $rootScope.$on('notificationChanged', function() { var notifications = _.reduce(models.model.buffers, function(memo, num) { return (parseInt(memo)||0) + num.notification;}); - if (notifications > 0 ) { - $scope.favico = new Favico({ - animation:'none' + if (typeof(notifications) !== 'number') return; + if (notifications > 0) { + $scope.favico.badge(notifications, { + bgColor: '#d00', + textColor: '#fff' }); - $scope.favico.badge(notifications); - }else { + } else { var unread = _.reduce(models.model.buffers, function(memo, num) { return (parseInt(memo)||0) + num.unread;}); - $scope.favico = new Favico({ - animation:'none', - bgColor : '#5CB85C', - textColor : '#ff0' - }); - $scope.favico.badge(unread); + if (unread === 0) { + $scope.favico.reset(); + } else { + $scope.favico.badge(unread, { + bgColor: '#5CB85C', + textColor: '#ff0' + }); + } } });