Closed Bug 1520427 Opened 6 years ago Closed 3 years ago

The WebExtension MailFolder type should expose parent folders

Categories

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

enhancement

Tracking

(thunderbird_esr78 wontfix)

RESOLVED FIXED
91 Branch
Tracking Status
thunderbird_esr78 --- wontfix

People

(Reporter: Fallen, Assigned: TbSync)

References

Details

Attachments

(1 file)

Right now browser.accounts.list() will return accounts. The folders are a flat list of folders. The only way to guess what the relationship between folders is, is the path. The docs say that the path isn't predictable and shouldn't be relied on, so I think we need some way to know the hierarchical structure of the folders.

I think this is a bug we should prioritize, if we want to make major changes to the folders/accounts APIs we should do it as early as possible.

Priority: -- → P1
Priority: P1 → P2
See Also: → 1606584

Geoff, did bug 1606584 fix this?

Flags: needinfo?(geoff)

Sort of. We still have no link to parent folders, which is why this is still open.

Flags: needinfo?(geoff)

Updating the title to match what is still remaining.

Currently, for example, an add-on can get a folder for a message header, but would not be able to iterate up the path tree (e.g. to find the folder names or parent folders.

Summary: Folders list should expose the concept of parent/child folders → The WebExtension MailFolder type should expose parent folders

Requests / use cases for parent folders include:

  • get current hierarchy level
  • get all names of each parent folder
  • get the root folder

There are multiple ways to accomplish this

  1. Add a parentFolder property in MailFolder type, holding the MailFolder of the parent Folder. If no parent avail (=root), return null.

WebExt have to manually walk backwards to get all the information.

  1. Add a parentFolders property, being an array of MailFolders of all parent folders up to the root (flat ordered list)

No need to walk, all the information is right there.

  1. Instead of adding a property parentFolder, add a method getParentFolder

  2. Instead of adding a property parentFolders, add a method getParentFolders

What do you think? Did I forget something?

Flags: needinfo?(standard8)
Flags: needinfo?(geoff)

I think maybe a getParentFolders() method is probably best.

Having a property on MailFolder feels like it might be extra work in the API, that we don't always need. browser.accounts.list() can be quite slow, so doing the least work possible there would be best. It would also avoid unnecessary slowing down other functions that return folders.

Getting all the parents rather than just the one would also be nicer, since if you're iterating up, that's potentially what you're going to need anyway.

Flags: needinfo?(standard8)

Ok, option 4. Patch is coming.

Assignee: nobody → john
Status: NEW → ASSIGNED
Attachment #9230572 - Attachment description: Bug 1520427 - Add getParentFolders method to folders API. r=darktrojan → Bug 1520427 - Add getParentFolders and getSubFolders methods to folders API. r=darktrojan
Target Milestone: --- → 91 Branch

Pushed by mkmelin@iki.fi:
https://hg.mozilla.org/comm-central/rev/46773c2a2cf3
Add getParentFolders and getSubFolders methods to folders API. r=darktrojan

Status: ASSIGNED → RESOLVED
Closed: 3 years ago
Resolution: --- → FIXED
Regressions: 1720238
Flags: needinfo?(geoff)
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: