From 0a5c5376492b1b7234178e945d4796c59cb9cc94 Mon Sep 17 00:00:00 2001 From: Tim Hostetler Date: Tue, 17 Nov 2020 15:47:54 -0500 Subject: [PATCH] Stop sending extra empty search request Requests for citation_count being sent even if not sorting by citations, this will now stop those requests --- src/js/widgets/search_bar/search_bar_widget.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/js/widgets/search_bar/search_bar_widget.js b/src/js/widgets/search_bar/search_bar_widget.js index d1fb520d5..1fc39e4a4 100644 --- a/src/js/widgets/search_bar/search_bar_widget.js +++ b/src/js/widgets/search_bar/search_bar_widget.js @@ -863,20 +863,22 @@ define([ dispatchRequest: function(apiQuery) { var sort = apiQuery.get('sort'); - var da = this.defaultQueryArguments; if (/citation_count_norm/i.test(sort)) { - da = _.extend(da, { + this.defaultQueryArguments = _.extend(this.defaultQueryArguments, { stats: 'true', 'stats.field': 'citation_count_norm', }); } else if (/citation_count/i.test(sort)) { - da = _.extend(da, { + this.defaultQueryArguments = _.extend(this.defaultQueryArguments, { stats: 'true', 'stats.field': 'citation_count', }); } else { this.model.unset('citationCount'); this.model.unset('citationLabel'); + + // don't bother sending request + return; } BaseWidget.prototype.dispatchRequest.call(this, apiQuery); },