From: Stephane Bisson Date: Thu, 11 Apr 2019 14:58:38 +0000 (-0400) Subject: RCFilters: display timestamp of new changes in refresh link X-Git-Tag: 1.34.0-rc.0~1920^2 X-Git-Url: https://git.cyclocoop.org/%242?a=commitdiff_plain;h=c27ffdfecf4616e651b5b11458adf7c2c5a27dc4;p=lhc%2Fweb%2Fwiklou.git RCFilters: display timestamp of new changes in refresh link The timestamp displayed in the link is not from the last refresh but from when new changes are available. I don't think this distinction is consequential. The fundamental meaning is that clicking the link will bring changes newer than the timestamp. I considered using a relative timestamp (2h ago) like is proposed in the task but I didn't think it was worth it for the following reasons: 1. Client-side formatting with momentjs is hacky at best and I couldn't find a way to have it respect user's preferences. 2. I don't think it makes the meaning of the timestamp in the message any clearer. I'll admit the meaning of the current timestamp is not explicit but I think it works when you don't think too much about it. 3. A relative timestamp requires a setInterval with decreasing interval to keep it up to date. ("A few seconds ago" -> "2 minutes ago", "1h ago", etc) Bug: T200353 Change-Id: I9058d47645914783227d1520adb78e75399b5504 --- diff --git a/includes/specials/SpecialRecentChanges.php b/includes/specials/SpecialRecentChanges.php index d0846b3068..9102f81751 100644 --- a/includes/specials/SpecialRecentChanges.php +++ b/includes/specials/SpecialRecentChanges.php @@ -918,7 +918,7 @@ class SpecialRecentChanges extends ChangesListSpecialPage { [ 'class' => 'rclistfrom' ], $this->makeOptionsLink( $this->msg( 'rclistfrom' )->plaintextParams( $now, $timenow, $datenow )->parse(), - [ 'from' => $timestamp ], + [ 'from' => $timestamp, 'fromFormatted' => $now ], $nondefaults ) ); diff --git a/includes/specials/SpecialWatchlist.php b/includes/specials/SpecialWatchlist.php index c6d9fc735d..a97859f7b9 100644 --- a/includes/specials/SpecialWatchlist.php +++ b/includes/specials/SpecialWatchlist.php @@ -598,11 +598,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 ) diff --git a/languages/i18n/en.json b/languages/i18n/en.json index 56ff4675b5..41f8c99f3e 100644 --- a/languages/i18n/en.json +++ b/languages/i18n/en.json @@ -1471,7 +1471,7 @@ "rcfilters-savedqueries-already-saved": "These filters are already saved. Change your settings to create a new Saved Filter.", "rcfilters-restore-default-filters": "Restore default filters", "rcfilters-clear-all-filters": "Clear all filters", - "rcfilters-show-new-changes": "View newest changes", + "rcfilters-show-new-changes": "View new changes since $1", "rcfilters-search-placeholder": "Filter changes (use menu or search for filter name)", "rcfilters-invalid-filter": "Invalid filter", "rcfilters-empty-filter": "No active filters. All contributions are shown.", diff --git a/languages/i18n/qqq.json b/languages/i18n/qqq.json index c7f2733cbd..f778a08ac5 100644 --- a/languages/i18n/qqq.json +++ b/languages/i18n/qqq.json @@ -1678,7 +1678,7 @@ "rcfilters-savedqueries-already-saved": "Title for the popup in [[Special:RecentChanges]] that indicates that current set of filters is already saved. This is for a small popup, please try to use a short string.", "rcfilters-restore-default-filters": "Label for the button that resets filters to defaults", "rcfilters-clear-all-filters": "Title for the button that clears all filters", - "rcfilters-show-new-changes": "Label for the button to show new changes.", + "rcfilters-show-new-changes": "Label for the button to show new changes. Parameters:\n* $1 - timestamp from which new changes are available. It indicates that clicking the refresh link will bring changes newer than (or equal to) this timestamp. It is formatted according to the user's date, time and timezone preferences", "rcfilters-search-placeholder": "Placeholder for the filter search input. The first \"Filter\" is a verb, and the second \"filter\" is a noun.", "rcfilters-invalid-filter": "A label for an invalid filter.", "rcfilters-empty-filter": "Placeholder for the filter list when no filters were chosen.", diff --git a/resources/src/mediawiki.rcfilters/dm/ChangesListViewModel.js b/resources/src/mediawiki.rcfilters/dm/ChangesListViewModel.js index 70677b91d4..d5357e0960 100644 --- a/resources/src/mediawiki.rcfilters/dm/ChangesListViewModel.js +++ b/resources/src/mediawiki.rcfilters/dm/ChangesListViewModel.js @@ -117,6 +117,7 @@ ChangesListViewModel.prototype.extractNextFrom = function ( $fieldset ) { var data = $fieldset.find( '.rclistfrom > a, .wlinfo' ).data( 'params' ); if ( data && data.from ) { this.nextFrom = data.from; + this.nextFromFormatted = data.fromFormatted; } }; @@ -127,6 +128,13 @@ ChangesListViewModel.prototype.getNextFrom = function () { return this.nextFrom; }; +/** + * @return {string} The 'from' parameter formatted per the user's datetime format preference + */ +ChangesListViewModel.prototype.getNextFromFormatted = function () { + return this.nextFromFormatted; +}; + /** * Toggle the 'live update' feature on/off * diff --git a/resources/src/mediawiki.rcfilters/ui/FilterWrapperWidget.js b/resources/src/mediawiki.rcfilters/ui/FilterWrapperWidget.js index ce9656eb27..a0f098c2e6 100644 --- a/resources/src/mediawiki.rcfilters/ui/FilterWrapperWidget.js +++ b/resources/src/mediawiki.rcfilters/ui/FilterWrapperWidget.js @@ -67,7 +67,6 @@ FilterWrapperWidget = function MwRcfiltersUiFilterWrapperWidget( this.showNewChangesLink = new OO.ui.ButtonWidget( { icon: 'reload', framed: false, - label: mw.msg( 'rcfilters-show-new-changes' ), flags: [ 'progressive' ], classes: [ 'mw-rcfilters-ui-filterWrapperWidget-showNewChanges' ] } ); @@ -131,6 +130,14 @@ FilterWrapperWidget.prototype.onShowNewChangesClick = function () { * @param {boolean} newChangesExist Whether new changes exist */ FilterWrapperWidget.prototype.onNewChangesExist = function ( newChangesExist ) { + if ( newChangesExist ) { + this.showNewChangesLink.setLabel( + mw.message( + 'rcfilters-show-new-changes', + this.changesListModel.getNextFromFormatted() + ).text() + ); + } this.showNewChangesLink.toggle( newChangesExist ); };