Browse Source

Fix regression for MUC message avatars.

If for some reason we haven't loaded all occupants vcards, the code will
load avatars, but not display them next to messages.
This commit fixes it: if the vcard is not on the contact model, we
fallback to the message (as before, but code wasn't checking if the
vcard is on the contact).
John Livingston 1 năm trước cách đây
mục cha
commit
d95ef91721
1 tập tin đã thay đổi với 6 bổ sung2 xóa
  1. 6 2
      src/shared/chat/templates/message.js

+ 6 - 2
src/shared/chat/templates/message.js

@@ -20,6 +20,10 @@ export default (el, o) => {
     const contact = el.model.occupant || el.model.contact;
     const author_style = getAuthorStyle(contact);
 
+    // The model to use for the avatar.
+    // Note: it can happen that the contact has not the vcard attribute but the message has.
+    const avatar_model = contact?.vcard ? contact : el.model
+
     return html`
         ${ o.is_first_unread ? html`<div class="message separator">
             <hr class="separator">
@@ -37,10 +41,10 @@ export default (el, o) => {
             ${ (o.should_show_avatar && !is_followup) ?
                 html`<a class="show-msg-author-modal" @click=${el.showUserModal}>
                     <converse-avatar
-                        .model=${contact || el.model}
+                        .model=${avatar_model}
                         class="avatar align-self-center"
                         name="${el.model.getDisplayName()}"
-                        nonce="${el.model.vcard?.get('vcard_updated')}"
+                        nonce="${avatar_model.vcard?.get('vcard_updated')}"
                         height="40" width="40"></converse-avatar>
                 </a>` : '' }