Skip to content

Commit

Permalink
fix(MessagesList): Limit relative date up to a week.
Browse files Browse the repository at this point in the history
Signed-off-by: DorraJaouad <dorra.jaoued7@gmail.com>
  • Loading branch information
DorraJaouad committed Mar 17, 2024
1 parent a330ccc commit e6c93e3
Showing 1 changed file with 18 additions and 9 deletions.
27 changes: 18 additions & 9 deletions src/components/MessagesList/MessagesList.vue
Expand Up @@ -561,6 +561,8 @@ 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 })
}
Expand All @@ -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') })
}
},
/**
Expand Down

0 comments on commit e6c93e3

Please sign in to comment.