Merge "ui: check for non nil results before using them"

This commit is contained in:
Brad Fitzpatrick 2014-01-28 00:38:38 +00:00 committed by Gerrit Code Review
commit 52a68b9c30
2 changed files with 8 additions and 1 deletions

View File

@ -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);
});

View File

@ -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() {