From 7764fc6910bf7a6ec74f521bdc63999597775be2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lorenz=20H=C3=BCbschle-Schneider?= Date: Mon, 10 Feb 2014 18:44:15 +0000 Subject: [PATCH] Dynamically load lines for each buffer on startup Add setting for number of lines to fetch initally. TODO: styling --- index.html | 15 ++++++++++----- js/glowingbear.js | 27 ++++++++++----------------- 2 files changed, 20 insertions(+), 22 deletions(-) diff --git a/index.html b/index.html index a7d0234..fe10c2e 100644 --- a/index.html +++ b/index.html @@ -78,11 +78,6 @@ -
- - -

Enter number of lines to sync from WeeChat on connect

-
@@ -250,6 +245,16 @@ $ openssl req -nodes -newkey rsa:2048 -keyout relay.pem -x509 -days 365 -out rel +
  • +
    +
    + +
    +
    +
  • diff --git a/js/glowingbear.js b/js/glowingbear.js index 1a614db..d63dde5 100644 --- a/js/glowingbear.js +++ b/js/glowingbear.js @@ -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) {