Skip to content

Commit

Permalink
MDL-64099 message: fix last message and date in group conversations
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanwyllie committed Nov 27, 2018
1 parent 99cbd61 commit 12d2381
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 18 deletions.
2 changes: 2 additions & 0 deletions lang/en/message.php
Expand Up @@ -46,6 +46,7 @@
$string['contactrequests'] = 'Contact requests';
$string['contactrequestsent'] = 'Contact request sent';
$string['contacts'] = 'Contacts';
$string['conversationlastmessage'] = '{$a->sender}: {$a->message}';
$string['decline'] = 'Decline';
$string['defaultmessageoutputs'] = 'Default message outputs';
$string['defaults'] = 'Defaults';
Expand Down Expand Up @@ -250,6 +251,7 @@
$string['writeamessage'] = 'Write a message...';
$string['wouldliketocontactyou'] = 'Would like to contact you';
$string['you'] = 'You:';
$string['yousender'] = 'You';
$string['youhaveblockeduser'] = 'You have blocked this user in the past';
$string['yourcontactrequestpending'] = 'Your contact request is pending with {$a}';

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 11 additions & 12 deletions message/amd/src/message_drawer_view_overview_section.js
Expand Up @@ -194,7 +194,7 @@ function(
carry = member.fullname;
}
return carry;
}, null) + ':';
}, null);
}

return formattedConversation;
Expand Down Expand Up @@ -363,7 +363,7 @@ function(
var message = conversation.messages[conversation.messages.length - 1];
var youString = '';
var stringRequests = [
{key: 'you', component: 'core_message'},
{key: 'yousender', component: 'core_message'},
{key: 'strftimetime24', component: 'core_langconfig'},
];
return Str.get_strings(stringRequests)
Expand All @@ -375,17 +375,16 @@ function(
return dates[0];
})
.then(function(dateString) {
var lastMessage = $(message.text).text();

if (message.fromLoggedInUser) {
lastMessage = youString + ' ' + lastMessage;
} else {
lastMessage = message.userFrom.fullname + ': ' + lastMessage;
}

element.find(SELECTORS.LAST_MESSAGE).html(lastMessage);
element.find(SELECTORS.LAST_MESSAGE_DATE).text(dateString).removeClass('hidden');
return dateString;

// Now load the last message.
return Str.get_string('conversationlastmessage', 'core_message', {
sender: message.fromLoggedInUser ? youString : message.userFrom.fullname,
message: "<span class='text-muted'>" + $(message.text).text() + "</span>"
});
})
.then(function(lastMessage) {
return element.find(SELECTORS.LAST_MESSAGE).html(lastMessage);
});
};

Expand Down
28 changes: 23 additions & 5 deletions message/templates/message_drawer_conversations_list.mustache
Expand Up @@ -66,16 +66,34 @@
<p class="m-0 text-truncate">{{.}}</p>
{{/subname}}
<p class="m-0 font-weight-light text-truncate" data-region="last-message">
{{#sentfromcurrentuser}}{{#str}} you, core_message {{/str}}{{/sentfromcurrentuser}}
{{^sentfromcurrentuser}}{{lastsendername}}{{/sentfromcurrentuser}}
<span class="text-muted">{{lastmessage}}</span>
{{#sentfromcurrentuser}}
{{#str}}
conversationlastmessage,
core_message,
{
"sender": "{{#str}} yousender, core_message {{/str}}",
"message": "<span class='text-muted'>{{lastmessage}}</span>"
}
{{/str}}
{{/sentfromcurrentuser}}
{{^sentfromcurrentuser}}
{{#lastsendername}}
{{#str}}
conversationlastmessage,
core_message,
{
"sender": "{{.}}",
"message": "<span class='text-muted'>{{lastmessage}}</span>"
}
{{/str}}
{{/lastsendername}}
{{/sentfromcurrentuser}}
</p>
</div>
<div class="d-flex align-self-stretch">
<div
class="ml-auto small position-absolute text-muted {{^lastmessagedate}}hidden{{/lastmessagedate}}"
class="px-2 py-1 small position-absolute position-right text-muted {{^lastmessagedate}}hidden{{/lastmessagedate}}"
data-region="last-message-date"
style="right: 0.5rem"
>
{{#lastmessagedate}}
{{#userdate}} {{.}}, {{#str}} strftimetime24, core_langconfig {{/str}} {{/userdate}}
Expand Down
4 changes: 4 additions & 0 deletions theme/boost/scss/moodle/core.scss
Expand Up @@ -2248,4 +2248,8 @@ $switch-transition: .2s all !default;

.text-decoration-none {
text-decoration: none !important; /* stylelint-disable-line declaration-no-important */
}

.position-right {
right: 0 !important; /* stylelint-disable-line declaration-no-important */
}
4 changes: 4 additions & 0 deletions theme/boost/style/moodle.css
Expand Up @@ -10532,6 +10532,10 @@ div.editor_atto_toolbar button .icon {
text-decoration: none !important;
/* stylelint-disable-line declaration-no-important */ }

.position-right {
right: 0 !important;
/* stylelint-disable-line declaration-no-important */ }

.icon {
font-size: 16px;
width: 16px;
Expand Down
4 changes: 4 additions & 0 deletions theme/bootstrapbase/less/moodle/core.less
Expand Up @@ -2446,4 +2446,8 @@ h3.sectionname .inplaceeditable.inplaceeditingon .editinstructions {

.text-decoration-none {
text-decoration: none !important; /* stylelint-disable-line declaration-no-important */
}

.position-right {
right: 0 !important; /* stylelint-disable-line declaration-no-important */
}
4 changes: 4 additions & 0 deletions theme/bootstrapbase/style/moodle.css
Expand Up @@ -4827,6 +4827,10 @@ h3.sectionname .inplaceeditable.inplaceeditingon .editinstructions {
text-decoration: none !important;
/* stylelint-disable-line declaration-no-important */
}
.position-right {
right: 0 !important;
/* stylelint-disable-line declaration-no-important */
}
/* admin.less */
.formtable tbody th {
font-weight: normal;
Expand Down

0 comments on commit 12d2381

Please sign in to comment.