Dynamically load lines for each buffer on startup

Add setting for number of lines to fetch initally.

TODO: styling
This commit is contained in:
Lorenz Hübschle-Schneider 2014-02-10 18:44:15 +00:00
parent 5a90e2e830
commit 7764fc6910
2 changed files with 20 additions and 22 deletions

View File

@ -78,11 +78,6 @@
</label>
</div>
</div>
<div class="form-group">
<label class="control-label" for="port">Lines</label>
<input type="text" class="form-control monospace" id="lines" ng-model="lines" placeholder="40">
<p class="help-block">Enter number of lines to sync from WeeChat on connect</p>
</div>
<button class="btn btn-lg btn-primary" ng-click="connect()">Connect <i class="glyphicon glyphicon-chevron-right"></i></button>
</form>
</div>
@ -250,6 +245,16 @@ $ openssl req -nodes -newkey rsa:2048 -keyout relay.pem -x509 -days 365 -out rel
</div>
</form>
</li>
<li class="">
<form class="form-inline" role="form">
<div class="checkbox">
<label>
&nbsp;&nbsp;lines fetched initially
<input type="text" ng-model="lines" class="input-sm col-md-3">
</label>
</div>
</form>
</li>
</ul>
</div>
<a ng-click="disconnect()" title="Disconnect from WeeChat">

View File

@ -286,16 +286,6 @@ function($rootScope,
});
// Send all the other commands required for initialization
ngWebsockets.send(
weeChat.Protocol.formatHdata({
path: "buffer:gui_buffers(*)/own_lines/last_line(-"+storage.get('lines')+")/data",
keys: []
})
).then(function(lineinfo) {
handlers.handleLineInfo(lineinfo);
$rootScope.scrollWithBuffer(true);
});
ngWebsockets.send(
weeChat.Protocol.formatHdata({
path: "hotlist:gui_hotlist(*)",
@ -384,11 +374,9 @@ function($rootScope,
}));
};
var getMoreLines = function(numLines) {
var fetchMoreLines = function(numLines) {
var buffer = models.getActiveBuffer();
if (numLines === undefined) {
var numLines = Math.max(40, buffer.requestedLines * 2);
}
numLines = Math.max(numLines, buffer.requestedLines * 2);
$rootScope.loadingLines = true;
ngWebsockets.send(
@ -415,7 +403,7 @@ function($rootScope,
disconnect: disconnect,
sendMessage: sendMessage,
sendCoreCommand: sendCoreCommand,
getMoreLines: getMoreLines
fetchMoreLines: fetchMoreLines
};
}]);
@ -476,6 +464,11 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout',
$rootScope.scrollWithBuffer(true);
var ab = models.getActiveBuffer();
if (ab.requestedLines < $scope.lines) {
// buffer has not been loaded
// some messages may be present if they arrived after we connected
$scope.fetchMoreLines($scope.lines);
}
$rootScope.pageTitle = ab.shortName + ' | ' + ab.title;
// If user wants to sync hotlist with weechat
@ -591,8 +584,8 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout',
};
$rootScope.loadingLines = false;
$scope.fetchMoreLines = function(numLines) {
connection.getMoreLines(numLines);
$scope.fetchMoreLines = function() {
connection.fetchMoreLines($scope.lines);
}
$rootScope.scrollWithBuffer = function(nonIncremental) {