Bug 1526985 - Part 1: Add support for multiple authors (add "et al" to summary views). r=mkmelin,jorgk
authoralta88@fixall.com
Fri, 19 Apr 2019 11:41:54 -0400
changeset 26617 5806b067a6a1277fb418ac27b88fbaf062de0a52
parent 26616 13360f79c2b5d776dc9e9736fcd0e915edb5fcdf
child 26618 f2aa9a4e1426738e9c21363660bba4fa453e8f3e
push id15922
push usermozilla@jorgk.com
push dateWed, 15 May 2019 21:48:05 +0000
treeherdercomm-central@5806b067a6a1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmkmelin, jorgk
bugs1526985
Bug 1526985 - Part 1: Add support for multiple authors (add "et al" to summary views). r=mkmelin,jorgk
mail/base/content/foldersummary.js
mail/base/modules/DisplayNameUtils.jsm
--- a/mail/base/content/foldersummary.js
+++ b/mail/base/content/foldersummary.js
@@ -19,16 +19,18 @@ var {MailUtils} = ChromeUtils.import("re
 class MozFolderSummary extends MozXULElement {
   constructor() {
     super();
     this.maxMsgHdrsInPopup = 8;
 
     this.showSubject = Services.prefs.getBoolPref("mail.biff.alert.show_subject");
     this.showSender = Services.prefs.getBoolPref("mail.biff.alert.show_sender");
     this.showPreview = Services.prefs.getBoolPref("mail.biff.alert.show_preview");
+    this.messengerBundle = Services.strings.createBundle(
+                             "chrome://messenger/locale/messenger.properties");
   }
 
   hasMessages() {
     return this.hasChildNodes();
   }
 
   parseFolder(folder, urlListener, outAsync) {
     // skip servers, Trash, Junk folders and newsgroups
@@ -128,18 +130,23 @@ class MozFolderSummary extends MozXULEle
             msgSubject = (msgSubject) ? "Re: " + msgSubject : "Re: ";
           }
           msgPopup.querySelector(".folderSummary-subject").textContent = msgSubject;
         }
 
         if (this.showSender) {
           let addrs = MailServices.headerParser.parseEncodedHeader(
             msgHdr.author, msgHdr.effectiveCharset, false);
-          msgPopup.querySelector(".folderSummary-sender").textContent =
+          let folderSummarySender = msgPopup.querySelector(".folderSummary-sender");
+          folderSummarySender.textContent =
             (addrs.length > 0) ? (addrs[0].name || addrs[0].email) : "";
+          if (addrs.length > 1) {
+            let andOthersStr = this.messengerBundle.GetStringFromName("andOthers");
+            folderSummarySender.textContent += " " + andOthersStr;
+          }
         }
 
         if (this.showPreview && msgHdr.getProperty("preview")) {
           // Get the preview text as a UTF-8 encoded string.
           msgPopup.querySelector(".folderSummary-previewText").textContent =
             decodeURIComponent(escape(msgHdr.getStringProperty("preview")));
         }
         this.appendChild(msgPopup);
--- a/mail/base/modules/DisplayNameUtils.jsm
+++ b/mail/base/modules/DisplayNameUtils.jsm
@@ -117,22 +117,26 @@ function formatDisplayName(aEmailAddress
  * @param aContext      The context of the header field (e.g. "to", "from").
  * @return The formatted display name.
  */
 function formatDisplayNameList(aHeaderValue, aContext) {
   let addresses = MailServices.headerParser.parseDecodedHeader(aHeaderValue);
   if (addresses.length > 0) {
     let displayName = formatDisplayName(addresses[0].email,
                                         addresses[0].name, aContext);
+    let andOthersStr = "";
+    if (addresses.length > 1)
+      andOthersStr = " " + gMessengerBundle.getString("andOthers");
+
     if (displayName)
-      return displayName;
+      return displayName + andOthersStr;
 
     // Construct default display.
     if (addresses[0].email) {
       return MailServices.headerParser
-                         .makeMailboxObject(addresses[0].name,
-                                            addresses[0].email).toString();
+                         .makeMailboxObject(addresses[0].name, addresses[0].email)
+                         .toString() + andOthersStr;
     }
   }
 
   // Something strange happened, just return the raw header value.
   return aHeaderValue;
 }