Stop abusing "hide nicklist" setting to show/hide sidebar on mobile
This commit is contained in:
parent
f44b67489d
commit
f3e0e3e047
1 changed files with 15 additions and 30 deletions
|
@ -334,13 +334,14 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout',
|
||||||
if ($scope.swipeStatus === 1) {
|
if ($scope.swipeStatus === 1) {
|
||||||
/* do nothing */
|
/* do nothing */
|
||||||
} else if ($scope.swipeStatus === 0) {
|
} else if ($scope.swipeStatus === 0) {
|
||||||
$scope.showSidebar();
|
$scope.showSidebar(); // updates swipe status to 1
|
||||||
} else if ($scope.swipeStatus === -1) {
|
} else if ($scope.swipeStatus === -1) {
|
||||||
if (!settings.alwaysnicklist) $scope.closeNick();
|
$scope.swipeStatus = 0;
|
||||||
|
$scope.showNicklist = $scope.updateShowNicklist();
|
||||||
} else {
|
} else {
|
||||||
console.log("Weird swipe status:", $scope.swipeStatus);
|
console.log("Weird swipe status:", $scope.swipeStatus);
|
||||||
$scope.swipeStatus = 0; // restore sanity
|
$scope.swipeStatus = 0; // restore sanity
|
||||||
$scope.closeNick();
|
$scope.showNicklist = $scope.updateShowNicklist();
|
||||||
$scope.hideSidebar();
|
$scope.hideSidebar();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -348,15 +349,16 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout',
|
||||||
$rootScope.swipeLeft = function() {
|
$rootScope.swipeLeft = function() {
|
||||||
// Depending on swipe state, ...
|
// Depending on swipe state, ...
|
||||||
if ($scope.swipeStatus === 1) {
|
if ($scope.swipeStatus === 1) {
|
||||||
$scope.hideSidebar();
|
$scope.hideSidebar(); // updates swipe status to 0
|
||||||
} else if ($scope.swipeStatus === 0) {
|
} else if ($scope.swipeStatus === 0) {
|
||||||
$scope.openNick();
|
$scope.swipeStatus = -1;
|
||||||
|
$scope.showNicklist = $scope.updateShowNicklist();
|
||||||
} else if ($scope.swipeStatus === -1) {
|
} else if ($scope.swipeStatus === -1) {
|
||||||
/* do nothing */
|
/* do nothing */
|
||||||
} else {
|
} else {
|
||||||
console.log("Weird swipe status:", $scope.swipeStatus);
|
console.log("Weird swipe status:", $scope.swipeStatus);
|
||||||
$scope.swipeStatus = 0; // restore sanity
|
$scope.swipeStatus = 0; // restore sanity
|
||||||
$scope.closeNick();
|
$scope.showNicklist = $scope.updateShowNicklist();
|
||||||
$scope.hideSidebar();
|
$scope.hideSidebar();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -369,8 +371,6 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout',
|
||||||
_.each(document.getElementsByTagName('textarea'), function(elem) {
|
_.each(document.getElementsByTagName('textarea'), function(elem) {
|
||||||
$timeout(function(){elem.blur();});
|
$timeout(function(){elem.blur();});
|
||||||
});
|
});
|
||||||
// hide nicklist
|
|
||||||
settings.nonicklist = true;
|
|
||||||
}
|
}
|
||||||
$scope.swipeStatus = 1;
|
$scope.swipeStatus = 1;
|
||||||
};
|
};
|
||||||
|
@ -378,14 +378,11 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout',
|
||||||
$rootScope.hideSidebar = function() {
|
$rootScope.hideSidebar = function() {
|
||||||
if (utils.isMobileUi()) {
|
if (utils.isMobileUi()) {
|
||||||
// make sure nicklist is hidden
|
// make sure nicklist is hidden
|
||||||
settings.nonicklist = true;
|
|
||||||
document.getElementById('sidebar').setAttribute('data-state', 'hidden');
|
document.getElementById('sidebar').setAttribute('data-state', 'hidden');
|
||||||
document.getElementById('content').setAttribute('sidebar-state', 'hidden');
|
document.getElementById('content').setAttribute('sidebar-state', 'hidden');
|
||||||
}
|
}
|
||||||
$scope.swipeStatus = 0;
|
$scope.swipeStatus = 0;
|
||||||
};
|
};
|
||||||
// fugly hack
|
|
||||||
$scope.hideSidebar = function() { $rootScope.hideSidebar(); };
|
|
||||||
|
|
||||||
settings.addCallback('autoconnect', function(autoconnect) {
|
settings.addCallback('autoconnect', function(autoconnect) {
|
||||||
if (autoconnect && !$rootScope.connected && !$rootScope.sslError && !$rootScope.securityError && !$rootScope.errorMessage) {
|
if (autoconnect && !$rootScope.connected && !$rootScope.sslError && !$rootScope.securityError && !$rootScope.errorMessage) {
|
||||||
|
@ -404,23 +401,6 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout',
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Open and close panels while on mobile devices through swiping
|
|
||||||
$scope.openNick = function() {
|
|
||||||
if (utils.isMobileUi()) {
|
|
||||||
if (settings.nonicklist) {
|
|
||||||
settings.nonicklist = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
$scope.closeNick = function() {
|
|
||||||
if (utils.isMobileUi()) {
|
|
||||||
if (!settings.nonicklist) {
|
|
||||||
settings.nonicklist = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// Watch model and update channel sorting when it changes
|
// Watch model and update channel sorting when it changes
|
||||||
var set_filter_predicate = function(orderbyserver) {
|
var set_filter_predicate = function(orderbyserver) {
|
||||||
if ($rootScope.showJumpKeys) {
|
if ($rootScope.showJumpKeys) {
|
||||||
|
@ -588,6 +568,7 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout',
|
||||||
// Wrap in a condition so we save ourselves the $apply if nothing changes (50ms or more)
|
// Wrap in a condition so we save ourselves the $apply if nothing changes (50ms or more)
|
||||||
if ($scope.wasMobileUi && !utils.isMobileUi()) {
|
if ($scope.wasMobileUi && !utils.isMobileUi()) {
|
||||||
$scope.showSidebar();
|
$scope.showSidebar();
|
||||||
|
$scope.showNicklist = $scope.updateShowNicklist();
|
||||||
}
|
}
|
||||||
$scope.wasMobileUi = utils.isMobileUi();
|
$scope.wasMobileUi = utils.isMobileUi();
|
||||||
$scope.calculateNumLines();
|
$scope.calculateNumLines();
|
||||||
|
@ -784,14 +765,18 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout',
|
||||||
if (!ab) {
|
if (!ab) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// Check if option no nicklist is set
|
// Check if option no nicklist is set (ignored on mobile)
|
||||||
if (settings.nonicklist && !settings.alwaysnicklist) {
|
if (!utils.isMobileUi() && settings.nonicklist && !settings.alwaysnicklist) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// Check if nicklist is empty
|
// Check if nicklist is empty
|
||||||
if (ab.isNicklistEmpty()) {
|
if (ab.isNicklistEmpty()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
// Check whether to show nicklist on mobile
|
||||||
|
if (utils.isMobileUi() && !settings.alwaysnicklist && $scope.swipeStatus !== -1) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue