Merge branch 'master' of https://github.com/glowing-bear/glowing-bear
This commit is contained in:
commit
81ef304ad7
|
@ -149,6 +149,9 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout',
|
|||
}, false);
|
||||
}
|
||||
|
||||
$rootScope.$on('nickListChanged', function() {
|
||||
$scope.updateShowNicklist();
|
||||
});
|
||||
|
||||
$rootScope.$on('activeBufferChanged', function(event, unreadSum) {
|
||||
var ab = models.getActiveBuffer();
|
||||
|
@ -776,7 +779,7 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout',
|
|||
$scope.updateShowNicklist = function() {
|
||||
var ab = models.getActiveBuffer();
|
||||
// Check whether buffer exists and nicklist is non-empty
|
||||
if (!ab || ab.isNicklistEmpty()) {
|
||||
if (!ab || !ab.nicklistRequested() || ab.isNicklistEmpty()) {
|
||||
$scope.showNicklist = false;
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -431,12 +431,24 @@ weechat.factory('handlers', ['$rootScope', '$log', 'models', 'plugins', 'notific
|
|||
|
||||
/*
|
||||
* Handle nicklist event
|
||||
*
|
||||
* This event can either fill or clear a nicklist. It is always a complete nicklist.
|
||||
*/
|
||||
var handleNicklist = function(message) {
|
||||
var nicklist = message.objects[0].content;
|
||||
var group = 'root';
|
||||
|
||||
//clear the nicklists in case we are clearing
|
||||
if (nicklist.length==1)
|
||||
{
|
||||
models.getBuffer(nicklist[0].pointers[0]).clearNicklist();
|
||||
}
|
||||
|
||||
//fill the nicklist
|
||||
nicklist.forEach(function(n) {
|
||||
var buffer = models.getBuffer(n.pointers[0]);
|
||||
|
||||
//buffer nicklist
|
||||
if (n.group === 1) {
|
||||
var g = new models.NickGroup(n);
|
||||
group = g.name;
|
||||
|
@ -446,6 +458,9 @@ weechat.factory('handlers', ['$rootScope', '$log', 'models', 'plugins', 'notific
|
|||
buffer.addNick(group, nick);
|
||||
}
|
||||
});
|
||||
|
||||
//check if nicklist should be hidden or not
|
||||
$rootScope.$emit('nickListChanged');
|
||||
};
|
||||
/*
|
||||
* Handle nicklist diff event
|
||||
|
|
13
js/models.js
13
js/models.js
|
@ -154,6 +154,18 @@ models.service('models', ['$rootScope', '$filter', 'bufferResume', function($roo
|
|||
}
|
||||
*/
|
||||
};
|
||||
/*
|
||||
* Clear the nicklist
|
||||
*/
|
||||
var clearNicklist = function() {
|
||||
//only keep the root node
|
||||
for (var obj in nicklist) {
|
||||
if (obj !== 'root') {
|
||||
delete nicklist[obj];
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/*
|
||||
* Updates a nick in nicklist
|
||||
*/
|
||||
|
@ -325,6 +337,7 @@ models.service('models', ['$rootScope', '$filter', 'bufferResume', function($roo
|
|||
nicklist: nicklist,
|
||||
addNick: addNick,
|
||||
delNick: delNick,
|
||||
clearNicklist: clearNicklist,
|
||||
updateNick: updateNick,
|
||||
getNicklistByTime: getNicklistByTime,
|
||||
serverSortKey: serverSortKey,
|
||||
|
|
Loading…
Reference in New Issue