Merge "Move section ID fallbacks into headers themselves"
[lhc/web/wiklou.git] / resources / src / mediawiki.rcfilters / dm / mw.rcfilters.dm.ChangesListViewModel.js
index f221b2b..0155a58 100644 (file)
@@ -14,6 +14,7 @@
                this.newChangesExist = false;
                this.nextFrom = null;
                this.liveUpdate = false;
+               this.unseenWatchedChanges = false;
        };
 
        /* Initialization */
@@ -79,6 +80,7 @@
                var from = this.nextFrom;
                this.valid = true;
                this.extractNextFrom( $fieldset );
+               this.checkForUnseenWatchedChanges( changesListContent );
                this.emit( 'update', changesListContent, $fieldset, isInitialDOM, separateOldAndNew ? from : null );
        };
 
         * @param {jQuery} $fieldset
         */
        mw.rcfilters.dm.ChangesListViewModel.prototype.extractNextFrom = function ( $fieldset ) {
-               this.nextFrom = $fieldset.find( '.rclistfrom > a' ).data( 'params' ).from;
+               var data = $fieldset.find( '.rclistfrom > a' ).data( 'params' );
+               this.nextFrom = data ? data.from : null;
        };
 
        /**
                return this.liveUpdate;
        };
 
+       /**
+        * Check if some of the given changes watched and unseen
+        *
+        * @param {jQuery|string} changeslistContent
+        */
+       mw.rcfilters.dm.ChangesListViewModel.prototype.checkForUnseenWatchedChanges = function ( changeslistContent ) {
+               this.unseenWatchedChanges = changeslistContent !== 'NO_RESULTS' &&
+                       changeslistContent.find( '.mw-changeslist-line-watched' ).length > 0;
+       };
+
+       /**
+        * @return {boolean} Whether some of the current changes are watched and unseen
+        */
+       mw.rcfilters.dm.ChangesListViewModel.prototype.hasUnseenWatchedChanges = function () {
+               return this.unseenWatchedChanges;
+       };
 }( mediaWiki ) );