Clean up updateShowNicklist()

This commit is contained in:
Lorenz Hübschle-Schneider 2018-03-19 11:03:04 +01:00
parent 66c8c53b41
commit fe3b975c6e

View file

@ -768,25 +768,24 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout',
// certain swipe actions. Sets $scope.showNicklist accordingly and returns // certain swipe actions. Sets $scope.showNicklist accordingly and returns
// whether the buffer even has a nicklist to show. // whether the buffer even has a nicklist to show.
$scope.updateShowNicklist = function() { $scope.updateShowNicklist = function() {
// returns array of booleans: [show nicklist, buffer has nicklist] var ab = models.getActiveBuffer();
var result = (function() { // Check whether buffer exists and nicklist is non-empty
var ab = models.getActiveBuffer(); if (!ab || ab.isNicklistEmpty()) {
// Check whether buffer exists and nicklist is non-empty $scope.showNicklist = false;
if (!ab || ab.isNicklistEmpty()) { return false;
return [false, false]; }
} // Check if nicklist is disabled in settings (ignored on mobile)
// Check if nicklist is disabled in settings (ignored on mobile) if (!utils.isMobileUi() && settings.nonicklist) {
if (!utils.isMobileUi() && settings.nonicklist) { $scope.showNicklist = false;
return [false, true]; return true;
} }
// mobile: hide nicklist unless overriden by setting or swipe action // mobile: hide nicklist unless overriden by setting or swipe action
if (utils.isMobileUi() && !settings.alwaysnicklist && $scope.swipeStatus !== -1) { if (utils.isMobileUi() && !settings.alwaysnicklist && $scope.swipeStatus !== -1) {
return [false, true]; $scope.showNicklist = false;
} return true;
return [true, true]; }
})(); $scope.showNicklist = true;
$scope.showNicklist = result[0]; return true;
return result[1];
}; };
//XXX not sure whether this belongs here //XXX not sure whether this belongs here