Bugfix. pretty_time was undefined

This commit is contained in:
JC Brand 2021-04-23 10:59:50 +02:00
parent db12e8a1e6
commit b2445d36d1
2 changed files with 4 additions and 10 deletions

View File

@ -29,8 +29,6 @@ export default class Message extends CustomElement {
} }
render () { render () {
const format = api.settings.get('time_format');
this.pretty_time = dayjs(this.model.get('edited') || this.model.get('time')).format(format);
if (this.show_spinner) { if (this.show_spinner) {
return tpl_spinner(); return tpl_spinner();
} else if (this.model.get('file') && !this.model.get('oob_url')) { } else if (this.model.get('file') && !this.model.get('oob_url')) {
@ -193,7 +191,9 @@ export default class Message extends CustomElement {
} }
getDerivedMessageProps () { getDerivedMessageProps () {
const format = api.settings.get('time_format');
return { return {
'pretty_time': dayjs(this.model.get('edited') || this.model.get('time')).format(format),
'has_mentions': this.hasMentions(), 'has_mentions': this.hasMentions(),
'hats': _converse.getHats(this.model), 'hats': _converse.getHats(this.model),
'is_first_unread': this.chatbox.get('first_unread_id') === this.model.get('id'), 'is_first_unread': this.chatbox.get('first_unread_id') === this.model.get('id'),
@ -266,13 +266,6 @@ export default class Message extends CustomElement {
`; `;
} }
renderAvatarByline () {
return html`
${ _converse.getHats(this.model).map(h => html`<span class="badge badge-secondary">${h.title}</span>`) }
<time timestamp="${this.model.get('edited') || this.model.get('time')}" class="chat-msg__time">${this.pretty_time}</time>
`;
}
showUserModal (ev) { showUserModal (ev) {
if (this.model.get('sender') === 'me') { if (this.model.get('sender') === 'me') {
_converse.xmppstatusview.showProfileModal(ev); _converse.xmppstatusview.showProfileModal(ev);

View File

@ -23,7 +23,8 @@ export default (el, o) => {
${ !o.is_me_message ? html` ${ !o.is_me_message ? html`
<span class="chat-msg__heading"> <span class="chat-msg__heading">
<span class="chat-msg__author"><a class="show-msg-author-modal" @click=${el.showUserModal}>${o.username}</a></span> <span class="chat-msg__author"><a class="show-msg-author-modal" @click=${el.showUserModal}>${o.username}</a></span>
${ el.renderAvatarByline() } ${ o.hats.map(h => html`<span class="badge badge-secondary">${h.title}</span>`) }
<time timestamp="${el.model.get('edited') || el.model.get('time')}" class="chat-msg__time">${o.pretty_time}</time>
${ o.is_encrypted ? html`<span class="fa fa-lock"></span>` : '' } ${ o.is_encrypted ? html`<span class="fa fa-lock"></span>` : '' }
</span>` : '' } </span>` : '' }
<div class="chat-msg__body chat-msg__body--${o.message_type} ${o.received ? 'chat-msg__body--received' : '' } ${o.is_delayed ? 'chat-msg__body--delayed' : '' }"> <div class="chat-msg__body chat-msg__body--${o.message_type} ${o.received ? 'chat-msg__body--received' : '' } ${o.is_delayed ? 'chat-msg__body--delayed' : '' }">