MDL-65135 message: use full date in messaging drawer for old messages.

Messages sent in previous years will now include the year portion of
the date string.
This commit is contained in:
Paul Holden 2020-10-13 00:08:54 +01:00
parent ed2400457b
commit 5d778a7646
4 changed files with 20 additions and 7 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -575,8 +575,10 @@ function(
var renderAddDays = function(header, body, footer, days, datesCache) {
var messagesContainer = getMessagesContainer(body);
var daysRenderPromises = days.map(function(data) {
var timestampDate = new Date(data.value.timestamp * 1000);
return Templates.render(TEMPLATES.DAY, {
timestamp: data.value.timestamp,
currentyear: timestampDate.getFullYear() === (new Date()).getFullYear(),
messages: formatMessagesForTemplate(data.value.messages, datesCache)
});
});

View File

@ -27,14 +27,25 @@
* All data attributes are required
Context variables required for this template:
* userid The logged in user id
* urls The URLs for the popover
* timestamp
* currentyear
* messages
Example context (json):
{}
{
"timestamp": 946684800,
"currentyear": false,
"messages": []
}
}}
<div class="mt-4" data-region="day-container" data-day-id="{{timestamp}}">
<h6 class="text-center mb-4 day">{{#userdate}} {{timestamp}}, {{#str}} strftimedateshort, core_langconfig {{/str}} {{/userdate}}</h6>
<h6 class="text-center mb-4 day">
{{#currentyear}}
{{#userdate}} {{timestamp}}, {{#str}} strftimedateshort, core_langconfig {{/str}} {{/userdate}}
{{/currentyear}}
{{^currentyear}}
{{#userdate}} {{timestamp}}, {{#str}} strftimedate, core_langconfig {{/str}} {{/userdate}}
{{/currentyear}}
</h6>
{{> core_message/message_drawer_view_conversation_body_messages }}
</div>