Merge pull request #344 from glowing-bear/fixlinetrimming
Don't trim unread lines
This commit is contained in:
commit
a105466b33
1 changed files with 10 additions and 5 deletions
|
@ -87,7 +87,7 @@ weechat.factory('handlers', ['$rootScope', '$log', 'models', 'plugins', function
|
||||||
var buffer = new models.Buffer(bufferMessage);
|
var buffer = new models.Buffer(bufferMessage);
|
||||||
models.addBuffer(buffer);
|
models.addBuffer(buffer);
|
||||||
/* Until we can decide if user asked for this buffer to be opened
|
/* Until we can decide if user asked for this buffer to be opened
|
||||||
* or not we will let user click opened buffers.
|
* or not we will let user click opened buffers.
|
||||||
models.setActiveBuffer(buffer.id);
|
models.setActiveBuffer(buffer.id);
|
||||||
*/
|
*/
|
||||||
};
|
};
|
||||||
|
@ -699,9 +699,14 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout',
|
||||||
$rootScope.$on('activeBufferChanged', function(event, unreadSum) {
|
$rootScope.$on('activeBufferChanged', function(event, unreadSum) {
|
||||||
var ab = models.getActiveBuffer();
|
var ab = models.getActiveBuffer();
|
||||||
|
|
||||||
// trim lines to 2 screenfuls + 10 lines
|
// Discard surplus lines. This is done *before* lines are fetched because that saves us the effort of special handling for the
|
||||||
ab.lines.splice(0, ab.lines.length - (2 * $scope.lines_per_screen + 10));
|
// case where a buffer is opened for the first time ;)
|
||||||
ab.requestedLines = ab.lines.length;
|
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 linesToRemove = Math.max(0, Math.min(minRetainUnread, surplusLines));
|
||||||
|
ab.lines.splice(0, linesToRemove); // remove the lines from the buffer
|
||||||
|
ab.requestedLines = ab.lines.length; // to ensure that the correct amount of lines is fetched should more be requested
|
||||||
|
ab.lastSeen -= linesToRemove; // adjust readmarker
|
||||||
|
|
||||||
$scope.bufferlines = ab.lines;
|
$scope.bufferlines = ab.lines;
|
||||||
$scope.nicklist = ab.nicklist;
|
$scope.nicklist = ab.nicklist;
|
||||||
|
@ -1237,7 +1242,7 @@ weechat.directive('inputBar', function() {
|
||||||
return {
|
return {
|
||||||
|
|
||||||
templateUrl: 'directives/input.html',
|
templateUrl: 'directives/input.html',
|
||||||
|
|
||||||
scope: {
|
scope: {
|
||||||
inputId: '@inputId'
|
inputId: '@inputId'
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue