Merge pull request #999 from lorenzhs/alt-a-hidden-buffers

Don't jump to hidden buffers with Alt-A
This commit is contained in:
Lorenz Hübschle-Schneider 2018-04-16 14:54:39 +02:00 committed by GitHub
commit 41a066ead1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -796,7 +796,7 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout',
// Try to find buffer with notification // Try to find buffer with notification
for (i in sortedBuffers) { for (i in sortedBuffers) {
buffer = sortedBuffers[i]; buffer = sortedBuffers[i];
if (buffer.notification > 0) { if (buffer.notification > 0 && !buffer.hidden) {
$scope.setActiveBuffer(buffer.id); $scope.setActiveBuffer(buffer.id);
return; // return instead of break so that the second for loop isn't executed return; // return instead of break so that the second for loop isn't executed
} }
@ -804,7 +804,7 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout',
// No notifications, find first buffer with unread lines instead // No notifications, find first buffer with unread lines instead
for (i in sortedBuffers) { for (i in sortedBuffers) {
buffer = sortedBuffers[i]; buffer = sortedBuffers[i];
if (buffer.unread > 0) { if (buffer.unread > 0 && !buffer.hidden) {
$scope.setActiveBuffer(buffer.id); $scope.setActiveBuffer(buffer.id);
return; return;
} }
@ -819,12 +819,18 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout',
// direction is +1 for next buffer, -1 for previous buffer // direction is +1 for next buffer, -1 for previous buffer
var sortedBuffers = _.sortBy($scope.getBuffers(), $rootScope.predicate); var sortedBuffers = _.sortBy($scope.getBuffers(), $rootScope.predicate);
var activeBuffer = models.getActiveBuffer(); var activeBuffer = models.getActiveBuffer();
var index = sortedBuffers.indexOf(activeBuffer); var index = sortedBuffers.indexOf(activeBuffer) + direction;
if (index >= 0) { var newBuffer;
var newBuffer = sortedBuffers[index + direction];
if (newBuffer) { // look for next non-hidden buffer
$scope.setActiveBuffer(newBuffer.id); while (index >= 0 && index < sortedBuffers.length &&
} (!newBuffer || newBuffer.hidden)) {
newBuffer = sortedBuffers[index];
index += direction;
}
if (!!newBuffer) {
$scope.setActiveBuffer(newBuffer.id);
} }
}; };