diff options
author | Joas Schilling <213943+nickvergessen@users.noreply.github.com> | 2024-03-18 12:24:39 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-18 12:24:39 +0100 |
commit | dd0ce1a7679a8f5e0c5f0defa92c41250d9b5fec (patch) | |
tree | 4ef6ff09d4a27b89defdd3f94eee8095bc7dd434 | |
parent | 240065ffc6c66bea0b8cf4f94f5fc6a3dbb4d374 (diff) | |
parent | 30af5084e6c31cf7da32604b4375242729c8b788 (diff) |
Merge pull request #11837 from nextcloud/fix/noid/relative-date-in-date-separators
Fix(MessagesList): Limit relative date up to a week.
-rw-r--r-- | src/components/MessagesList/MessagesList.vue | 29 |
1 files changed, 19 insertions, 10 deletions
diff --git a/src/components/MessagesList/MessagesList.vue b/src/components/MessagesList/MessagesList.vue index 36658a463..7c97ac0eb 100644 --- a/src/components/MessagesList/MessagesList.vue +++ b/src/components/MessagesList/MessagesList.vue @@ -561,8 +561,10 @@ export default { return t('spreed', 'Today') case 1: return t('spreed', 'Yesterday') + case 7: + return t('spreed', 'A week ago') default: - return t('spreed', '{n} days ago', { n: diffDays }) + return n('spreed', '%n day ago', '%n days ago', diffDays) } }, @@ -574,15 +576,22 @@ export default { */ generateDateSeparator(dateTimestamp) { const date = moment.unix(dateTimestamp).startOf('day') - // <Today>, <November 11th, 2019> - return t('spreed', '{relativeDate}, {absoluteDate}', { - relativeDate: this.getRelativePrefix(date), - // 'LL' formats a localized date including day of month, month - // name and year - absoluteDate: date.format('LL'), - }, undefined, { - escape: false, // French "Today" has a ' in it - }) + // <Today>, <March 18th, 2024> + // Relative date is only shown until a week ago + if (moment().startOf('day').diff(date, 'days') <= 7) { + return t('spreed', '{relativeDate}, {absoluteDate}', { + relativeDate: this.getRelativePrefix(date), + // 'LL' formats a localized date including day of month, month + // name and year + absoluteDate: date.format('LL'), + }, undefined, { + escape: false, // French "Today" has a ' in it + }) + } else { + // <March 18th, 2024> + return t('spreed', '{absoluteDate}', { absoluteDate: date.format('LL') }) + } + }, /** |