Bug 726281 - Remove References header before saving as template. r=aceman
authorJorg K <mozilla@jorgk.com>
Tue, 19 Jul 2016 08:52:58 +0200
changeset 19593 bbdd29586adf74c06080201b03e83a68261efbc9
parent 19592 5fdf4efb7ad1eacc425f26ce61647d5156c4a036
child 19594 e8d79693a47abcb6d70eab7f9e2ebbc7bd815bba
push id12087
push usermozilla@jorgk.com
push dateTue, 19 Jul 2016 06:56:31 +0000
treeherdercomm-central@bbdd29586adf [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersaceman
bugs726281
Bug 726281 - Remove References header before saving as template. r=aceman
mail/components/compose/content/MsgComposeCommands.js
--- a/mail/components/compose/content/MsgComposeCommands.js
+++ b/mail/components/compose/content/MsgComposeCommands.js
@@ -3079,18 +3079,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;