From: Moriel Schottlender Date: Thu, 12 Oct 2017 18:28:36 +0000 (-0700) Subject: RCFilters: Don't reload the list if the change was highlights-only X-Git-Tag: 1.31.0-rc.0~1570^2 X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=commitdiff_plain;h=ad7af7c7e1a53ba7656511993454b0c7d520a59d RCFilters: Don't reload the list if the change was highlights-only Bug: T164131 Change-Id: I9952467d0acef84a6445d970977c1265a3ebff95 --- diff --git a/resources/src/mediawiki.rcfilters/mw.rcfilters.Controller.js b/resources/src/mediawiki.rcfilters/mw.rcfilters.Controller.js index 0b2dd8d381..8374b4813c 100644 --- a/resources/src/mediawiki.rcfilters/mw.rcfilters.Controller.js +++ b/resources/src/mediawiki.rcfilters/mw.rcfilters.Controller.js @@ -369,9 +369,10 @@ * Reset to default filters */ mw.rcfilters.Controller.prototype.resetToDefaults = function () { - this.filtersModel.updateStateFromParams( this._getDefaultParams() ); - - this.updateChangesList(); + if ( this.applyParamChange( this._getDefaultParams() ) ) { + // Only update the changes list if there was a change to actual filters + this.updateChangesList(); + } }; /** @@ -387,13 +388,13 @@ * Empty all selected filters */ mw.rcfilters.Controller.prototype.emptyFilters = function () { - var highlightedFilterNames = this.filtersModel - .getHighlightedItems() + var highlightedFilterNames = this.filtersModel.getHighlightedItems() .map( function ( filterItem ) { return { name: filterItem.getName() }; } ); - this.filtersModel.updateStateFromParams( {} ); - - this.updateChangesList(); + if ( this.applyParamChange( {} ) ) { + // Only update the changes list if there was a change to actual filters + this.updateChangesList(); + } if ( highlightedFilterNames ) { this._trackHighlight( 'clearAll', highlightedFilterNames ); @@ -677,10 +678,10 @@ return; } - // Apply parameters to model - this.filtersModel.updateStateFromParams( params ); - - this.updateChangesList(); + if ( this.applyParamChange( params ) ) { + // Update changes list only if there was a difference in filter selection + this.updateChangesList(); + } // Log filter grouping this.trackFilterGroupings( 'savedfilters' ); @@ -1057,6 +1058,24 @@ } }; + /** + * Apply a change of parameters to the model state, and check whether + * the new state is different than the old state. + * + * @param {Object} newParamState New parameter state to apply + * @return {boolean} New applied model state is different than the previous state + */ + mw.rcfilters.Controller.prototype.applyParamChange = function ( newParamState ) { + var after, + before = this.filtersModel.getSelectedState(); + + this.filtersModel.updateStateFromParams( newParamState ); + + after = this.filtersModel.getSelectedState(); + + return !OO.compare( before, after ); + }; + /** * Mark all changes as seen on Watchlist */