From ad68e32c0826031bf6297b05c57fd4d3e92794b1 Mon Sep 17 00:00:00 2001 From: Tor Hveem Date: Fri, 28 Feb 2014 00:55:34 +0100 Subject: [PATCH] Don't show fetch more lines when there aren't any --- index.html | 4 +--- js/glowingbear.js | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/index.html b/index.html index b2820e1..31c4a5d 100644 --- a/index.html +++ b/index.html @@ -232,9 +232,7 @@ $ openssl req -nodes -newkey rsa:4096 -keyout relay.pem -x509 -days 365 -out rel - - - diff --git a/js/glowingbear.js b/js/glowingbear.js index c42d9e5..7e29bfb 100644 --- a/js/glowingbear.js +++ b/js/glowingbear.js @@ -432,6 +432,10 @@ function($rootScope, var setReadmarker = (buffer.lastSeen >= 0); buffer.lines.length = 0; buffer.requestedLines = 0; + // Count number of lines recieved + var newLength = lineinfo.objects[0].content.length; + + // Parse the lines handlers.handleLineInfo(lineinfo, true); if (setReadmarker) { @@ -444,7 +448,14 @@ function($rootScope, // the read marker position correct buffer.lastSeen -= oldLength; } - + // We request more lines, but didn't get more. No more lines! + if(oldLength === newLength) { + $rootScope.noMoreLines = true; + } + // We requested more lines than we got, no more lines. + if(newLength < numLines) { + $rootScope.noMoreLines = true; + } $rootScope.loadingLines = false; // Scroll read marker to the center of the screen $rootScope.scrollWithBuffer(true); @@ -583,6 +594,9 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout', $rootScope.$on('activeBufferChanged', function() { $rootScope.scrollWithBuffer(true); + // Reset no more lines + $rootScope.noMoreLines = false; + var ab = models.getActiveBuffer(); if (ab.requestedLines < $scope.lines) { // buffer has not been loaded, but some lines may already be present if they arrived after we connected
+ Fetch more lines Fetching more lines...