Document, simplify, and improve swipe logic

This commit is contained in:
Lorenz Hübschle-Schneider 2017-04-17 18:04:24 +02:00 committed by Lorenz Hübschle-Schneider
parent f3e0e3e047
commit 9c28ec4055

View file

@ -30,6 +30,11 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout',
$scope.command = ''; $scope.command = '';
$scope.themes = ['dark', 'light', 'black', 'dark-spacious', 'blue', 'base16-default', 'base16-light', 'base16-mocha', 'base16-ocean-dark', 'base16-solarized-dark', 'base16-solarized-light']; $scope.themes = ['dark', 'light', 'black', 'dark-spacious', 'blue', 'base16-default', 'base16-light', 'base16-mocha', 'base16-ocean-dark', 'base16-solarized-dark', 'base16-solarized-light'];
// Current swipe status. Values:
// +1: bufferlist open, nicklist closed
// 0: bufferlist closed, nicklist closed
// -1: bufferlist closed, nicklist open
$scope.swipeStatus = 1; $scope.swipeStatus = 1;
// Initialise all our settings, this needs to include all settings // Initialise all our settings, this needs to include all settings
@ -171,9 +176,6 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout',
// Check if we should show nicklist or not // Check if we should show nicklist or not
$scope.showNicklist = $scope.updateShowNicklist(); $scope.showNicklist = $scope.updateShowNicklist();
} }
if ($scope.swipeStatus <= 0 && !settings.alwaysnicklist) {
$scope.swipeStatus = $scope.showNicklist ? -1 : 0;
}
if (ab.requestedLines < $scope.lines_per_screen) { if (ab.requestedLines < $scope.lines_per_screen) {
// buffer has not been loaded, but some lines may already be present if they arrived after we connected // buffer has not been loaded, but some lines may already be present if they arrived after we connected
@ -336,6 +338,7 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout',
} else if ($scope.swipeStatus === 0) { } else if ($scope.swipeStatus === 0) {
$scope.showSidebar(); // updates swipe status to 1 $scope.showSidebar(); // updates swipe status to 1
} else if ($scope.swipeStatus === -1) { } else if ($scope.swipeStatus === -1) {
// hide nicklist
$scope.swipeStatus = 0; $scope.swipeStatus = 0;
$scope.showNicklist = $scope.updateShowNicklist(); $scope.showNicklist = $scope.updateShowNicklist();
} else { } else {
@ -351,6 +354,7 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout',
if ($scope.swipeStatus === 1) { if ($scope.swipeStatus === 1) {
$scope.hideSidebar(); // updates swipe status to 0 $scope.hideSidebar(); // updates swipe status to 0
} else if ($scope.swipeStatus === 0) { } else if ($scope.swipeStatus === 0) {
// show nicklist
$scope.swipeStatus = -1; $scope.swipeStatus = -1;
$scope.showNicklist = $scope.updateShowNicklist(); $scope.showNicklist = $scope.updateShowNicklist();
} else if ($scope.swipeStatus === -1) { } else if ($scope.swipeStatus === -1) {
@ -746,9 +750,6 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout',
// Watch model and update show setting when it changes // Watch model and update show setting when it changes
settings.addCallback('nonicklist', function() { settings.addCallback('nonicklist', function() {
$scope.showNicklist = $scope.updateShowNicklist(); $scope.showNicklist = $scope.updateShowNicklist();
if ($scope.swipeStatus <= 0 && !settings.alwaysnicklist) {
$scope.swipeStatus = $scope.showNicklist ? -1 : 0;
}
// restore bottom view // restore bottom view
if ($rootScope.connected && $rootScope.bufferBottom) { if ($rootScope.connected && $rootScope.bufferBottom) {
$timeout(function(){ $timeout(function(){
@ -756,6 +757,9 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout',
}, 500); }, 500);
} }
}); });
settings.addCallback('alwaysnicklist', function() {
$scope.showNicklist = $scope.updateShowNicklist();
});
$scope.showNicklist = false; $scope.showNicklist = false;
// Utility function that template can use to check if nicklist should // Utility function that template can use to check if nicklist should
// be displayed for current buffer or not // be displayed for current buffer or not