Fetch more lines on request
This commit is contained in:
parent
0d7224b607
commit
32bcb1c943
|
@ -282,6 +282,12 @@ $ openssl req -nodes -newkey rsa:2048 -keyout relay.pem -x509 -days 365 -out rel
|
|||
</ul>
|
||||
</div>
|
||||
<table ng-class="{'notimestamp':notimestamp}">
|
||||
<tbody>
|
||||
<tr class="bufferline">
|
||||
<a class="fetchmorelines" ng-click="fetchMoreLines()" ng-hide="loadingLines">Fetch more lines</a>
|
||||
<span ng-show="loadingLines">Fetching more lines...</span>
|
||||
</tr>
|
||||
</tbody>
|
||||
<tbody ng-repeat="bufferline in (bufferlines = activeBuffer().lines)">
|
||||
<tr class="bufferline">
|
||||
<td class="time">
|
||||
|
|
|
@ -24,9 +24,10 @@ weechat.factory('handlers', ['$rootScope', 'models', 'plugins', function($rootSc
|
|||
|
||||
var handleLine = function(line, initial) {
|
||||
var message = new models.BufferLine(line);
|
||||
var buffer = models.getBuffer(message.buffer);
|
||||
buffer.requestedLines++;
|
||||
// Only react to line if its displayed
|
||||
if (message.displayed) {
|
||||
var buffer = models.getBuffer(message.buffer);
|
||||
message = plugins.PluginManager.contentForMessage(message, $rootScope.visible);
|
||||
buffer.addLine(message);
|
||||
|
||||
|
@ -88,10 +89,11 @@ weechat.factory('handlers', ['$rootScope', 'models', 'plugins', function($rootSc
|
|||
*
|
||||
* (lineinfo) messages are specified by this client. It is request after bufinfo completes
|
||||
*/
|
||||
var handleLineInfo = function(message) {
|
||||
var handleLineInfo = function(message, initial) {
|
||||
var lines = message.objects[0].content.reverse();
|
||||
if (initial === undefined) initial = true;
|
||||
lines.forEach(function(l) {
|
||||
handleLine(l, true);
|
||||
handleLine(l, initial);
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -381,13 +383,37 @@ function($rootScope,
|
|||
}));
|
||||
};
|
||||
|
||||
var getMoreLines = function(numLines) {
|
||||
var buffer = models.getActiveBuffer();
|
||||
if (numLines === undefined) {
|
||||
var numLines = Math.max(40, buffer.requestedLines * 2);
|
||||
}
|
||||
|
||||
$rootScope.loadingLines = true;
|
||||
ngWebsockets.send(
|
||||
weeChat.Protocol.formatHdata({
|
||||
path: "buffer:0x" + buffer.id + "/own_lines/last_line(-" + numLines + ")/data",
|
||||
keys: []
|
||||
})
|
||||
).then(function(lineinfo) {
|
||||
// delete old lines and add new ones
|
||||
var oldLength = buffer.lines.length;
|
||||
buffer.lines.length = 0;
|
||||
buffer.requestedLines = 0;
|
||||
handlers.handleLineInfo(lineinfo, false);
|
||||
buffer.lastSeen = buffer.lines.length - oldLength - 1;
|
||||
$rootScope.loadingLines = false;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
return {
|
||||
// send: send,
|
||||
connect: connect,
|
||||
disconnect: disconnect,
|
||||
sendMessage: sendMessage,
|
||||
sendCoreCommand: sendCoreCommand
|
||||
sendCoreCommand: sendCoreCommand,
|
||||
getMoreLines: getMoreLines
|
||||
};
|
||||
}]);
|
||||
|
||||
|
@ -562,6 +588,11 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout',
|
|||
}
|
||||
};
|
||||
|
||||
$rootScope.loadingLines = false;
|
||||
$scope.fetchMoreLines = function(numLines) {
|
||||
connection.getMoreLines(numLines);
|
||||
}
|
||||
|
||||
$rootScope.scrollWithBuffer = function(nonIncremental) {
|
||||
// First, get scrolling status *before* modification
|
||||
// This is required to determine where we were in the buffer pre-change
|
||||
|
|
|
@ -18,6 +18,7 @@ models.service('models', ['$rootScope', '$filter', function($rootScope, $filter)
|
|||
var local_variables = message.local_vars;
|
||||
var notify = 3; // Default 3 == message
|
||||
var lines = [];
|
||||
var requestedLines = 0;
|
||||
var nicklist = {};
|
||||
var flatnicklist = [];
|
||||
var history = [];
|
||||
|
@ -153,6 +154,7 @@ models.service('models', ['$rootScope', '$filter', function($rootScope, $filter)
|
|||
number: number,
|
||||
title: title,
|
||||
lines: lines,
|
||||
requestedLines: requestedLines,
|
||||
addLine: addLine,
|
||||
lastSeen: lastSeen,
|
||||
unread: unread,
|
||||
|
|
Loading…
Reference in New Issue