Bug 1589552 - add tagName param in addContact function in chat-group.js. r=clokep
authorKhushil Mistry <khushil324@gmail.com>
Mon, 16 Mar 2020 22:30:43 +0200
changeset 38497 3511b452ac30ac419fb0148b133a323939e3152f
parent 38496 2891d703d7591ad5492211961c7bfc1593ab8193
child 38498 d3be91942e370b708a1ff63bab301528ff4bbd44
push id400
push userclokep@gmail.com
push dateMon, 04 May 2020 18:56:09 +0000
reviewersclokep
bugs1589552
Bug 1589552 - add tagName param in addContact function in chat-group.js. r=clokep
mail/components/im/content/chat-conversation.js
mail/components/im/content/chat-group.js
mail/components/im/content/chat-imconv.js
--- a/mail/components/im/content/chat-conversation.js
+++ b/mail/components/im/content/chat-conversation.js
@@ -76,17 +76,17 @@
               break;
 
             case "replying-to-prompt":
               this.addPrompt(data);
               break;
 
             case "target-prpl-conversation-changed":
             case "update-conv-title":
-              if (this.tab) {
+              if (this.tab && this.conv) {
                 this.tab.setAttribute("label", this.conv.title);
               }
               break;
 
             // Update the status too.
             case "update-buddy-status":
             case "update-buddy-icon":
             case "update-conv-chatleft":
--- a/mail/components/im/content/chat-group.js
+++ b/mail/components/im/content/chat-group.js
@@ -126,17 +126,17 @@
       contactElt.group = this;
       this.contacts.splice(end, 0, contactElt);
       this.contactsById[contact.id] = contactElt;
       this.removeAttribute("collapsed");
       this._updateGroupLabel();
       return contactElt;
     }
 
-    updateContactPosition(subject) {
+    updateContactPosition(subject, tagName) {
       let contactElt = this.contactsById[subject.id];
       let index = this.contacts.indexOf(contactElt);
       if (index == -1) {
         // Sometimes we get a display-name-changed notification for
         // an offline contact, if it's not in the list, just ignore it.
         return;
       }
       // See if the position of the contact should be changed.
@@ -147,20 +147,21 @@
             this.contacts[index - 1].contact
           ) < 0) ||
         (index != this.contacts.length - 1 &&
           this.sortComparator(
             contactElt.contact,
             this.contacts[index + 1].contact
           ) > 0)
       ) {
+        let list = this.parentNode;
+        let selectedItem = list.selectedItem;
         let oldItem = this.removeContact(subject);
-        let newItem = this.addContact(subject);
-        let list = this.parentNode;
-        if (list.selectedItem == oldItem) {
+        let newItem = this.addContact(subject, tagName);
+        if (selectedItem == oldItem) {
           list.selectedItem = newItem;
         }
       }
     }
 
     removeContact(contactForID) {
       let contact = this.contactsById[contactForID.id];
       if (!contact) {
--- a/mail/components/im/content/chat-imconv.js
+++ b/mail/components/im/content/chat-imconv.js
@@ -109,17 +109,20 @@
             topic == "update-buddy-status" ||
             topic == "update-conv-chatleft" ||
             topic == "update-conv-chatjoining" ||
             topic == "chat-update-topic"
           ) {
             this.update();
           }
           if (topic == "update-conv-title") {
-            this.group.updateContactPosition(this.conv);
+            this.group.updateContactPosition(
+              this.conv,
+              "chat-imconv-richlistitem"
+            );
           }
         }.bind(this),
       };
 
       this.initializeAttributeInheritance();
     }
 
     get displayName() {