WebExtension experiments don't have access to the addressBookCache
Categories
(Thunderbird :: Add-Ons: Extensions API, defect)
Tracking
(Not tracked)
People
(Reporter: standard8, Assigned: darktrojan)
Details
Attachments
(1 file)
|
9.95 KB,
patch
|
mkmelin
:
review+
|
Details | Diff | Splinter Review |
As far as I can tell, the extension context doesn't make the addressBookCache available. This makes it hard for authors to design experiment APIs where we pass in the contact id.
| Reporter | ||
Updated•6 years ago
|
| Assignee | ||
Comment 1•6 years ago
|
||
I was looking in to fixing this when I discovered that you can access APIs from an experiment through context.apiObj, so listing the address books would be context.apiObj.addressBooks.list().
It calls the function directly rather than going through the WE mechanisms so you may get a result returned immediately where you'd get a Promise the normal way. In the case of the address book APIs especially I expect at least some of them will become asynchronous in the near future (due to the address book work) so it's probably best to just use await everywhere.
| Reporter | ||
Comment 2•6 years ago
|
||
(In reply to Geoff Lankow (:darktrojan) from comment #1)
I was looking in to fixing this when I discovered that you can access APIs from an experiment through
context.apiObj, so listing the address books would becontext.apiObj.addressBooks.list().
I guess you realise this as you haven't closed the bug, but this isn't enough to make the API easy / performant. Generally I'd like to pass the id through, then via the cache to get the nsIAbCard to pass to other core functions. Whilst I can look it up again via name/email, that isn't guaranteed to get the same card as I had before.
| Assignee | ||
Comment 3•6 years ago
|
||
That's a fair point. I was somewhat forgetting that the API's functions return a WE-friendly version of the object rather than the object itself.
I expect that the most useful parts would be findAddressBookById, findMailingListById, findContactById (and maybe convert if you'd ever want to return something from the API). Is there anything else you think would be worth having?
(Incidentally I'm kinda hoping the find…ById functions become redundant when the address book work finally gets some traction.)
| Reporter | ||
Comment 4•6 years ago
|
||
Yeah, they would probably be the most useful.
| Assignee | ||
Comment 5•6 years ago
|
||
This gives experiments access to the three "find" functions and convert. I've also tidied up the experiment test by converting the embedded file to a function so that it can be linted properly.
Comment 6•6 years ago
|
||
| Assignee | ||
Updated•6 years ago
|
Updated•6 years ago
|
Pushed by mkmelin@iki.fi:
https://hg.mozilla.org/comm-central/rev/36da94e8ddb4
Give WebExtension experiments access to addressBookCache. r=mkmelin DONTBUILD
Description
•