}
}
- 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' );
}
'description' => 'rcfilters-filter-watchlistactivity-unseen-description',
'cssClassSuffix' => 'watchedunseen',
'isRowApplicableCallable' => function ( $ctx, RecentChange $rc ) {
- $changeTs = $rc->getAttribute( 'rc_timestamp' );
- $lastVisitTs = $this->watchStore->getLatestNotificationTimestamp(
- $rc->getAttribute( 'wl_notificationtimestamp' ),
- $rc->getPerformer(),
- $rc->getTitle()
- );
- return $lastVisitTs !== null && $changeTs >= $lastVisitTs;
+ return !$this->isChangeEffectivelySeen( $rc );
},
],
[
'label' => 'rcfilters-filter-watchlistactivity-seen-label',
'description' => 'rcfilters-filter-watchlistactivity-seen-description',
'cssClassSuffix' => 'watchedseen',
- 'isRowApplicableCallable' => function ( $ctx, $rc ) {
- $changeTs = $rc->getAttribute( 'rc_timestamp' );
- $lastVisitTs = $rc->getAttribute( 'wl_notificationtimestamp' );
- return $lastVisitTs === null || $changeTs < $lastVisitTs;
+ 'isRowApplicableCallable' => function ( $ctx, RecentChange $rc ) {
+ return $this->isChangeEffectivelySeen( $rc );
}
],
],
'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',
$rc->counter = $counter++;
if ( $this->getConfig()->get( 'ShowUpdatedMarker' ) ) {
- $updated = $obj->wl_notificationtimestamp;
+ $unseen = !$this->isChangeEffectivelySeen( $rc );
} else {
- $updated = false;
+ $unseen = false;
}
if ( isset( $watchedItemStore ) ) {
$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;
}
$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 )
$count = $store->countWatchedItems( $this->getUser() );
return floor( $count / 2 );
}
+
+ /**
+ * @param RecentChange $rc
+ * @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
+ */
+ private function getLatestNotificationTimestamp( RecentChange $rc ) {
+ return $this->watchStore->getLatestNotificationTimestamp(
+ $rc->getAttribute( 'wl_notificationtimestamp' ),
+ $rc->getPerformer(),
+ $rc->getTitle()
+ );
+ }
}