RCFilters: Make live update polling configurable
authorStephane Bisson <sbisson@wikimedia.org>
Thu, 21 Sep 2017 20:43:23 +0000 (16:43 -0400)
committerStephane Bisson <sbisson@wikimedia.org>
Fri, 22 Sep 2017 17:22:40 +0000 (13:22 -0400)
Introducing $wgStructuredChangeFiltersLiveUpdatePollingRate
to configure the polling rate for live update.

Allows disabling polling completely by setting it to 0.

Change-Id: I13d3a4bb642c55a16e442f8f8d650c637f13f72c

includes/DefaultSettings.php
includes/specialpage/ChangesListSpecialPage.php
resources/src/mediawiki.rcfilters/mw.rcfilters.Controller.js
resources/src/mediawiki.rcfilters/mw.rcfilters.js

index cdb7ce8..3ca8d8c 100644 (file)
@@ -6864,6 +6864,13 @@ $wgStructuredChangeFiltersEnableExperimentalViews = false;
  */
 $wgStructuredChangeFiltersOnWatchlist = false;
 
+/**
+ * Polling rate, in seconds, used by the 'live update' and 'view newest' features
+ * of the RCFilters app on SpecialRecentChanges and Special:Watchlist.
+ * 0 to disable completely.
+ */
+$wgStructuredChangeFiltersLiveUpdatePollingRate = 3;
+
 /**
  * Use new page patrolling to check new pages on Special:Newpages
  */
index dd0dd92..6415b2c 100644 (file)
@@ -624,6 +624,11 @@ abstract class ChangesListSpecialPage extends SpecialPage {
                                ]
                        );
 
+                       $out->addJsConfigVars(
+                               'StructuredChangeFiltersLiveUpdatePollingRate',
+                               $this->getConfig()->get( 'StructuredChangeFiltersLiveUpdatePollingRate' )
+                       );
+
                        if ( static::$savedQueriesPreferenceName ) {
                                $savedQueries = FormatJson::decode(
                                        $this->getUser()->getOption( static::$savedQueriesPreferenceName )
index 507c979..ed2a73f 100644 (file)
                this.initializing = false;
                this.switchView( 'default' );
 
-               this._scheduleLiveUpdate();
+               this.pollingRate = mw.config.get( 'StructuredChangeFiltersLiveUpdatePollingRate' );
+               if ( this.pollingRate ) {
+                       this._scheduleLiveUpdate();
+               }
        };
 
        /**
         * @private
         */
        mw.rcfilters.Controller.prototype._scheduleLiveUpdate = function () {
-               setTimeout( this._doLiveUpdate.bind( this ), 3000 );
+               setTimeout( this._doLiveUpdate.bind( this ), this.pollingRate * 1000 );
        };
 
        /**
index d203328..e28f34a 100644 (file)
@@ -46,7 +46,7 @@
                        }
                },
                featureFlags: {
-                       liveUpdate: mw.config.get( 'wgStructuredChangeFiltersLiveUpdateSupported' ) &&
+                       liveUpdate: mw.config.get( 'StructuredChangeFiltersLiveUpdatePollingRate' ) &&
                                ( mw.user.options.get( 'rcenhancedfilters' ) || new mw.Uri().query.liveupdate )
                }
        };