From d4b4194ed0fe8165976a4b2053e28db624c8485f Mon Sep 17 00:00:00 2001 From: mpl Date: Tue, 28 Jan 2014 00:13:51 +0100 Subject: [PATCH] ui: check for non nil results before using them http://camlistore.org/issue/352 Change-Id: I321d2bf2a48eed9aa0b9b4f5bf5d630d3741af97 --- server/camlistored/ui/blob_item_container_react.js | 3 +++ server/camlistored/ui/search_session.js | 6 +++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/server/camlistored/ui/blob_item_container_react.js b/server/camlistored/ui/blob_item_container_react.js index e5c1ef1ab..32763ac8d 100644 --- a/server/camlistored/ui/blob_item_container_react.js +++ b/server/camlistored/ui/blob_item_container_react.js @@ -136,6 +136,9 @@ 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 fdd47446e..a8be4270f 100644 --- a/server/camlistored/ui/search_session.js +++ b/server/camlistored/ui/search_session.js @@ -178,7 +178,11 @@ cam.SearchSession.prototype.startSocketQuery_ = function() { this.socket_.close(); } - var query = this.connection_.buildQuery(this.query_, this.constructor.DESCRIBE_REQUEST, Math.max(this.data_.blobs.length, this.constructor.PAGE_SIZE_)); + var numResults = 0; + if (this.data_ && this.data_.blobs) { + numResults = this.data_.blobs.length; + } + var query = this.connection_.buildQuery(this.query_, this.constructor.DESCRIBE_REQUEST, Math.max(numResults, this.constructor.PAGE_SIZE_)); this.socket_ = new WebSocket(this.socketUri_.toString()); this.socket_.onopen = function() {