Bug 726281 - Remove References header before saving as template. r=aceman a=rkent
authorJorg K <mozilla@jorgk.com>
Tue, 19 Jul 2016 08:52:58 +0200
changeset 24772 0b0c555b35cbbf2de9c1699544bf5e3157d4129f
parent 24771 11823ddb88f048173b3a053f7e6e43468d378ed1
child 24773 8b518a8a65154dcff554fb481fdade5b9b45daff
push id81
push userkent@caspia.com
push dateFri, 23 Sep 2016 00:36:03 +0000
treeherdercomm-esr45@9b6e406c4875 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersaceman, rkent
bugs726281
Bug 726281 - Remove References header before saving as template. r=aceman a=rkent
mail/components/compose/content/MsgComposeCommands.js
--- a/mail/components/compose/content/MsgComposeCommands.js
+++ b/mail/components/compose/content/MsgComposeCommands.js
@@ -3015,18 +3015,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;