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> </label>
</div> </div>
</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> <button class="btn btn-lg btn-primary" ng-click="connect()">Connect <i class="glyphicon glyphicon-chevron-right"></i></button>
</form> </form>
</div> </div>
@ -250,6 +245,16 @@ $ openssl req -nodes -newkey rsa:2048 -keyout relay.pem -x509 -days 365 -out rel
</div> </div>
</form> </form>
</li> </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> </ul>
</div> </div>
<a ng-click="disconnect()" title="Disconnect from WeeChat"> <a ng-click="disconnect()" title="Disconnect from WeeChat">

View file

@ -286,16 +286,6 @@ function($rootScope,
}); });
// Send all the other commands required for initialization // 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( ngWebsockets.send(
weeChat.Protocol.formatHdata({ weeChat.Protocol.formatHdata({
path: "hotlist:gui_hotlist(*)", path: "hotlist:gui_hotlist(*)",
@ -384,11 +374,9 @@ function($rootScope,
})); }));
}; };
var getMoreLines = function(numLines) { var fetchMoreLines = function(numLines) {
var buffer = models.getActiveBuffer(); var buffer = models.getActiveBuffer();
if (numLines === undefined) { numLines = Math.max(numLines, buffer.requestedLines * 2);
var numLines = Math.max(40, buffer.requestedLines * 2);
}
$rootScope.loadingLines = true; $rootScope.loadingLines = true;
ngWebsockets.send( ngWebsockets.send(
@ -415,7 +403,7 @@ function($rootScope,
disconnect: disconnect, disconnect: disconnect,
sendMessage: sendMessage, sendMessage: sendMessage,
sendCoreCommand: sendCoreCommand, sendCoreCommand: sendCoreCommand,
getMoreLines: getMoreLines fetchMoreLines: fetchMoreLines
}; };
}]); }]);
@ -476,6 +464,11 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout',
$rootScope.scrollWithBuffer(true); $rootScope.scrollWithBuffer(true);
var ab = models.getActiveBuffer(); 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; $rootScope.pageTitle = ab.shortName + ' | ' + ab.title;
// If user wants to sync hotlist with weechat // If user wants to sync hotlist with weechat
@ -591,8 +584,8 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout',
}; };
$rootScope.loadingLines = false; $rootScope.loadingLines = false;
$scope.fetchMoreLines = function(numLines) { $scope.fetchMoreLines = function() {
connection.getMoreLines(numLines); connection.fetchMoreLines($scope.lines);
} }
$rootScope.scrollWithBuffer = function(nonIncremental) { $rootScope.scrollWithBuffer = function(nonIncremental) {