Bug 1617448 - Rename composeParams variable to details to avoid confusion. r=mkmelin
authorGeoff Lankow <geoff@darktrojan.net>
Tue, 31 Mar 2020 14:20:30 +1300
changeset 38649 b2b96ec63aff658f33e49832cd828aaf19d80a94
parent 38648 7b54036ce7d67afa8361606c720287e5710b4775
child 38650 83b898e3dfb2017a173b8fcc91a89e2aa3a625fe
push id400
push userclokep@gmail.com
push dateMon, 04 May 2020 18:56:09 +0000
reviewersmkmelin
bugs1617448
Bug 1617448 - Rename composeParams variable to details to avoid confusion. r=mkmelin
mail/components/extensions/parent/ext-compose.js
--- a/mail/components/extensions/parent/ext-compose.js
+++ b/mail/components/extensions/parent/ext-compose.js
@@ -39,17 +39,17 @@ async function parseComposeRecipientList
         );
       }
     }
     return recipients.join(",");
   }
   return list;
 }
 
-async function openComposeWindow(relatedMessageId, type, composeParams) {
+async function openComposeWindow(relatedMessageId, type, details) {
   function waitForWindow() {
     return new Promise(resolve => {
       function observer(subject, topic, data) {
         if (
           subject.location.href ==
           "chrome://messenger/content/messengercompose/messengercompose.xhtml"
         ) {
           Services.obs.removeObserver(observer, "chrome-document-loaded");
@@ -89,53 +89,51 @@ async function openComposeWindow(related
     "@mozilla.org/messengercompose/composefields;1"
   ].createInstance(Ci.nsIMsgCompFields);
 
   if (relatedMessageId) {
     let msgHdr = messageTracker.getMessage(relatedMessageId);
     params.originalMsgURI = msgHdr.folder.getUriForMsg(msgHdr);
   }
   params.type = type;
-  if (composeParams) {
-    if (composeParams.body !== null) {
-      if (composeParams.plainTextBody !== null) {
+  if (details) {
+    if (details.body !== null) {
+      if (details.plainTextBody !== null) {
         throw new ExtensionError(
           "Only one of body and plainTextBody can be specified."
         );
       }
-      if (composeParams.isPlainText) {
+      if (details.isPlainText) {
         throw new ExtensionError(
           "Cannot specify body when isPlainText is true. Use plainTextBody instead."
         );
       }
     }
 
     for (let field of ["to", "cc", "bcc", "replyTo", "followupTo"]) {
-      composeFields[field] = await parseComposeRecipientList(
-        composeParams[field]
-      );
+      composeFields[field] = await parseComposeRecipientList(details[field]);
     }
-    if (composeParams.newsgroups) {
-      if (Array.isArray(composeParams.newsgroups)) {
-        composeFields.newsgroups = composeParams.newsgroups.join(",");
+    if (details.newsgroups) {
+      if (Array.isArray(details.newsgroups)) {
+        composeFields.newsgroups = details.newsgroups.join(",");
       } else {
-        composeFields.newsgroups = composeParams.newsgroups;
+        composeFields.newsgroups = details.newsgroups;
       }
     }
-    if (composeParams.subject !== null) {
-      composeFields.subject = composeParams.subject;
+    if (details.subject !== null) {
+      composeFields.subject = details.subject;
     }
-    if (composeParams.body !== null) {
-      composeFields.body = composeParams.body;
+    if (details.body !== null) {
+      composeFields.body = details.body;
     }
-    if (composeParams.plainTextBody != null) {
-      if (composeParams.isPlainText) {
+    if (details.plainTextBody != null) {
+      if (details.isPlainText) {
         params.format = Ci.nsIMsgCompFormat.PlainText;
       }
-      composeFields.body = composeParams.plainTextBody;
+      composeFields.body = details.plainTextBody;
     }
   }
 
   params.composeFields = composeFields;
 
   let newWindowPromise = waitForWindow();
   MailServices.compose.OpenComposeWindowWithParams(null, params);
   return newWindowPromise;
@@ -271,39 +269,39 @@ this.compose = class extends ExtensionAP
             };
 
             composeEventTracker.on("compose-before-send", listener);
             return () => {
               composeEventTracker.off("compose-before-send", listener);
             };
           },
         }).api(),
-        beginNew(composeParams) {
-          return openComposeWindow(null, Ci.nsIMsgCompType.New, composeParams);
+        beginNew(details) {
+          return openComposeWindow(null, Ci.nsIMsgCompType.New, details);
         },
         beginReply(messageId, replyType) {
           let type = Ci.nsIMsgCompType.Reply;
           if (replyType == "replyToList") {
             type = Ci.nsIMsgCompType.ReplyToList;
           } else if (replyType == "replyToAll") {
             type = Ci.nsIMsgCompType.ReplyAll;
           }
           return openComposeWindow(messageId, type);
         },
-        beginForward(messageId, forwardType, composeParams) {
+        beginForward(messageId, forwardType, details) {
           let type = Ci.nsIMsgCompType.ForwardInline;
           if (forwardType == "forwardAsAttachment") {
             type = Ci.nsIMsgCompType.ForwardAsAttachment;
           } else if (
             forwardType === null &&
             Services.prefs.getIntPref("mail.forward_message_mode") == 0
           ) {
             type = Ci.nsIMsgCompType.ForwardAsAttachment;
           }
-          return openComposeWindow(messageId, type, composeParams);
+          return openComposeWindow(messageId, type, details);
         },
         getComposeDetails(tabId) {
           let tab = getComposeTab(tabId);
           return getComposeDetails(tab.nativeTab);
         },
         setComposeDetails(tabId, details) {
           let tab = getComposeTab(tabId);
           return setComposeDetails(tab.nativeTab, details);