소스 검색

Bugfix. Error messages don't have associated vcards

JC Brand 6 년 전
부모
커밋
148eaeacf5
3개의 변경된 파일15개의 추가작업 그리고 6개의 파일을 삭제
  1. 8 3
      dist/converse.js
  2. 3 1
      src/converse-chatboxes.js
  3. 4 2
      src/converse-message-view.js

+ 8 - 3
dist/converse.js

@@ -60321,7 +60321,9 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
         },
         },
 
 
         setVCard() {
         setVCard() {
-          if (this.get('type') === 'groupchat') {
+          if (this.get('type') === 'error') {
+            return;
+          } else if (this.get('type') === 'groupchat') {
             this.vcard = this.getVCardForChatroomOccupant();
             this.vcard = this.getVCardForChatroomOccupant();
           } else {
           } else {
             const jid = this.get('from');
             const jid = this.get('from');
@@ -67523,7 +67525,10 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
         },
         },
 
 
         initialize() {
         initialize() {
-          this.model.vcard.on('change', this.render, this);
+          if (this.model.vcard) {
+            this.model.vcard.on('change', this.render, this);
+          }
+
           this.model.on('change:correcting', this.onMessageCorrection, this);
           this.model.on('change:correcting', this.onMessageCorrection, this);
           this.model.on('change:message', this.render, this);
           this.model.on('change:message', this.render, this);
           this.model.on('change:progress', this.renderFileUploadProgresBar, this);
           this.model.on('change:progress', this.renderFileUploadProgresBar, this);
@@ -67575,7 +67580,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
         renderChatMessage() {
         renderChatMessage() {
           const is_me_message = this.isMeCommand(),
           const is_me_message = this.isMeCommand(),
                 moment_time = moment(this.model.get('time')),
                 moment_time = moment(this.model.get('time')),
-                role = this.model.vcard.get('role'),
+                role = this.model.vcard ? this.model.vcard.get('role') : null,
                 roles = role ? role.split(',') : [];
                 roles = role ? role.split(',') : [];
           const msg = u.stringToElement(tpl_message(_.extend(this.model.toJSON(), {
           const msg = u.stringToElement(tpl_message(_.extend(this.model.toJSON(), {
             '__': __,
             '__': __,

+ 3 - 1
src/converse-chatboxes.js

@@ -109,7 +109,9 @@
                 },
                 },
 
 
                 setVCard () {
                 setVCard () {
-                    if (this.get('type') === 'groupchat') {
+                    if (this.get('type') === 'error') {
+                        return;
+                    } else if (this.get('type') === 'groupchat') {
                         this.vcard = this.getVCardForChatroomOccupant();
                         this.vcard = this.getVCardForChatroomOccupant();
                     } else {
                     } else {
                         const jid = this.get('from');
                         const jid = this.get('from');

+ 4 - 2
src/converse-message-view.js

@@ -58,7 +58,9 @@
                 },
                 },
 
 
                 initialize () {
                 initialize () {
-                    this.model.vcard.on('change', this.render, this);
+                    if (this.model.vcard) {
+                        this.model.vcard.on('change', this.render, this);
+                    }
                     this.model.on('change:correcting', this.onMessageCorrection, this);
                     this.model.on('change:correcting', this.onMessageCorrection, this);
                     this.model.on('change:message', this.render, this);
                     this.model.on('change:message', this.render, this);
                     this.model.on('change:progress', this.renderFileUploadProgresBar, this);
                     this.model.on('change:progress', this.renderFileUploadProgresBar, this);
@@ -105,7 +107,7 @@
                 renderChatMessage () {
                 renderChatMessage () {
                     const is_me_message = this.isMeCommand(),
                     const is_me_message = this.isMeCommand(),
                           moment_time = moment(this.model.get('time')),
                           moment_time = moment(this.model.get('time')),
-                          role = this.model.vcard.get('role'),
+                          role = this.model.vcard ? this.model.vcard.get('role') : null,
                           roles = role ? role.split(',') : [];
                           roles = role ? role.split(',') : [];
 
 
                     const msg = u.stringToElement(tpl_message(
                     const msg = u.stringToElement(tpl_message(