From 279816cfda2a7e33543ae97fd00bcc30273690d8 Mon Sep 17 00:00:00 2001 From: Moriel Schottlender Date: Tue, 1 Aug 2017 16:02:44 -0700 Subject: [PATCH] RCFilters: Don't reload results for redundant requests Ignore reloading if the requests are: - Change of inverted namespaces if there are no namespace items selected. - Reloading of new saved query if that same query is already loaded Bug: T172138 Change-Id: Id43bef8a08aab3412a6c5cb538d048935a178114 --- .../mw.rcfilters.Controller.js | 25 ++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/resources/src/mediawiki.rcfilters/mw.rcfilters.Controller.js b/resources/src/mediawiki.rcfilters/mw.rcfilters.Controller.js index 9d2c3318ac..fbd44fd414 100644 --- a/resources/src/mediawiki.rcfilters/mw.rcfilters.Controller.js +++ b/resources/src/mediawiki.rcfilters/mw.rcfilters.Controller.js @@ -399,7 +399,17 @@ */ mw.rcfilters.Controller.prototype.toggleInvertedNamespaces = function () { this.filtersModel.toggleInvertedNamespaces(); - this.updateChangesList(); + + if ( + this.filtersModel.getFiltersByView( 'namespaces' ) + .filter( function ( filterItem ) { + return filterItem.isSelected(); + } ) + .length + ) { + // Only re-fetch results if there are namespace items that are actually selected + this.updateChangesList(); + } }; /** @@ -601,9 +611,18 @@ */ mw.rcfilters.Controller.prototype.applySavedQuery = function ( queryID ) { var data, highlights, - queryItem = this.savedQueriesModel.getItemByID( queryID ); + queryItem = this.savedQueriesModel.getItemByID( queryID ), + currentMatchingQuery = this.findQueryMatchingCurrentState(); - if ( queryItem ) { + if ( + queryItem && + ( + // If there's already a query, don't reload it + // if it's the same as the one that already exists + !currentMatchingQuery || + currentMatchingQuery.getID() !== queryItem.getID() + ) + ) { data = queryItem.getData(); highlights = data.highlights; -- 2.20.1