Simplify/clean up the unread and notification code
This commit is contained in:
parent
a9dcc68af2
commit
2617dadb65
3 changed files with 14 additions and 18 deletions
14
js/models.js
14
js/models.js
|
@ -16,10 +16,10 @@ models.service('models', ['$rootScope', 'colors', function($rootScope, colors) {
|
|||
var number = message['number']
|
||||
var pointer = message['pointers'][0]
|
||||
var lines = []
|
||||
var active = false;
|
||||
var notification = '';
|
||||
var unread = '';
|
||||
var lastSeen = -2;
|
||||
var active = false
|
||||
var notification = 0
|
||||
var unread = 0
|
||||
var lastSeen = -2
|
||||
|
||||
/*
|
||||
* Adds a line to this buffer
|
||||
|
@ -30,7 +30,7 @@ models.service('models', ['$rootScope', 'colors', function($rootScope, colors) {
|
|||
var addLine = function(line) {
|
||||
lines.push(line);
|
||||
}
|
||||
|
||||
|
||||
return {
|
||||
id: pointer,
|
||||
fullName: fullName,
|
||||
|
@ -40,6 +40,8 @@ models.service('models', ['$rootScope', 'colors', function($rootScope, colors) {
|
|||
lines: lines,
|
||||
addLine: addLine,
|
||||
lastSeen: lastSeen,
|
||||
unread: unread,
|
||||
notification: notification,
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -100,6 +102,8 @@ models.service('models', ['$rootScope', 'colors', function($rootScope, colors) {
|
|||
|
||||
var BufferList = []
|
||||
activeBuffer = null;
|
||||
unreads = 0;
|
||||
notifications = 0;
|
||||
|
||||
this.model = { 'buffers': {} }
|
||||
|
||||
|
|
|
@ -200,20 +200,12 @@ weechat.factory('handlers', ['$rootScope', 'colors', 'models', 'plugins', functi
|
|||
|
||||
if (!initial) {
|
||||
if (!buffer.active && _.contains(message.tags, 'notify_message') && !_.contains(message.tags, 'notify_none')) {
|
||||
if (buffer.unread == '' || buffer.unread == undefined) {
|
||||
buffer.unread = 1;
|
||||
}else {
|
||||
buffer.unread++;
|
||||
}
|
||||
buffer.unread++;
|
||||
}
|
||||
|
||||
if(message.highlight || _.contains(message.tags, 'notify_private') ) {
|
||||
buffer.notification++;
|
||||
$rootScope.createHighlight(buffer, message);
|
||||
if (buffer.notification == '' || buffer.notification == undefined) {
|
||||
buffer.notification = 1;
|
||||
}else {
|
||||
buffer.notification++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -523,10 +515,10 @@ 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((parseInt(buffer.notification) || 0) > 0) {
|
||||
if(buffer.notification > 0) {
|
||||
$scope.setActiveBuffer(buffer.id);
|
||||
break;
|
||||
}else if((parseInt(buffer.unread) || 0) > 0) {
|
||||
}else if(buffer.unread > 0) {
|
||||
$scope.setActiveBuffer(buffer.id);
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue