X-Git-Url: https://git.cyclocoop.org/?a=blobdiff_plain;f=includes%2Fspecials%2FSpecialWatchlist.php;h=c326257b64c8a7c772b3a32151983be1fa02edc0;hb=baa3105f63b0de50138b8011ad9faeb9415a15b8;hp=4d2fc62dde7d3f449f5e7405ab8efca7ed4e85eb;hpb=9254c8ea2e93f1659eaac07b273d2b4350cba26c;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/specials/SpecialWatchlist.php b/includes/specials/SpecialWatchlist.php index 4d2fc62dde..c326257b64 100644 --- a/includes/specials/SpecialWatchlist.php +++ b/includes/specials/SpecialWatchlist.php @@ -37,12 +37,16 @@ class SpecialWatchlist extends ChangesListSpecialPage { protected static $limitPreferenceName = 'wllimit'; protected static $collapsedPreferenceName = 'rcfilters-wl-collapsed'; + /** @var float|int */ private $maxDays; + /** WatchedItemStore */ + private $watchStore; public function __construct( $page = 'Watchlist', $restriction = 'viewmywatchlist' ) { parent::__construct( $page, $restriction ); $this->maxDays = $this->getConfig()->get( 'RCMaxAge' ) / ( 3600 * 24 ); + $this->watchStore = MediaWikiServices::getInstance()->getWatchedItemStore(); } public function doesWrites() { @@ -187,9 +191,10 @@ class SpecialWatchlist extends ChangesListSpecialPage { 'label' => 'rcfilters-filter-watchlistactivity-unseen-label', 'description' => 'rcfilters-filter-watchlistactivity-unseen-description', 'cssClassSuffix' => 'watchedunseen', - 'isRowApplicableCallable' => function ( $ctx, $rc ) { + 'isRowApplicableCallable' => function ( $ctx, RecentChange $rc ) { $changeTs = $rc->getAttribute( 'rc_timestamp' ); - $lastVisitTs = $rc->getAttribute( 'wl_notificationtimestamp' ); + $lastVisitTs = $this->getLatestSeenTimestamp( $rc ); + return $lastVisitTs !== null && $changeTs >= $lastVisitTs; }, ], @@ -198,16 +203,26 @@ class SpecialWatchlist extends ChangesListSpecialPage { 'label' => 'rcfilters-filter-watchlistactivity-seen-label', 'description' => 'rcfilters-filter-watchlistactivity-seen-description', 'cssClassSuffix' => 'watchedseen', - 'isRowApplicableCallable' => function ( $ctx, $rc ) { + 'isRowApplicableCallable' => function ( $ctx, RecentChange $rc ) { $changeTs = $rc->getAttribute( 'rc_timestamp' ); - $lastVisitTs = $rc->getAttribute( 'wl_notificationtimestamp' ); + $lastVisitTs = $this->getLatestSeenTimestamp( $rc ); + return $lastVisitTs === null || $changeTs < $lastVisitTs; } ], ], 'default' => ChangesListStringOptionsFilterGroup::NONE, - 'queryCallable' => function ( $specialPageClassName, $context, $dbr, - &$tables, &$fields, &$conds, &$query_options, &$join_conds, $selectedValues ) { + 'queryCallable' => function ( + $specialPageClassName, + $context, + IDatabase $dbr, + &$tables, + &$fields, + &$conds, + &$query_options, + &$join_conds, + $selectedValues + ) { if ( $selectedValues === [ 'seen' ] ) { $conds[] = $dbr->makeList( [ 'wl_notificationtimestamp IS NULL', @@ -526,7 +541,8 @@ class SpecialWatchlist extends ChangesListSpecialPage { $rc->counter = $counter++; if ( $this->getConfig()->get( 'ShowUpdatedMarker' ) ) { - $updated = $obj->wl_notificationtimestamp; + $lastVisitTs = $this->getLatestSeenTimestamp( $rc ); + $updated = ( $lastVisitTs > $rc->getAttribute( 'timestamp' ) ); } else { $updated = false; } @@ -590,11 +606,12 @@ class SpecialWatchlist extends ChangesListSpecialPage { $lang = $this->getLanguage(); $timestamp = wfTimestampNow(); + $now = $lang->userTimeAndDate( $timestamp, $user ); $wlInfo = Html::rawElement( 'span', [ 'class' => 'wlinfo', - 'data-params' => json_encode( [ 'from' => $timestamp ] ), + 'data-params' => json_encode( [ 'from' => $timestamp, 'fromFormatted' => $now ] ), ], $this->msg( 'wlnote' )->numParams( $numRows, round( $opts['days'] * 24 ) )->params( $lang->userDate( $timestamp, $user ), $lang->userTime( $timestamp, $user ) @@ -691,15 +708,16 @@ class SpecialWatchlist extends ChangesListSpecialPage { if ( $this->isStructuredFilterUiEnabled() ) { $rcfilterContainer = Html::element( 'div', - [ 'class' => 'rcfilters-container' ] + // TODO: Remove deprecated rcfilters-container class + [ 'class' => 'rcfilters-container mw-rcfilters-container' ] ); $loadingContainer = Html::rawElement( 'div', - [ 'class' => 'rcfilters-spinner' ], + [ 'class' => 'mw-rcfilters-spinner' ], Html::element( 'div', - [ 'class' => 'rcfilters-spinner-bounce' ] + [ 'class' => 'mw-rcfilters-spinner-bounce' ] ) ); @@ -707,7 +725,8 @@ class SpecialWatchlist extends ChangesListSpecialPage { $this->getOutput()->addHTML( Html::rawElement( 'div', - [ 'class' => 'rcfilters-head' ], + // TODO: Remove deprecated rcfilters-head class + [ 'class' => 'rcfilters-head mw-rcfilters-head' ], $rcfilterContainer . $form ) ); @@ -840,4 +859,16 @@ class SpecialWatchlist extends ChangesListSpecialPage { $count = $store->countWatchedItems( $this->getUser() ); return floor( $count / 2 ); } + + /** + * @param RecentChange $rc + * @return string TS_MW timestamp + */ + protected function getLatestSeenTimestamp( RecentChange $rc ) { + return $this->watchStore->getLatestNotificationTimestamp( + $rc->getAttribute( 'wl_notificationtimestamp' ), + $rc->getPerformer(), + $rc->getTitle() + ); + } }