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); }, false);
} }
$rootScope.$on('nickListChanged', function() {
$scope.updateShowNicklist();
});
$rootScope.$on('activeBufferChanged', function(event, unreadSum) { $rootScope.$on('activeBufferChanged', function(event, unreadSum) {
var ab = models.getActiveBuffer(); var ab = models.getActiveBuffer();
@ -776,7 +779,7 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout',
$scope.updateShowNicklist = function() { $scope.updateShowNicklist = function() {
var ab = models.getActiveBuffer(); var ab = models.getActiveBuffer();
// Check whether buffer exists and nicklist is non-empty // Check whether buffer exists and nicklist is non-empty
if (!ab || ab.isNicklistEmpty()) { if (!ab || !ab.nicklistRequested() || ab.isNicklistEmpty()) {
$scope.showNicklist = false; $scope.showNicklist = false;
return false; return false;
} }

View File

@ -431,12 +431,24 @@ weechat.factory('handlers', ['$rootScope', '$log', 'models', 'plugins', 'notific
/* /*
* Handle nicklist event * Handle nicklist event
*
* This event can either fill or clear a nicklist. It is always a complete nicklist.
*/ */
var handleNicklist = function(message) { var handleNicklist = function(message) {
var nicklist = message.objects[0].content; var nicklist = message.objects[0].content;
var group = 'root'; 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) { nicklist.forEach(function(n) {
var buffer = models.getBuffer(n.pointers[0]); var buffer = models.getBuffer(n.pointers[0]);
//buffer nicklist
if (n.group === 1) { if (n.group === 1) {
var g = new models.NickGroup(n); var g = new models.NickGroup(n);
group = g.name; group = g.name;
@ -446,6 +458,9 @@ weechat.factory('handlers', ['$rootScope', '$log', 'models', 'plugins', 'notific
buffer.addNick(group, nick); buffer.addNick(group, nick);
} }
}); });
//check if nicklist should be hidden or not
$rootScope.$emit('nickListChanged');
}; };
/* /*
* Handle nicklist diff event * 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 * Updates a nick in nicklist
*/ */
@ -325,6 +337,7 @@ models.service('models', ['$rootScope', '$filter', 'bufferResume', function($roo
nicklist: nicklist, nicklist: nicklist,
addNick: addNick, addNick: addNick,
delNick: delNick, delNick: delNick,
clearNicklist: clearNicklist,
updateNick: updateNick, updateNick: updateNick,
getNicklistByTime: getNicklistByTime, getNicklistByTime: getNicklistByTime,
serverSortKey: serverSortKey, serverSortKey: serverSortKey,