diff --git a/i18n/en.json b/i18n/en.json index b3474e00e..2e20402a0 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -137,6 +137,9 @@ "discussiontools-topicsubscription-notify-unsubscribed-body": "You will no longer receive notifications about new comments in this topic.", "discussiontools-topicsubscription-notify-unsubscribed-title": "You have unsubscribed.", "discussiontools-topicsubscription-pager-actions": "Actions", + "discussiontools-topicsubscription-pager-created": "First subscribed", + "discussiontools-topicsubscription-pager-notified": "Latest notification", + "discussiontools-topicsubscription-pager-notified-never": "never", "discussiontools-topicsubscription-pager-page": "Page", "discussiontools-topicsubscription-pager-topic": "Topic", "discussiontools-topicsubscription-pager-unsubscribe-button": "Unsubscribe", diff --git a/i18n/qqq.json b/i18n/qqq.json index c94b8aa55..e62a275a8 100644 --- a/i18n/qqq.json +++ b/i18n/qqq.json @@ -149,6 +149,9 @@ "discussiontools-topicsubscription-notify-unsubscribed-body": "Body of notification shown when a user unsubscribes from a topic.", "discussiontools-topicsubscription-notify-unsubscribed-title": "Title of notification shown when a user unsubscribes from a topic.", "discussiontools-topicsubscription-pager-actions": "Used on [[mw:Special:TopicSubscriptions|Special:TopicSubscriptions]] as a table heading.\n{{identical|Action}}", + "discussiontools-topicsubscription-pager-created": "Used on [[mw:Special:TopicSubscriptions|Special:TopicSubscriptions]] as a table heading.", + "discussiontools-topicsubscription-pager-notified": "Used on [[mw:Special:TopicSubscriptions|Special:TopicSubscriptions]] as a table heading.", + "discussiontools-topicsubscription-pager-notified-never": "Used on [[mw:Special:TopicSubscriptions|Special:TopicSubscriptions]] in the table.", "discussiontools-topicsubscription-pager-page": "Used on [[mw:Special:TopicSubscriptions|Special:TopicSubscriptions]] as a table heading.", "discussiontools-topicsubscription-pager-topic": "Used on [[mw:Special:TopicSubscriptions|Special:TopicSubscriptions]] as a table heading.", "discussiontools-topicsubscription-pager-unsubscribe-button": "Used on [[mw:Special:TopicSubscriptions|Special:TopicSubscriptions]] in the table, as a button label.", diff --git a/includes/TopicSubscriptionsPager.php b/includes/TopicSubscriptionsPager.php index 0e90acc13..4bf1c5c12 100644 --- a/includes/TopicSubscriptionsPager.php +++ b/includes/TopicSubscriptionsPager.php @@ -18,7 +18,10 @@ class TopicSubscriptionsPager extends TablePager { * won't get "stuck" when e.g. 50 subscriptions are all created within a second. */ private const INDEX_FIELDS = [ + // The auto-increment ID will almost always have the same order as sub_created + // and the field already has an index. '_topic' => [ 'sub_id' ], + 'sub_created' => [ 'sub_id' ], // TODO Add indexes that cover these fields to enable sorting by them // 'sub_state' => [ 'sub_state', 'sub_item' ], // 'sub_created' => [ 'sub_created', 'sub_item' ], @@ -60,6 +63,8 @@ class TopicSubscriptionsPager extends TablePager { return [ '_topic' => $this->msg( 'discussiontools-topicsubscription-pager-topic' )->text(), '_page' => $this->msg( 'discussiontools-topicsubscription-pager-page' )->text(), + 'sub_created' => $this->msg( 'discussiontools-topicsubscription-pager-created' )->text(), + 'sub_notified' => $this->msg( 'discussiontools-topicsubscription-pager-notified' )->text(), '_unsubscribe' => $this->msg( 'discussiontools-topicsubscription-pager-actions' )->text(), ]; } @@ -81,6 +86,14 @@ class TopicSubscriptionsPager extends TablePager { $title = Title::makeTitleSafe( $row->sub_namespace, $row->sub_title ); return $linkRenderer->makeLink( $title, $title->getPrefixedText() ); + case 'sub_created': + return htmlspecialchars( $this->getLanguage()->userTimeAndDate( $value, $this->getUser() ) ); + + case 'sub_notified': + return $value ? + htmlspecialchars( $this->getLanguage()->userTimeAndDate( $value, $this->getUser() ) ) : + $this->msg( 'discussiontools-topicsubscription-pager-notified-never' )->escaped(); + case '_unsubscribe': $title = Title::makeTitleSafe( $row->sub_namespace, $row->sub_title ); return (string)new OOUI\ButtonWidget( [ @@ -123,6 +136,8 @@ class TopicSubscriptionsPager extends TablePager { 'sub_namespace', 'sub_title', 'sub_section', + 'sub_created', + 'sub_notified', ], 'conds' => [ 'sub_user' => $this->getUser()->getId(), @@ -135,7 +150,7 @@ class TopicSubscriptionsPager extends TablePager { * @inheritDoc */ public function getDefaultSort() { - return '_topic'; + return 'sub_created'; } /** @@ -149,7 +164,7 @@ class TopicSubscriptionsPager extends TablePager { * @inheritDoc */ protected function isFieldSortable( $field ) { - // Topic is set to the auto-ID field (sub_id), so sorting by it is not very useful + // Hide the sort button for "Topic" as it is more accurately shown as "Created" return isset( static::INDEX_FIELDS[$field] ) && $field !== '_topic'; } }