Merge pull request #442 from glowing-bear/fix-line-fetching-after-switch
Re-enable "fetch more lines" after trimming lines on buffer switch
This commit is contained in:
commit
8758cad336
1 changed files with 8 additions and 4 deletions
|
@ -108,10 +108,14 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout',
|
||||||
// case where a buffer is opened for the first time ;)
|
// case where a buffer is opened for the first time ;)
|
||||||
var minRetainUnread = ab.lines.length - unreadSum + 5; // do not discard unread lines and keep 5 additional lines for context
|
var minRetainUnread = ab.lines.length - unreadSum + 5; // do not discard unread lines and keep 5 additional lines for context
|
||||||
var surplusLines = ab.lines.length - (2 * $scope.lines_per_screen + 10); // retain up to 2*(screenful + 10) + 10 lines because magic numbers
|
var surplusLines = ab.lines.length - (2 * $scope.lines_per_screen + 10); // retain up to 2*(screenful + 10) + 10 lines because magic numbers
|
||||||
var linesToRemove = Math.max(0, Math.min(minRetainUnread, surplusLines));
|
var linesToRemove = Math.min(minRetainUnread, surplusLines);
|
||||||
|
|
||||||
|
if (linesToRemove > 0) {
|
||||||
ab.lines.splice(0, linesToRemove); // remove the lines from the buffer
|
ab.lines.splice(0, linesToRemove); // remove the lines from the buffer
|
||||||
ab.requestedLines -= linesToRemove; // to ensure that the correct amount of lines is fetched should more be requested
|
ab.requestedLines -= linesToRemove; // to ensure that the correct amount of lines is fetched should more be requested
|
||||||
ab.lastSeen -= linesToRemove; // adjust readmarker
|
ab.lastSeen -= linesToRemove; // adjust readmarker
|
||||||
|
ab.allLinesFetched = false; // we just removed lines, so we don't have all of them. re-enable "fetch more lines"
|
||||||
|
}
|
||||||
|
|
||||||
$scope.bufferlines = ab.lines;
|
$scope.bufferlines = ab.lines;
|
||||||
$scope.nicklist = ab.nicklist;
|
$scope.nicklist = ab.nicklist;
|
||||||
|
|
Loading…
Reference in a new issue