Bug 1322473 - Ensure the selected conversation hasn't changed before updating the log list. r=clokep
authoraleth <aleth@instantbird.org>
Sun, 08 Jan 2017 02:30:24 +0100
changeset 20999 7b3948ead9381fa9c7fd7b1ba0a76b06c4f7395a
parent 20998 6e08e4db98838348b9dbc54fe83f25e195a91096
child 21000 b0e38b2324c339f3e765ab8f63acabf10cbaaa73
push id12739
push useraleth@instantbird.org
push dateWed, 11 Jan 2017 23:06:31 +0000
treeherdercomm-central@b0e38b2324c3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersclokep
bugs1322473
Bug 1322473 - Ensure the selected conversation hasn't changed before updating the log list. r=clokep
mail/components/im/content/chat-messenger-overlay.js
--- a/mail/components/im/content/chat-messenger-overlay.js
+++ b/mail/components/im/content/chat-messenger-overlay.js
@@ -622,17 +622,18 @@ var chatHandler = {
     // We only care about single clicks of the left button.
     if (aEvent.button != 0 || aEvent.detail != 1)
       return;
     let item = document.getElementById("contactlistbox").selectedItem;
     if (item.localName == "imconv" && item.convView)
       item.convView.focus();
   },
   onListItemSelected: function() {
-    let item = document.getElementById("contactlistbox").selectedItem;
+    let contactlistbox = document.getElementById("contactlistbox");
+    let item = contactlistbox.selectedItem;
     if (!item || item.hidden || item.localName == "imgroup") {
       this._hideContextPane(true);
       document.getElementById("conversationsDeck").selectedPanel =
         document.getElementById("noConvScreen");
       this.updateTitle();
       this.observedContact = null;
       return;
     }
@@ -653,16 +654,18 @@ var chatHandler = {
       cti.removeAttribute("topicEditable");
       cti.removeAttribute("noTopic");
       this.observedContact = null;
 
       let path = "logs/" + item.log.path;
       path = OS.Path.join(OS.Constants.Path.profileDir, ...path.split("/"));
       imServices.logs.getLogFromFile(path, true).then(aLog => {
         imServices.logs.getSimilarLogs(aLog, true).then(aSimilarLogs => {
+          if (contactlistbox.selectedItem != item)
+            return;
           this._pendingSearchTerm = item.searchTerm || undefined;
           this._showLogList(aSimilarLogs, aLog);
         });
       });
     }
     else if (item.localName == "imconv") {
       let convDeck = document.getElementById("conversationsDeck");
       if (!item.convView) {
@@ -680,16 +683,18 @@ var chatHandler = {
       else
         item.convView.onConvResize();
 
       convDeck.selectedPanel = item.convView;
       item.convView.updateConvStatus();
       item.update();
 
       imServices.logs.getLogsForConversation(item.conv, true).then(aLogs => {
+        if (contactlistbox.selectedItem != item)
+          return;
         this._showLogList(aLogs);
       });
 
       let contextPane = document.getElementById("contextPane");
       if (item.conv.isChat) {
         contextPane.setAttribute("chat", "true");
         item.convView.showParticipants();
       }
@@ -711,16 +716,18 @@ var chatHandler = {
                 // Return early to avoid flickering and changing the selected log.
 
       this.showContactInfo(contact);
       this.observedContact = contact;
 
       document.getElementById("contextPane").removeAttribute("chat");
 
       imServices.logs.getLogsForContact(contact, true).then(aLogs => {
+        if (contactlistbox.selectedItem != item)
+          return;
         if (!this._showLogList(aLogs, true)) {
           document.getElementById("conversationsDeck").selectedPanel =
             document.getElementById("logDisplay");
           document.getElementById("logDisplayDeck").selectedPanel =
             document.getElementById("noPreviousConvScreen");
         }
       });
     }