From d9316ff8ddd1bb2c70474bb0cdd5872d2a7bf651 Mon Sep 17 00:00:00 2001 From: Aaron Boodman Date: Fri, 7 Nov 2014 23:44:39 -0800 Subject: [PATCH] Fix bug where 'no results' message sometimes showed momentarily. SearchSession::isComplete() could sometimes return the wrong answer. Nulling out the continuation is needed to make loadMoreResults() idempotent. So had to add more state to SearchSession specifically for tracking completeness. Change-Id: Ic2a90c73f3a764f358476cffa6d498ea53103421 --- server/camlistored/ui/search_session.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/server/camlistored/ui/search_session.js b/server/camlistored/ui/search_session.js index fed0f42f7..cacc22e83 100644 --- a/server/camlistored/ui/search_session.js +++ b/server/camlistored/ui/search_session.js @@ -42,6 +42,7 @@ cam.SearchSession = function(connection, currentUri, query) { this.continuation_ = this.getContinuation_(this.constructor.SEARCH_SESSION_CHANGE_TYPE.NEW); this.socket_ = null; this.supportsWebSocket_ = false; + this.isComplete_ = false; this.resetData_(); }; @@ -97,7 +98,7 @@ cam.SearchSession.prototype.loadMoreResults = function() { // Returns true if it is known that all data which can be loaded for this query has been. cam.SearchSession.prototype.isComplete = function() { - return !this.continuation_; + return this.isComplete_; } cam.SearchSession.prototype.supportsChangeNotifications = function() { @@ -207,6 +208,7 @@ cam.SearchSession.prototype.searchDone_ = function(changeType, result) { this.continuation_ = this.getContinuation_(this.constructor.SEARCH_SESSION_CHANGE_TYPE.APPEND, result.continue); } else { this.continuation_ = null; + this.isComplete_ = true; } if (changes) {