From fe3b975c6ee222a77a80955ca2134470c5941f03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lorenz=20H=C3=BCbschle-Schneider?= Date: Mon, 19 Mar 2018 11:03:04 +0100 Subject: [PATCH] Clean up updateShowNicklist() --- js/glowingbear.js | 37 ++++++++++++++++++------------------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/js/glowingbear.js b/js/glowingbear.js index 3276cb5..32b4193 100644 --- a/js/glowingbear.js +++ b/js/glowingbear.js @@ -768,25 +768,24 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout', // certain swipe actions. Sets $scope.showNicklist accordingly and returns // whether the buffer even has a nicklist to show. $scope.updateShowNicklist = function() { - // returns array of booleans: [show nicklist, buffer has nicklist] - var result = (function() { - var ab = models.getActiveBuffer(); - // Check whether buffer exists and nicklist is non-empty - if (!ab || ab.isNicklistEmpty()) { - return [false, false]; - } - // Check if nicklist is disabled in settings (ignored on mobile) - if (!utils.isMobileUi() && settings.nonicklist) { - return [false, true]; - } - // mobile: hide nicklist unless overriden by setting or swipe action - if (utils.isMobileUi() && !settings.alwaysnicklist && $scope.swipeStatus !== -1) { - return [false, true]; - } - return [true, true]; - })(); - $scope.showNicklist = result[0]; - return result[1]; + var ab = models.getActiveBuffer(); + // Check whether buffer exists and nicklist is non-empty + if (!ab || ab.isNicklistEmpty()) { + $scope.showNicklist = false; + return false; + } + // Check if nicklist is disabled in settings (ignored on mobile) + if (!utils.isMobileUi() && settings.nonicklist) { + $scope.showNicklist = false; + return true; + } + // mobile: hide nicklist unless overriden by setting or swipe action + if (utils.isMobileUi() && !settings.alwaysnicklist && $scope.swipeStatus !== -1) { + $scope.showNicklist = false; + return true; + } + $scope.showNicklist = true; + return true; }; //XXX not sure whether this belongs here