Merge "RCFilters: Remove new changes visual cue for Live Update feature"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Thu, 3 Aug 2017 17:21:49 +0000 (17:21 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Thu, 3 Aug 2017 17:21:49 +0000 (17:21 +0000)
resources/src/mediawiki.rcfilters/dm/mw.rcfilters.dm.ChangesListViewModel.js
resources/src/mediawiki.rcfilters/mw.rcfilters.Controller.js
resources/src/mediawiki.rcfilters/ui/mw.rcfilters.ui.FormWrapperWidget.js

index 34ed2eb..f221b2b 100644 (file)
         * @param {jQuery|string} changesListContent
         * @param {jQuery} $fieldset
         * @param {boolean} [isInitialDOM] Using the initial (already attached) DOM elements
-        * @param {boolean} [fromLiveUpdate] These are new changes fetched via Live Update
+        * @param {boolean} [separateOldAndNew] Whether a logical separation between old and new changes is needed
         * @fires update
         */
-       mw.rcfilters.dm.ChangesListViewModel.prototype.update = function ( changesListContent, $fieldset, isInitialDOM, fromLiveUpdate ) {
+       mw.rcfilters.dm.ChangesListViewModel.prototype.update = function ( changesListContent, $fieldset, isInitialDOM, separateOldAndNew ) {
                var from = this.nextFrom;
                this.valid = true;
                this.extractNextFrom( $fieldset );
-               this.emit( 'update', changesListContent, $fieldset, isInitialDOM, fromLiveUpdate ? from : null );
+               this.emit( 'update', changesListContent, $fieldset, isInitialDOM, separateOldAndNew ? from : null );
        };
 
        /**
index 30bec87..e9981bd 100644 (file)
                this.initializing = false;
 
                this.prevLoggedItems = [];
+
+               this.FILTER_CHANGE = 'filterChange';
+               this.SHOW_NEW_CHANGES = 'showNewChanges';
+               this.LIVE_UPDATE = 'liveUpdate';
        };
 
        /* Initialization */
        mw.rcfilters.Controller.prototype.toggleLiveUpdate = function ( enable ) {
                this.changesListModel.toggleLiveUpdate( enable );
                if ( this.changesListModel.getLiveUpdate() && this.changesListModel.getNewChangesExist() ) {
-                       this.showNewChanges();
+                       this.updateChangesList( null, this.LIVE_UPDATE );
                }
        };
 
 
                                if ( data.changes !== 'NO_RESULTS' ) {
                                        if ( this.changesListModel.getLiveUpdate() ) {
-                                               return this.updateChangesList( false, null, true, false );
+                                               return this.updateChangesList( null, this.LIVE_UPDATE );
                                        } else {
                                                this.changesListModel.setNewChangesExist( true );
                                        }
         * fetching and showing the new changes
         */
        mw.rcfilters.Controller.prototype.showNewChanges = function () {
-               return this.updateChangesList( false, null, true, true );
+               return this.updateChangesList( null, this.SHOW_NEW_CHANGES );
        };
 
        /**
        /**
         * Update the list of changes and notify the model
         *
-        * @param {boolean} [updateUrl=true] Whether the URL should be updated with the current state of the filters
         * @param {Object} [params] Extra parameters to add to the API call
-        * @param {boolean} [isLiveUpdate=false] The purpose of this update is to show new results for the same filters
-        * @param {boolean} [invalidateCurrentChanges=true] Invalidate current changes by default (show spinner)
+        * @param {string} [updateMode='filterChange'] One of 'filterChange', 'liveUpdate', 'showNewChanges'
         * @return {jQuery.Promise} Promise that is resolved when the update is complete
         */
-       mw.rcfilters.Controller.prototype.updateChangesList = function ( updateUrl, params, isLiveUpdate, invalidateCurrentChanges ) {
-               updateUrl = updateUrl === undefined ? true : updateUrl;
-               invalidateCurrentChanges = invalidateCurrentChanges === undefined ? true : invalidateCurrentChanges;
-               if ( updateUrl ) {
+       mw.rcfilters.Controller.prototype.updateChangesList = function ( params, updateMode ) {
+               updateMode = updateMode === undefined ? this.FILTER_CHANGE : updateMode;
+
+               if ( updateMode === this.FILTER_CHANGE ) {
                        this._updateURL( params );
                }
-               if ( invalidateCurrentChanges ) {
+               if ( updateMode === this.FILTER_CHANGE || updateMode === this.SHOW_NEW_CHANGES ) {
                        this.changesListModel.invalidate();
                }
                this.changesListModel.setNewChangesExist( false );
                                function ( pieces ) {
                                        var $changesListContent = pieces.changes,
                                                $fieldset = pieces.fieldset;
-                                       this.changesListModel.update( $changesListContent, $fieldset, false, isLiveUpdate );
+                                       this.changesListModel.update(
+                                               $changesListContent,
+                                               $fieldset,
+                                               false,
+                                               updateMode === this.SHOW_NEW_CHANGES
+                                       );
                                }.bind( this )
                                // Do nothing for failure
                        )
index 44f6da7..7f7bbd2 100644 (file)
@@ -54,7 +54,7 @@
         * @return {boolean} false
         */
        mw.rcfilters.ui.FormWrapperWidget.prototype.onLinkClick = function ( e ) {
-               this.controller.updateChangesList( true, $( e.target ).data( 'params' ) );
+               this.controller.updateChangesList( $( e.target ).data( 'params' ) );
                return false;
        };
 
@@ -78,7 +78,7 @@
                        data[ $( this ).prop( 'name' ) ] = value;
                } );
 
-               this.controller.updateChangesList( true, data );
+               this.controller.updateChangesList( data );
                return false;
        };