Bug 726281 - Remove References header before saving as template. r=aceman a=jorgk
authorJorg K <mozilla@jorgk.com>
Tue, 19 Jul 2016 08:52:58 +0200
changeset 27308 c9d810bd10a1041815129057a03639ca8f820cf2
parent 27307 8667c168bc247cc85e2d6aab45350016daa81922
child 27309 cf2e3d47bb06e72babd689cc451f1fb5cf43cc4c
push id1850
push userclokep@gmail.com
push dateWed, 08 Mar 2017 19:29:12 +0000
treeherdercomm-esr52@028df196b2d9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersaceman, jorgk
bugs726281
Bug 726281 - Remove References header before saving as template. r=aceman a=jorgk
mail/components/compose/content/MsgComposeCommands.js
--- a/mail/components/compose/content/MsgComposeCommands.js
+++ b/mail/components/compose/content/MsgComposeCommands.js
@@ -3029,18 +3029,32 @@ function SaveAsDraft()
   defaultSaveOperation = "draft";
 }
 
 function SaveAsTemplate()
 {
   gAutoSaveKickedIn = false;
   gEditingDraft = false;
 
+  let savedPreferences = null;
+  if (gMsgCompose && gMsgCompose.compFields) {
+    // Clear References header. When we use the template, we don't want that
+    // header, yet, "edit as new message" maintains it. So we need to clear
+    // it when saving the template.
+    // Note: The In-Reply-To header is the last entry in the references header,
+    // so it will get cleared as well.
+    savedPreferences = gMsgCompose.compFields.references;
+    gMsgCompose.compFields.references = null;
+  }
+
   GenericSendMessage(nsIMsgCompDeliverMode.SaveAsTemplate);
   defaultSaveOperation = "template";
+
+  if (savedPreferences)
+    gMsgCompose.compFields.references = savedPreferences;
 }
 
 // Sets the additional FCC, in addition to the default FCC.
 function MessageFcc(aFolder)
 {
   if (!gMsgCompose)
     return;