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>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<table ng-class="{'notimestamp':notimestamp}">
|
<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)">
|
<tbody ng-repeat="bufferline in (bufferlines = activeBuffer().lines)">
|
||||||
<tr class="bufferline">
|
<tr class="bufferline">
|
||||||
<td class="time">
|
<td class="time">
|
||||||
|
|
|
@ -24,9 +24,10 @@ weechat.factory('handlers', ['$rootScope', 'models', 'plugins', function($rootSc
|
||||||
|
|
||||||
var handleLine = function(line, initial) {
|
var handleLine = function(line, initial) {
|
||||||
var message = new models.BufferLine(line);
|
var message = new models.BufferLine(line);
|
||||||
|
var buffer = models.getBuffer(message.buffer);
|
||||||
|
buffer.requestedLines++;
|
||||||
// Only react to line if its displayed
|
// Only react to line if its displayed
|
||||||
if (message.displayed) {
|
if (message.displayed) {
|
||||||
var buffer = models.getBuffer(message.buffer);
|
|
||||||
message = plugins.PluginManager.contentForMessage(message, $rootScope.visible);
|
message = plugins.PluginManager.contentForMessage(message, $rootScope.visible);
|
||||||
buffer.addLine(message);
|
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
|
* (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();
|
var lines = message.objects[0].content.reverse();
|
||||||
|
if (initial === undefined) initial = true;
|
||||||
lines.forEach(function(l) {
|
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 {
|
return {
|
||||||
// send: send,
|
// send: send,
|
||||||
connect: connect,
|
connect: connect,
|
||||||
disconnect: disconnect,
|
disconnect: disconnect,
|
||||||
sendMessage: sendMessage,
|
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) {
|
$rootScope.scrollWithBuffer = function(nonIncremental) {
|
||||||
// First, get scrolling status *before* modification
|
// First, get scrolling status *before* modification
|
||||||
// This is required to determine where we were in the buffer pre-change
|
// 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 local_variables = message.local_vars;
|
||||||
var notify = 3; // Default 3 == message
|
var notify = 3; // Default 3 == message
|
||||||
var lines = [];
|
var lines = [];
|
||||||
|
var requestedLines = 0;
|
||||||
var nicklist = {};
|
var nicklist = {};
|
||||||
var flatnicklist = [];
|
var flatnicklist = [];
|
||||||
var history = [];
|
var history = [];
|
||||||
|
@ -153,6 +154,7 @@ models.service('models', ['$rootScope', '$filter', function($rootScope, $filter)
|
||||||
number: number,
|
number: number,
|
||||||
title: title,
|
title: title,
|
||||||
lines: lines,
|
lines: lines,
|
||||||
|
requestedLines: requestedLines,
|
||||||
addLine: addLine,
|
addLine: addLine,
|
||||||
lastSeen: lastSeen,
|
lastSeen: lastSeen,
|
||||||
unread: unread,
|
unread: unread,
|
||||||
|
|
Loading…
Reference in New Issue