Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix(MessagesList): Limit relative date up to a week. #11837

Merged
merged 1 commit into from Mar 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
29 changes: 19 additions & 10 deletions src/components/MessagesList/MessagesList.vue
Expand Up @@ -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)
}
},

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
DorraJaouad marked this conversation as resolved.
Show resolved Hide resolved
if (moment().startOf('day').diff(date, 'days') <= 7) {
return t('spreed', '{relativeDate}, {absoluteDate}', {
relativeDate: this.getRelativePrefix(date),
DorraJaouad marked this conversation as resolved.
Show resolved Hide resolved
// '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>
DorraJaouad marked this conversation as resolved.
Show resolved Hide resolved
return t('spreed', '{absoluteDate}', { absoluteDate: date.format('LL') })
}

},

/**
Expand Down