Bug 1542667 - Copy selected identity's attributes when customising the From address. r=mkmelin
authorGeoff Lankow <geoff@darktrojan.net>
Thu, 27 Jun 2019 10:46:48 +1200
changeset 35963 a32a7dd507912e310334745f46a2788848b146e3
parent 35962 9f2d18f74b1517f68e06a96970ad0736aedce2a9
child 35964 94f38909bfab2a9a0ee5bf604d05993cf48e7afb
push id392
push userclokep@gmail.com
push dateMon, 02 Sep 2019 20:17:19 +0000
reviewersmkmelin
bugs1542667
Bug 1542667 - Copy selected identity's attributes when customising the From address. r=mkmelin
mail/components/compose/content/MsgComposeCommands.js
--- a/mail/components/compose/content/MsgComposeCommands.js
+++ b/mail/components/compose/content/MsgComposeCommands.js
@@ -4066,23 +4066,22 @@ function FillIdentityList(menulist) {
   menulist.menupopup.appendChild(document.createXULElement("menuseparator"));
   menulist.menupopup.appendChild(document.createXULElement("menuitem"))
           .setAttribute("command", "cmd_customizeFromAddress");
 }
 
 function getCurrentAccountKey() {
   // Get the account's key.
   let identityList = GetMsgIdentityElement();
-  return identityList.selectedItem.getAttribute("accountkey");
+  return identityList.getAttribute("accountkey");
 }
 
 function getCurrentIdentityKey() {
   // Get the identity key.
-  let identityList = GetMsgIdentityElement();
-  return identityList.selectedItem.getAttribute("identitykey");
+  return gCurrentIdentity.key;
 }
 
 function getIdentityForKey(key) {
   return MailServices.accounts.getIdentity(key);
 }
 
 function getCurrentIdentity() {
   return getIdentityForKey(getCurrentIdentityKey());
@@ -5492,22 +5491,25 @@ function hideIrrelevantAddressingOptions
   }
 }
 
 function LoadIdentity(startup) {
   var identityElement = document.getElementById("msgIdentity");
   var prevIdentity = gCurrentIdentity;
 
   if (identityElement) {
-    var idKey = identityElement.selectedItem.getAttribute("identitykey");
-    gCurrentIdentity = MailServices.accounts.getIdentity(idKey);
-
+    let idKey = null;
     let accountKey = null;
-    // Set the account key value on the menu list.
     if (identityElement.selectedItem) {
+      // Set the identity key value on the menu list.
+      idKey = identityElement.selectedItem.getAttribute("identitykey");
+      identityElement.setAttribute("identitykey", idKey);
+      gCurrentIdentity = MailServices.accounts.getIdentity(idKey);
+
+      // Set the account key value on the menu list.
       accountKey = identityElement.selectedItem.getAttribute("accountkey");
       identityElement.setAttribute("accountkey", accountKey);
       hideIrrelevantAddressingOptions(accountKey);
     }
 
     let maxRecipients = awGetNumberOfRecipients();
     for (let i = 1; i <= maxRecipients; i++) {
       let params = JSON.parse(awGetInputElement(i).searchParam);