Bug 1559608 - When default account is disabled, pick first identity from menu popup instead of all identities. r=jorgk
authoraceman <acelists@atlas.sk>
Sun, 16 Jun 2019 00:26:58 +0200
changeset 35869 a949ea7ada533248cdf0f93b3777f7e6597706b5
parent 35868 793a15b6f65edb4f04051913786b829178829e4e
child 35870 12611e8ca4489c44a3bb6e8c3c685117e6afbd87
push id392
push userclokep@gmail.com
push dateMon, 02 Sep 2019 20:17:19 +0000
reviewersjorgk
bugs1559608
Bug 1559608 - When default account is disabled, pick first identity from menu popup instead of all identities. r=jorgk
mail/components/compose/content/MsgComposeCommands.js
--- a/mail/components/compose/content/MsgComposeCommands.js
+++ b/mail/components/compose/content/MsgComposeCommands.js
@@ -2794,23 +2794,22 @@ function ComposeStartup(aParams) {
         }
       }
     }
 
     if (!params.identity || !params.identity.email) {
       let identity = null;
       // No preset identity and no match, so use the default account.
       let defaultAccount = MailServices.accounts.defaultAccount;
-      if (defaultAccount) {
+      if (defaultAccount)
         identity = defaultAccount.defaultIdentity;
-        if (!identity) {
-          let identities = MailServices.accounts.allIdentities;
-          if (identities.length > 0)
-            identity = identities.queryElementAt(0, Ci.nsIMsgIdentity);
-        }
+      if (!identity) {
+        // Get the first identity we have in the list.
+        let identitykey = identityList.getItemAtIndex(0).getAttribute("identitykey");
+        identity = MailServices.accounts.getIdentity(identitykey);
       }
       params.identity = identity;
     }
 
     // Warn if no or more than one match was found.
     // But don't warn for +suffix additions (a+b@c.com).
     if (from && (suitableCount > 1 ||
         (suitableCount == 0 && !emailSimilar(from, params.identity.email))))