From a9dcc68af27ad86bc25bfa050698db6f1dbe1f4e Mon Sep 17 00:00:00 2001 From: Tor Hveem Date: Tue, 15 Oct 2013 14:31:41 +0200 Subject: [PATCH] Instead of using buffer.notification as a boolean, save number of notifications into the variable. And when displaying unread messages display unread notifications if any and if not then display number of unreads. --- index.html | 3 ++- js/models.js | 4 ++-- js/websockets.js | 8 ++++++-- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/index.html b/index.html index c9a0301..578651b 100644 --- a/index.html +++ b/index.html @@ -100,7 +100,8 @@ $ openssl req -nodes -newkey rsa:2048 -keyout relay.pem -x509 -days 365 -out rel
  • - + + {{ content.shortName }}{{ content.fullName }}
  • diff --git a/js/models.js b/js/models.js index a505b81..bbac9e6 100644 --- a/js/models.js +++ b/js/models.js @@ -17,7 +17,7 @@ models.service('models', ['$rootScope', 'colors', function($rootScope, colors) { var pointer = message['pointers'][0] var lines = [] var active = false; - var notification = false; + var notification = ''; var unread = ''; var lastSeen = -2; @@ -161,9 +161,9 @@ models.service('models', ['$rootScope', 'colors', function($rootScope, colors) { } }); - activeBuffer.notification = false; activeBuffer.active = true; activeBuffer.unread = ''; + activeBuffer.notification = ''; $rootScope.$emit('activeBufferChanged'); } diff --git a/js/websockets.js b/js/websockets.js index 70965de..ec10555 100644 --- a/js/websockets.js +++ b/js/websockets.js @@ -209,7 +209,11 @@ weechat.factory('handlers', ['$rootScope', 'colors', 'models', 'plugins', functi if(message.highlight || _.contains(message.tags, 'notify_private') ) { $rootScope.createHighlight(buffer, message); - buffer.notification = true; + if (buffer.notification == '' || buffer.notification == undefined) { + buffer.notification = 1; + }else { + buffer.notification++; + } } } } @@ -519,7 +523,7 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout', // Find next buffer with activity and switch to it for(i in $scope.buffers) { var buffer = $scope.buffers[i]; - if(buffer.notification) { + if((parseInt(buffer.notification) || 0) > 0) { $scope.setActiveBuffer(buffer.id); break; }else if((parseInt(buffer.unread) || 0) > 0) {