Merge pull request #122 from lorenzhs/fixfavico

Fix Favico
This commit is contained in:
David Cormier 2014-02-02 06:40:24 -08:00
commit 38ac95c863
1 changed files with 15 additions and 11 deletions

View File

@ -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 (typeof(notifications) !== 'number') return;
if (notifications > 0) {
$scope.favico = new Favico({
animation:'none'
$scope.favico.badge(notifications, {
bgColor: '#d00',
textColor: '#fff'
});
$scope.favico.badge(notifications);
} else {
var unread = _.reduce(models.model.buffers, function(memo, num) { return (parseInt(memo)||0) + num.unread;});
$scope.favico = new Favico({
animation:'none',
if (unread === 0) {
$scope.favico.reset();
} else {
$scope.favico.badge(unread, {
bgColor: '#5CB85C',
textColor: '#ff0'
});
$scope.favico.badge(unread);
}
}
});