Bug 1559608 - When default account is disabled, pick first identity from menu popup instead of all identities. r=IanN DONTBUILD
authoraceman <acelists@atlas.sk>
Sun, 16 Jun 2019 00:49:30 +0200
changeset 35870 12611e8ca4489c44a3bb6e8c3c685117e6afbd87
parent 35869 a949ea7ada533248cdf0f93b3777f7e6597706b5
child 35871 2da4df6a339f3f26108d322f3e2917327991ab0f
push id392
push userclokep@gmail.com
push dateMon, 02 Sep 2019 20:17:19 +0000
reviewersIanN
bugs1559608
Bug 1559608 - When default account is disabled, pick first identity from menu popup instead of all identities. r=IanN DONTBUILD
suite/mailnews/components/compose/content/MsgComposeCommands.js
--- a/suite/mailnews/components/compose/content/MsgComposeCommands.js
+++ b/suite/mailnews/components/compose/content/MsgComposeCommands.js
@@ -1254,19 +1254,23 @@ function ComposeStartup(aParams)
 
   // An identity with no email is likely not valid.
   if (!params.identity || !params.identity.email) {
     let identities;
     // no pre selected identity, so use the default account
     let defaultAccount = gAccountManager.defaultAccount;
     if (defaultAccount)
       identities = defaultAccount.identities;
-    if (!identities || identities.length == 0)
-      identities = gAccountManager.allIdentities;
-    params.identity = identities.queryElementAt(0, Ci.nsIMsgIdentity);
+    if (identities && identities.length > 0) {
+      params.identity = identities.queryElementAt(0, Ci.nsIMsgIdentity);
+    } else {
+      // Get the first identity we have in the list.
+      let identitykey = identityList.getItemAtIndex(0).getAttribute("identitykey");
+      params.identity = MailServices.accounts.getIdentity(identitykey);
+    }
   }
 
   identityList.selectedItem =
     identityList.getElementsByAttribute("identitykey", params.identity.key)[0];
   if (params.composeFields.from)
     identityList.value = MailServices.headerParser.parseDecodedHeader(params.composeFields.from)[0].toString();
   LoadIdentity(true);
   if (sMsgComposeService)