From 081df2bf826fb419d10f9d0d62d30c2d3469b3e9 Mon Sep 17 00:00:00 2001 From: Nolan Lawson Date: Sun, 21 Mar 2021 18:03:53 -0700 Subject: [PATCH] fix: use day-only time format for wellness setting (#2021) * fix: use day-only time format for wellness setting * fix: tweak intl strings [skip ci] * test: add test --- src/intl/en-US.js | 2 +- .../_a11y/getAccessibleLabelForStatus.js | 4 +-- src/routes/_components/status/Status.html | 16 +++++++---- .../status/StatusRelativeDate.html | 20 ++----------- src/routes/_utils/formatters.js | 6 ++++ tests/spec/041-wellness.js | 28 +++++++++++++++++++ tests/utils.js | 1 + 7 files changed, 51 insertions(+), 26 deletions(-) create mode 100644 tests/spec/041-wellness.js diff --git a/src/intl/en-US.js b/src/intl/en-US.js index e145bef6..c7502834 100644 --- a/src/intl/en-US.js +++ b/src/intl/en-US.js @@ -394,7 +394,7 @@ export default { hideUnread: 'Hide unread notifications count (i.e. the red dot)', // The quality that makes something seem important or interesting because it seems to be happening now immediacy: 'Immediacy', - showAbsoluteTimestamps: 'Show absolute timestamps instead of relative timestamps', + showAbsoluteTimestamps: 'Show absolute timestamps (e.g. "March 3rd") instead of relative timestamps (e.g. "5 minutes ago")', ui: 'UI', grayscaleMode: 'Grayscale mode', wellnessFooter: `These settings are partly based on guidelines from the diff --git a/src/routes/_a11y/getAccessibleLabelForStatus.js b/src/routes/_a11y/getAccessibleLabelForStatus.js index 2fa78bb3..62b8e5f8 100644 --- a/src/routes/_a11y/getAccessibleLabelForStatus.js +++ b/src/routes/_a11y/getAccessibleLabelForStatus.js @@ -35,7 +35,7 @@ function cleanupText (text) { } export function getAccessibleLabelForStatus (originalAccount, account, plainTextContent, - timeagoFormattedDate, spoilerText, showContent, + shortInlineFormattedDate, spoilerText, showContent, reblog, notification, visibility, omitEmojiInDisplayNames, disableLongAriaLabels, showMedia, showPoll) { const originalAccountDisplayName = getAccountAccessibleName(originalAccount, omitEmojiInDisplayNames) @@ -58,7 +58,7 @@ export function getAccessibleLabelForStatus (originalAccount, account, plainText contentTextToShow, mediaTextToShow, pollTextToShow, - timeagoFormattedDate, + shortInlineFormattedDate, `@${originalAccount.acct}`, privacyText, getReblogText(reblog, account, omitEmojiInDisplayNames) diff --git a/src/routes/_components/status/Status.html b/src/routes/_components/status/Status.html index 9e617d4e..b94e2db5 100644 --- a/src/routes/_components/status/Status.html +++ b/src/routes/_components/status/Status.html @@ -127,7 +127,7 @@ import { formatTimeagoDate } from '../../_intl/formatTimeagoDate' import { measureText } from '../../_utils/measureText' import { LONG_POST_LENGTH, LONG_POST_TEXT } from '../../_static/statuses' - import { absoluteDateFormatter } from '../../_utils/formatters' + import { absoluteDateFormatter, dayOnlyAbsoluteDateFormatter } from '../../_utils/formatters' import { composeNewStatusMentioning } from '../../_actions/mention' import { createStatusOrNotificationUuid } from '../../_utils/createStatusOrNotificationUuid' import { addEmojiTooltips } from '../../_utils/addEmojiTooltips' @@ -277,15 +277,19 @@ createdAtDate: ({ originalStatus }) => originalStatus.created_at, createdAtDateTS: ({ createdAtDate }) => new Date(createdAtDate).getTime(), absoluteFormattedDate: ({ createdAtDateTS }) => absoluteDateFormatter.format(createdAtDateTS), - timeagoFormattedDate: ({ createdAtDateTS, $now }) => formatTimeagoDate(createdAtDateTS, $now), + shortInlineFormattedDate: ({ createdAtDateTS, $now, $disableRelativeTimestamps }) => ( + $disableRelativeTimestamps + ? dayOnlyAbsoluteDateFormatter.format(createdAtDateTS) + : formatTimeagoDate(createdAtDateTS, $now) + ), reblog: ({ status }) => status.reblog, ariaLabel: ({ - originalAccount, account, plainTextContent, timeagoFormattedDate, spoilerText, + originalAccount, account, plainTextContent, shortInlineFormattedDate, spoilerText, showContent, reblog, notification, visibility, $omitEmojiInDisplayNames, $disableLongAriaLabels, showMedia, showPoll }) => ( getAccessibleLabelForStatus(originalAccount, account, plainTextContent, - timeagoFormattedDate, spoilerText, showContent, + shortInlineFormattedDate, spoilerText, showContent, reblog, notification, visibility, $omitEmojiInDisplayNames, $disableLongAriaLabels, showMedia, showPoll ) @@ -309,10 +313,10 @@ showContent: ({ spoilerText, spoilerShown }) => !spoilerText || spoilerShown, // These timestamp params may change every 10 seconds due to now() polling, so keep them // separate from the generic `params` list to avoid costly recomputes. - timestampParams: ({ createdAtDate, createdAtDateTS, timeagoFormattedDate, absoluteFormattedDate }) => ({ + timestampParams: ({ createdAtDate, createdAtDateTS, shortInlineFormattedDate, absoluteFormattedDate }) => ({ createdAtDate, createdAtDateTS, - timeagoFormattedDate, + shortInlineFormattedDate, absoluteFormattedDate }), // This params list deliberately does *not* include `spoilersShown` or `replyShown`, because these diff --git a/src/routes/_components/status/StatusRelativeDate.html b/src/routes/_components/status/StatusRelativeDate.html index e16bea97..a8284651 100644 --- a/src/routes/_components/status/StatusRelativeDate.html +++ b/src/routes/_components/status/StatusRelativeDate.html @@ -4,9 +4,9 @@ rel="prefetch" {tabindex} > -