Open Bug 1520425 Opened 6 years ago Updated 2 years ago

Folder query API

Categories

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

enhancement

Tracking

(Not tracked)

People

(Reporter: Fallen, Unassigned)

References

Details

We have https://searchfox.org/comm-central/source/mailnews/base/util/folderUtils.jsm#171 which gives us the most recently used folders. I think we should consider exposing this as an API.

On the upside, doing so would allow us to define our own touch points for when a folder becomes recent, and add-ons using this API would have access to the same list.

On the downside, extensions could also just implement this on their own if they have an event when a folder is selected or otherwise becomes recent.

This bug could also be morphed to provide a query function for folders in accounts with specific limitations, e.g. they are recent, or contain a substring, etc.

How about this:

browser.folders.query({
  accountId: 123,          // Folders of a specific account
  recent: true,            // If specified, folders will be sorted by most recent folder and only recent will be returned
  favorite: true,          // Folder is marked favorite
  unread: true,            // Has unread messages. Not sure if we want to provide a min/max unread, I'm thinking not.
  type: "folder"           // MailFolder type
});
Flags: needinfo?(geoff)

Another query mode that we may be able to fit in:

// Get the folder(s) selected in the current window
browser.folders.query({ windowId: browser.windows.WINDOW_ID_CURRENT, active: true });

This might conflict with the recent option, so maybe having a separate browser.folders.getRecent() would actually make more sense.

Summary: Most recently used folders API → Folder query API

It would be good to be able to find a folder matching certain properties. Finding the current one is possible already through the mailTabs API, so I don't think we need that.

Flags: needinfo?(geoff)
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.