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.
This commit is contained in:
Tor Hveem 2013-10-15 14:31:41 +02:00
parent 8fea1c072e
commit a9dcc68af2
3 changed files with 10 additions and 5 deletions

View File

@ -100,7 +100,8 @@ $ openssl req -nodes -newkey rsa:2048 -keyout relay.pem -x509 -days 365 -out rel
</li> </li>
<li class="label" ng-class="{'active': content.active }" ng-repeat="(key, content) in buffers | toArray | filter:search | filter:hasUnread | orderBy:'content.number':true"> <li class="label" ng-class="{'active': content.active }" ng-repeat="(key, content) in buffers | toArray | filter:search | filter:hasUnread | orderBy:'content.number':true">
<a href="#" ng-click="setActiveBuffer(content.id)" title="{{ content.fullName }}"> <a href="#" ng-click="setActiveBuffer(content.id)" title="{{ content.fullName }}">
<span class="badge pull-right" ng-class="{'danger': content.notification }" ng-bind="content.unread"></span> <span class="badge pull-right" ng-hide="content.notification" ng-bind="content.unread"></span>
<span class="badge pull-right danger" ng-show="content.notification" ng-bind="content.notification"></span>
{{ content.shortName }}<span ng-hide="content.shortName">{{ content.fullName }}</span> {{ content.shortName }}<span ng-hide="content.shortName">{{ content.fullName }}</span>
</a> </a>
</li> </li>

View File

@ -17,7 +17,7 @@ models.service('models', ['$rootScope', 'colors', function($rootScope, colors) {
var pointer = message['pointers'][0] var pointer = message['pointers'][0]
var lines = [] var lines = []
var active = false; var active = false;
var notification = false; var notification = '';
var unread = ''; var unread = '';
var lastSeen = -2; var lastSeen = -2;
@ -161,9 +161,9 @@ models.service('models', ['$rootScope', 'colors', function($rootScope, colors) {
} }
}); });
activeBuffer.notification = false;
activeBuffer.active = true; activeBuffer.active = true;
activeBuffer.unread = ''; activeBuffer.unread = '';
activeBuffer.notification = '';
$rootScope.$emit('activeBufferChanged'); $rootScope.$emit('activeBufferChanged');
} }

View File

@ -209,7 +209,11 @@ weechat.factory('handlers', ['$rootScope', 'colors', 'models', 'plugins', functi
if(message.highlight || _.contains(message.tags, 'notify_private') ) { if(message.highlight || _.contains(message.tags, 'notify_private') ) {
$rootScope.createHighlight(buffer, message); $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 // Find next buffer with activity and switch to it
for(i in $scope.buffers) { for(i in $scope.buffers) {
var buffer = $scope.buffers[i]; var buffer = $scope.buffers[i];
if(buffer.notification) { if((parseInt(buffer.notification) || 0) > 0) {
$scope.setActiveBuffer(buffer.id); $scope.setActiveBuffer(buffer.id);
break; break;
}else if((parseInt(buffer.unread) || 0) > 0) { }else if((parseInt(buffer.unread) || 0) > 0) {