Merge "Allow hidden skins to show up in preferences"
[lhc/web/wiklou.git] / includes / specials / SpecialWatchlist.php
index c326257..56f5c8f 100644 (file)
@@ -110,7 +110,14 @@ class SpecialWatchlist extends ChangesListSpecialPage {
                }
        }
 
-       public static function checkStructuredFilterUiEnabled( Config $config, User $user ) {
+       /**
+        * @see ChangesListSpecialPage::checkStructuredFilterUiEnabled
+        */
+       public static function checkStructuredFilterUiEnabled( $user ) {
+               if ( $user instanceof Config ) {
+                       wfDeprecated( __METHOD__ . ' with Config argument', '1.34' );
+                       $user = func_get_arg( 1 );
+               }
                return !$user->getOption( 'wlenhancedfilters-disable' );
        }
 
@@ -192,10 +199,7 @@ class SpecialWatchlist extends ChangesListSpecialPage {
                                        'description' => 'rcfilters-filter-watchlistactivity-unseen-description',
                                        'cssClassSuffix' => 'watchedunseen',
                                        'isRowApplicableCallable' => function ( $ctx, RecentChange $rc ) {
-                                               $changeTs = $rc->getAttribute( 'rc_timestamp' );
-                                               $lastVisitTs = $this->getLatestSeenTimestamp( $rc );
-
-                                               return $lastVisitTs !== null && $changeTs >= $lastVisitTs;
+                                               return !$this->isChangeEffectivelySeen( $rc );
                                        },
                                ],
                                [
@@ -204,10 +208,7 @@ class SpecialWatchlist extends ChangesListSpecialPage {
                                        'description' => 'rcfilters-filter-watchlistactivity-seen-description',
                                        'cssClassSuffix' => 'watchedseen',
                                        'isRowApplicableCallable' => function ( $ctx, RecentChange $rc ) {
-                                               $changeTs = $rc->getAttribute( 'rc_timestamp' );
-                                               $lastVisitTs = $this->getLatestSeenTimestamp( $rc );
-
-                                               return $lastVisitTs === null || $changeTs < $lastVisitTs;
+                                               return $this->isChangeEffectivelySeen( $rc );
                                        }
                                ],
                        ],
@@ -541,10 +542,9 @@ class SpecialWatchlist extends ChangesListSpecialPage {
                        $rc->counter = $counter++;
 
                        if ( $this->getConfig()->get( 'ShowUpdatedMarker' ) ) {
-                               $lastVisitTs = $this->getLatestSeenTimestamp( $rc );
-                               $updated = ( $lastVisitTs > $rc->getAttribute( 'timestamp' ) );
+                               $unseen = !$this->isChangeEffectivelySeen( $rc );
                        } else {
-                               $updated = false;
+                               $unseen = false;
                        }
 
                        if ( isset( $watchedItemStore ) ) {
@@ -554,7 +554,10 @@ class SpecialWatchlist extends ChangesListSpecialPage {
                                $rc->numberofWatchingusers = 0;
                        }
 
-                       $changeLine = $list->recentChangesLine( $rc, $updated, $counter );
+                       // XXX: this treats pages with no unseen changes as "not on the watchlist" since
+                       // everything is on the watchlist and it is an easy way to make pages with unseen
+                       // changes appear bold. @TODO: clean this up.
+                       $changeLine = $list->recentChangesLine( $rc, $unseen, $counter );
                        if ( $changeLine !== false ) {
                                $s .= $changeLine;
                        }
@@ -862,9 +865,19 @@ class SpecialWatchlist extends ChangesListSpecialPage {
 
        /**
         * @param RecentChange $rc
-        * @return string TS_MW timestamp
+        * @return bool User viewed the revision or a newer one
+        */
+       protected function isChangeEffectivelySeen( RecentChange $rc ) {
+               $firstUnseen = $this->getLatestNotificationTimestamp( $rc );
+
+               return ( $firstUnseen === null || $firstUnseen > $rc->getAttribute( 'rc_timestamp' ) );
+       }
+
+       /**
+        * @param RecentChange $rc
+        * @return string|null TS_MW timestamp of first unseen revision or null if there isn't one
         */
-       protected function getLatestSeenTimestamp( RecentChange $rc ) {
+       private function getLatestNotificationTimestamp( RecentChange $rc ) {
                return $this->watchStore->getLatestNotificationTimestamp(
                        $rc->getAttribute( 'wl_notificationtimestamp' ),
                        $rc->getPerformer(),