From 64b266b960a25a03af40ff0235d7a98d773098f9 Mon Sep 17 00:00:00 2001 From: Kosta Harlan Date: Wed, 27 Jun 2018 16:58:22 -0400 Subject: [PATCH] RC Filters: Don't apply/clear highlighting while still initializing this.controller.isInitialized() is still false on page load, we don't want to clear/apply highlights at this stage. Remove Controller's this.initializing in favor of this.initialized, expose it through isInitialized(), and remove ChangesListWrapperWidget's this.filterModelInitialized since it's now unused. Bug: T198359 Change-Id: I284ded2c6dd891dfb3efab5c6800c26a806ce306 --- .../mw.rcfilters.Controller.js | 22 +++++++++---------- ...w.rcfilters.ui.ChangesListWrapperWidget.js | 15 ++++--------- 2 files changed, 14 insertions(+), 23 deletions(-) diff --git a/resources/src/mediawiki.rcfilters/mw.rcfilters.Controller.js b/resources/src/mediawiki.rcfilters/mw.rcfilters.Controller.js index 3e900f0dc5..52438ca42b 100644 --- a/resources/src/mediawiki.rcfilters/mw.rcfilters.Controller.js +++ b/resources/src/mediawiki.rcfilters/mw.rcfilters.Controller.js @@ -34,7 +34,7 @@ this.requestCounter = {}; this.baseFilterState = {}; this.uriProcessor = null; - this.initializing = false; + this.initialized = false; this.wereSavedQueriesSaved = false; this.prevLoggedItems = []; @@ -243,16 +243,6 @@ } } - // Check whether we need to load defaults. - // We do this by checking whether the current URI query - // contains any parameters recognized by the system. - // If it does, we load the given state. - // If it doesn't, we have no values at all, and we assume - // the user loads the base-page and we load defaults. - // Defaults should only be applied on load (if necessary) - // or on request - this.initializing = true; - if ( defaultSavedQueryExists ) { // This came from the server, meaning that we have a default // saved query, but the server could not load it, probably because @@ -279,7 +269,7 @@ ); } - this.initializing = false; + this.initialized = true; this.switchView( 'default' ); this.pollingRate = mw.config.get( 'StructuredChangeFiltersLiveUpdatePollingRate' ); @@ -288,6 +278,14 @@ } }; + /** + * Check if the controller has finished initializing. + * @return {boolean} Controller is initialized + */ + mw.rcfilters.Controller.prototype.isInitialized = function () { + return this.initialized; + }; + /** * Extracts information from the changes list DOM * diff --git a/resources/src/mediawiki.rcfilters/ui/mw.rcfilters.ui.ChangesListWrapperWidget.js b/resources/src/mediawiki.rcfilters/ui/mw.rcfilters.ui.ChangesListWrapperWidget.js index 94b25053f9..3a83eeca5e 100644 --- a/resources/src/mediawiki.rcfilters/ui/mw.rcfilters.ui.ChangesListWrapperWidget.js +++ b/resources/src/mediawiki.rcfilters/ui/mw.rcfilters.ui.ChangesListWrapperWidget.js @@ -29,13 +29,11 @@ this.changesListViewModel = changesListViewModel; this.controller = controller; this.highlightClasses = null; - this.filtersModelInitialized = false; // Events this.filtersViewModel.connect( this, { itemUpdate: 'onItemUpdate', - highlightChange: 'onHighlightChange', - initialize: 'onFiltersModelInitialize' + highlightChange: 'onHighlightChange' } ); this.changesListViewModel.connect( this, { invalidate: 'onModelInvalidate', @@ -54,13 +52,6 @@ OO.inheritClass( mw.rcfilters.ui.ChangesListWrapperWidget, OO.ui.Widget ); - /** - * Respond to filters model initialize event - */ - mw.rcfilters.ui.ChangesListWrapperWidget.prototype.onFiltersModelInitialize = function () { - this.filtersModelInitialized = true; - }; - /** * Get all available highlight classes * @@ -94,7 +85,9 @@ * Respond to a filter item model update */ mw.rcfilters.ui.ChangesListWrapperWidget.prototype.onItemUpdate = function () { - if ( this.filtersModelInitialized && this.filtersViewModel.isHighlightEnabled() ) { + if ( this.controller.isInitialized() && this.filtersViewModel.isHighlightEnabled() ) { + // this.controller.isInitialized() is still false during page load, + // we don't want to clear/apply highlights at this stage. this.clearHighlight(); this.applyHighlight(); } -- 2.20.1