diff options
author | Aaron Schulz <aschulz@wikimedia.org> | 2019-05-03 13:23:24 -0700 |
---|---|---|
committer | Aaron Schulz <aschulz@wikimedia.org> | 2019-05-03 13:23:24 -0700 |
commit | 03d37f283b91f5a981ce131ac99a1a11151db53b (patch) | |
tree | 2c91a04f5476c2681106fcea603e9bd3941e8f2c /includes/specials/SpecialWatchlist.php | |
parent | 8b5b49cb6d8c9df839b7d6bc70590b040cc4ebda (diff) | |
download | mediawikicore-03d37f283b91f5a981ce131ac99a1a11151db53b.tar.gz mediawikicore-03d37f283b91f5a981ce131ac99a1a11151db53b.zip |
Consolidate duplicated unseen change logic and fix inconsistent code
Bug: T218511
Change-Id: I42387498dff0b1fc31f006ce3ba71241de9d45d7
Diffstat (limited to 'includes/specials/SpecialWatchlist.php')
-rw-r--r-- | includes/specials/SpecialWatchlist.php | 31 |
1 files changed, 17 insertions, 14 deletions
diff --git a/includes/specials/SpecialWatchlist.php b/includes/specials/SpecialWatchlist.php index bac059d2ae2f..812f1b00ab5c 100644 --- a/includes/specials/SpecialWatchlist.php +++ b/includes/specials/SpecialWatchlist.php @@ -199,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 ); }, ], [ @@ -211,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 ); } ], ], @@ -548,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 ) ) { @@ -561,7 +554,7 @@ class SpecialWatchlist extends ChangesListSpecialPage { $rc->numberofWatchingusers = 0; } - $changeLine = $list->recentChangesLine( $rc, $updated, $counter ); + $changeLine = $list->recentChangesLine( $rc, $unseen, $counter ); if ( $changeLine !== false ) { $s .= $changeLine; } @@ -869,9 +862,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 ) { + $lastVisitTs = $this->getLatestSeenTimestampIfHasUnseen( $rc ); + + return $lastVisitTs === null || $lastVisitTs > $rc->getAttribute( 'rc_timestamp' ); + } + + /** + * @param RecentChange $rc + * @return string|null TS_MW timestamp or null if all revision were seen */ - protected function getLatestSeenTimestamp( RecentChange $rc ) { + private function getLatestSeenTimestampIfHasUnseen( RecentChange $rc ) { return $this->watchStore->getLatestNotificationTimestamp( $rc->getAttribute( 'wl_notificationtimestamp' ), $rc->getPerformer(), |