Closed Bug 1681141 Opened 5 years ago Closed 5 years ago

Add accounts.getDefault and accounts.getDefaultIdentity to accounts API

Categories

(Thunderbird :: Add-Ons: Extensions API, enhancement)

enhancement

Tracking

(thunderbird_esr78 fixed)

RESOLVED FIXED
85 Branch
Tracking Status
thunderbird_esr78 --- fixed

People

(Reporter: TbSync, Assigned: TbSync)

References

Details

Attachments

(1 file, 2 obsolete files)

With bug 1681023 the default compose mode of the used/default identity is mostly ignored so that add-on code has a consistent behavior. This bug adds the accounts.getDefault() and accounts.getDefaultIdentity(accountId) methods to be able to access the default compose mode of the default identity.

Attachment #9191700 - Flags: review?(geoff)
Comment on attachment 9191700 [details] [diff] [review] bug1681141_add_getDefault_and_getDefaultIdentity.patch Review of attachment 9191700 [details] [diff] [review]: ----------------------------------------------------------------- ::: mail/components/extensions/parent/ext-accounts.js @@ +59,5 @@ > + let account = MailServices.accounts.defaultAccount; > + if (account) { > + return convertAccount(account); > + } > + return null; Let's fix convertAccount so that it returns null if null is passed to it. @@ +66,5 @@ > + let account = await this.get(accountId); > + if (account && account.identities?.length > 0) { > + return account.identities[0]; > + } > + return null; I'd prefer to keep methods in an API separate where possible. This is cute but it does a bunch of extra work which just gets thrown away. ::: mail/components/extensions/test/xpcshell/test_ext_accounts.js @@ +16,5 @@ > + let defaultAccount = await browser.accounts.getDefault(); > + browser.test.assertEq( > + null, > + defaultAccount, > + `The default account should be null, as none is defined.` Use double quotes here, as there's no reason to use backquotes.
Attachment #9191700 - Flags: review?(geoff) → review-

Also made convertMailIdentity return null if no identity given.

Attachment #9191700 - Attachment is obsolete: true
Attachment #9191843 - Flags: review?(geoff)

Comment on attachment 9191843 [details] [diff] [review]
bug1681141_add_getDefault_and_getDefaultIdentity_v2.patch

I think convertMailIdentity should return null if account is null too, on the off-chance we give it an identity but not an account.

Attachment #9191843 - Flags: review?(geoff) → review+

Also check for !account in convertMailIdentity().

Attachment #9191843 - Attachment is obsolete: true
Attachment #9192132 - Flags: review+
Target Milestone: --- → 85 Branch

Pushed by mkmelin@iki.fi:
https://hg.mozilla.org/comm-central/rev/6e53e1c7831a
Add accounts.getDefault and accounts.getDefaultIdentity to accounts API. r=darktrojan

Status: ASSIGNED → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED

Comment on attachment 9192132 [details] [diff] [review]
bug1681141_add_getDefault_and_getDefaultIdentity_v3.patch

[Approval Request Comment]
User impact if declined:
Add-on developers can not use the latest fixes and improvements of our WebExtension API.

Testing completed (on c-c, etc.):
https://treeherder.mozilla.org/jobs?repo=try-comm-central&revision=3cdff293d5d1bd77777f5da371caaa02c4b05de3

Risk to taking this patch (and alternatives if risky):
I hope none

Remark:
The provided try run includes all bugs I want to uplift for TB 78.7 and shows a working patch order.
The first one, which does not have a bug number in the commit messages is Bug 1680653.
This bug is the 10th one.

Attachment #9192132 - Flags: approval-comm-esr78?

Comment on attachment 9192132 [details] [diff] [review]
bug1681141_add_getDefault_and_getDefaultIdentity_v3.patch

[Triage Comment]
Approved for esr78

Attachment #9192132 - Flags: approval-comm-esr78? → approval-comm-esr78+
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: