Merge pull request #224 from lorenzhs/fetchall
Try to fetch all unread lines if that is a reasonable amount
This commit is contained in:
commit
e74d5dd270
2 changed files with 18 additions and 5 deletions
|
@ -645,12 +645,20 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout',
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
$rootScope.$on('activeBufferChanged', function() {
|
|
||||||
|
$rootScope.$on('activeBufferChanged', function(event, unreadSum) {
|
||||||
var ab = models.getActiveBuffer();
|
var ab = models.getActiveBuffer();
|
||||||
|
|
||||||
if (ab.requestedLines < $scope.lines) {
|
if (ab.requestedLines < $scope.lines) {
|
||||||
// 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
|
||||||
$scope.fetchMoreLines($scope.lines);
|
// try to determine how many lines to fetch
|
||||||
|
var numLines = $scope.lines; // that's a screenful plus 10 lines
|
||||||
|
unreadSum += 10; // let's just add a 10 line safety margin here again
|
||||||
|
if (unreadSum > numLines) {
|
||||||
|
// request up to 4*(screenful + 10 lines)
|
||||||
|
numLines = Math.min(4*numLines, unreadSum);
|
||||||
|
}
|
||||||
|
$scope.fetchMoreLines(numLines);
|
||||||
}
|
}
|
||||||
$rootScope.updateTitle(ab);
|
$rootScope.updateTitle(ab);
|
||||||
|
|
||||||
|
@ -847,8 +855,11 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout',
|
||||||
|
|
||||||
|
|
||||||
$rootScope.loadingLines = false;
|
$rootScope.loadingLines = false;
|
||||||
$scope.fetchMoreLines = function() {
|
$scope.fetchMoreLines = function(numLines) {
|
||||||
connection.fetchMoreLines($scope.lines);
|
if (!numLines) {
|
||||||
|
numLines = $scope.lines;
|
||||||
|
}
|
||||||
|
connection.fetchMoreLines(numLines);
|
||||||
};
|
};
|
||||||
|
|
||||||
$rootScope.scrollWithBuffer = function(nonIncremental) {
|
$rootScope.scrollWithBuffer = function(nonIncremental) {
|
||||||
|
|
|
@ -419,11 +419,13 @@ models.service('models', ['$rootScope', '$filter', function($rootScope, $filter)
|
||||||
previousBuffer.lastSeen = previousBuffer.lines.length-1;
|
previousBuffer.lastSeen = previousBuffer.lines.length-1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var unreadSum = activeBuffer.unread + activeBuffer.notification;
|
||||||
|
|
||||||
activeBuffer.active = true;
|
activeBuffer.active = true;
|
||||||
activeBuffer.unread = 0;
|
activeBuffer.unread = 0;
|
||||||
activeBuffer.notification = 0;
|
activeBuffer.notification = 0;
|
||||||
|
|
||||||
$rootScope.$emit('activeBufferChanged');
|
$rootScope.$emit('activeBufferChanged', unreadSum);
|
||||||
$rootScope.$emit('notificationChanged');
|
$rootScope.$emit('notificationChanged');
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue