Bug 1354822 - For an empty group, like undisclosed-recipients, display group name in the thread pane (and other misc. fixes). r=aceman a=jorgk
authorJorg K <jorgk@jorgk.com>
Mon, 10 Apr 2017 00:33:40 +0200
changeset 24459 3ba871050cc7
parent 24458 bd921bdc8b03
child 24460 a96b63bf7d0f
push id2055
push usermozilla@jorgk.com
push dateWed, 12 Apr 2017 15:22:52 +0000
treeherdercomm-aurora@d3970dc6cd9c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersaceman, jorgk
bugs1354822
Bug 1354822 - For an empty group, like undisclosed-recipients, display group name in the thread pane (and other misc. fixes). r=aceman a=jorgk
mail/base/content/mailWidgets.xml
mail/base/content/msgHdrViewOverlay.js
mailnews/base/src/nsMsgDBView.cpp
--- a/mail/base/content/mailWidgets.xml
+++ b/mail/base/content/mailWidgets.xml
@@ -605,32 +605,32 @@
       </method>
 
       <!-- updateEmailAddressNode: private method used to set properties on an address node -->
       <method name="updateEmailAddressNode">
         <parameter name="aEmailNode"/>
         <parameter name="aAddress"/>
         <body>
           <![CDATA[
-            aEmailNode.setAttribute("label", aAddress.fullAddress || aAddress.displayName);
+            aEmailNode.setAttribute("label", aAddress.fullAddress || aAddress.displayName || "");
             aEmailNode.removeAttribute("tooltiptext");
             aEmailNode.setAttribute("emailAddress", aAddress.emailAddress || "");
             aEmailNode.setAttribute("fullAddress", aAddress.fullAddress || "");
             aEmailNode.setAttribute("displayName", aAddress.displayName || "");
 
             // Since the control attribute points to the
             // <mail-multi-emailHeaderField> element rather than the XUL
             // <mail-emailaddress>, screen readers don't know to automagically
             // prepend the label when reading the tag, so we force this.
             // Furthermore, at least on Mac, there is no JS labelElement
             // property at all, so we skip in that case.  We get away with it
             // because there's no screen reader support on the Mac.
             if ("labelElement" in this) {
                 let ariaLabel = this.labelElement.value + ": " +
-                                aAddress.fullAddress || aAddress.displayName;
+                                (aAddress.fullAddress || aAddress.displayName || "");
                 aEmailNode.setAttribute("aria-label", ariaLabel);
             }
 
             try
             {
               if (("UpdateEmailNodeDetails" in top) && aAddress.emailAddress)
                 UpdateEmailNodeDetails(aAddress.emailAddress, aEmailNode);
             }
--- a/mail/base/content/msgHdrViewOverlay.js
+++ b/mail/base/content/msgHdrViewOverlay.js
@@ -1417,32 +1417,32 @@ function UpdateExtraAddressProcessing(aA
     if (aItem instanceof nsIAbDirectory) {
       // If we don't have a match, search again for updates (e.g. a interface
       // to an existing book may just have been added).
       if (!aDocumentNode.cardDetails.card)
         UpdateEmailNodeDetails(aAddressData.emailAddress, aDocumentNode);
     }
     else if (aItem instanceof nsIAbCard) {
       // If we don't have a card, does this new one match?
-      if (!aDocumentNode.cardDetails.card &&
+      if (aDocumentNode.cardDetails && !aDocumentNode.cardDetails.card &&
           aItem.hasEmailAddress(aAddressData.emailAddress)) {
         // Just in case we have a bogus parent directory.
         if (aParentDir instanceof nsIAbDirectory) {
           var cardDetails = { book: aParentDir, card: aItem };
           UpdateEmailNodeDetails(aAddressData.emailAddress, aDocumentNode,
                                  cardDetails);
         } else {
           UpdateEmailNodeDetails(aAddressData.emailAddress, aDocumentNode);
         }
       }
     }
     break;
   case nsIAbListener.directoryItemRemoved:
     // Unfortunately we don't necessarily get the same card object back.
-    if (aAddressData &&
+    if (aAddressData && aDocumentNode.cardDetails &&
         aDocumentNode.cardDetails.card &&
         aDocumentNode.cardDetails.book == aParentDir &&
         aItem.hasEmailAddress(aAddressData.emailAddress)) {
       UpdateEmailNodeDetails(aAddressData.emailAddress, aDocumentNode);
     }
     break;
   case nsIAbListener.directoryRemoved:
     if (aDocumentNode.cardDetails.book == aItem)
@@ -1475,17 +1475,17 @@ function hideEmailNewsPopup(addressNode)
 
 function setupEmailAddressPopup(emailAddressNode)
 {
   var emailAddressPlaceHolder = document.getElementById("emailAddressPlaceHolder");
   var emailAddress = emailAddressNode.getPart("emaillabel").value;
   emailAddressNode.setAttribute("selected", "true");
   emailAddressPlaceHolder.setAttribute("label", emailAddress);
 
-  if (emailAddressNode.cardDetails.card) {
+  if (emailAddressNode.cardDetails && emailAddressNode.cardDetails.card) {
     document.getElementById("addToAddressBookItem").setAttribute("hidden", true);
     if (!emailAddressNode.cardDetails.book.readOnly) {
       document.getElementById("editContactItem").removeAttribute("hidden");
       document.getElementById("viewContactItem").setAttribute("hidden", true);
     } else {
       document.getElementById("editContactItem").setAttribute("hidden", true);
       document.getElementById("viewContactItem").removeAttribute("hidden");
     }
--- a/mailnews/base/src/nsMsgDBView.cpp
+++ b/mailnews/base/src/nsMsgDBView.cpp
@@ -525,16 +525,24 @@ nsresult nsMsgDBView::FetchRecipients(ns
 
     // add ', ' between each recipient
     if (i != 0)
       aRecipientsString.Append(NS_LITERAL_STRING(", "));
 
     aRecipientsString.Append(recipient);
   }
 
+  if (numAddresses == 0 && unparsedRecipients.FindChar(':') != kNotFound) {
+    // No addresses and a colon, so an empty group like "undisclosed-recipients: ;".
+    // Add group name so at least something displays.
+    nsString group;
+    CopyUTF8toUTF16(unparsedRecipients, group);
+    aRecipientsString.Assign(group);
+  }
+
   UpdateCachedName(aHdr, "recipient_names", aRecipientsString);
 
   return NS_OK;
 }
 
 nsresult nsMsgDBView::FetchSubject(nsIMsgDBHdr * aMsgHdr, uint32_t aFlags, nsAString &aValue)
 {
   if (aFlags & nsMsgMessageFlags::HasRe)