This commit is contained in:
Jeremy Mahieu 2019-12-14 23:47:14 +01:00
commit 81ef304ad7
3 changed files with 32 additions and 1 deletions

View File

@ -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;
}

View File

@ -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

View File

@ -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,