From 828999e3226359c3815b07d4a31451982bd436eb Mon Sep 17 00:00:00 2001 From: mpl Date: Mon, 17 Mar 2014 16:44:14 +0100 Subject: [PATCH] UI: reset search session data if empty result. http://camlistore.org/issue/352 Change-Id: I085c744a8ca31c4420f8132c897305c548b0483e --- server/camlistored/ui/blob_item_container_react.js | 3 --- server/camlistored/ui/search_session.js | 7 +++++++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/server/camlistored/ui/blob_item_container_react.js b/server/camlistored/ui/blob_item_container_react.js index 2df1d1a08..6e8400bf3 100644 --- a/server/camlistored/ui/blob_item_container_react.js +++ b/server/camlistored/ui/blob_item_container_react.js @@ -138,9 +138,6 @@ cam.BlobItemContainerReact = React.createClass({ this.childProps_ = []; var results = this.props.searchSession.getCurrentResults(); - if (!results || !results.blobs || results.blobs.length == 0) { - return; - } var data = goog.array.map(results.blobs, function(blob) { return new cam.BlobItemReactData(blob.blob, results.description.meta); }); diff --git a/server/camlistored/ui/search_session.js b/server/camlistored/ui/search_session.js index a8be4270f..602cec7ed 100644 --- a/server/camlistored/ui/search_session.js +++ b/server/camlistored/ui/search_session.js @@ -76,6 +76,10 @@ cam.SearchSession.prototype.getQuery = function() { } // Returns all the data we currently have loaded. +// It is guaranteed to return the following properties: +// blobs // non-zero length +// description +// description.meta cam.SearchSession.prototype.getCurrentResults = function() { return this.data_; }; @@ -154,6 +158,9 @@ cam.SearchSession.prototype.searchDone_ = function(changeType, result) { this.data_.blobs = result.blobs; this.data_.description = result.description; } + if (!this.data_.blobs || this.data_.blobs.length == 0) { + this.resetData_(); + } if (result.continue) { this.continuation_ = this.getContinuation_(this.constructor.SEARCH_SESSION_CHANGE_TYPE.APPEND, result.continue);