Closed Bug 1520425 Opened 6 years ago Closed 1 year ago

Folder query API

Categories

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

enhancement

Tracking

(thunderbird_esr115 wontfix)

RESOLVED FIXED
121 Branch
Tracking Status
thunderbird_esr115 --- wontfix

People

(Reporter: Fallen, Assigned: TbSync)

References

Details

Attachments

(3 files)

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
Assignee: nobody → john
Status: NEW → ASSIGNED

Depends on D191729

Attachment #9359977 - Attachment description: 48888:656b36391db9 john tip Bug 1520425 - Add folders.query(). r=#thunderbird-reviewers → Bug 1520425 - Add folders.query(). r=#thunderbird-reviewers

I just found bug 1840039, where @:Fallen adds the following information:

It would be great to have messenger.folders.query to search for folders that match criteria. I haven't thought out all the use cases, but here are my immediate needs for quickmove:

recent: true - a special mode that will return recent folders by MRUTime.
limit: NNN - limit the number of folders to return
canFileMessages: true - only return folders where messages can be filed in

Here are a few others from nsIMsgFolder that might make sense, though we certainly don't have to implement all of them:

canSubscribe
canDeleteMessages
deletable
canCreateSubfolders
canRename
hasNewMessages
folder type
hasSubfolers

Here is a crude start: https://github.com/kewisch/quickmove-extension/blob/7f9ac419d30f48649ff15fef45d9f672b439402c/api/api.js#L90

Duplicate of this bug: 1840039
Attachment #9360074 - Attachment description: Bug 1520425 - Expose MailFolderInfo.lastAccessed. r=#thunderbird-reviewers → Bug 1520425 - Expose MailFolderInfo.lastUsed. r=#thunderbird-reviewers
Attachment #9360074 - Attachment description: Bug 1520425 - Expose MailFolderInfo.lastUsed. r=#thunderbird-reviewers → Bug 1520425 - Expose folder more properties. r=mkmelin
Attachment #9359977 - Attachment description: Bug 1520425 - Add folders.query(). r=#thunderbird-reviewers → WIP: Bug 1520425 - Add folders.query().
Attachment #9360074 - Attachment description: Bug 1520425 - Expose folder more properties. r=mkmelin → Bug 1520425 - Expose more folder properties and capabilities. r=mkmelin
Attachment #9359977 - Attachment description: WIP: Bug 1520425 - Add folders.query(). → Bug 1520425 - Add folders.query(). r=#thunderbird-reviewers
Duplicate of this bug: 1859040
Depends on: 1860583
Target Milestone: --- → 121 Branch

Pushed by solange@thunderbird.net:
https://hg.mozilla.org/comm-central/rev/e4c417a964c9
Move getFolder() in ExtensionAccounts.sys.mjs. r=mkmelin
https://hg.mozilla.org/comm-central/rev/34adc3a0db1f
Expose more folder properties and capabilities. r=mkmelin
https://hg.mozilla.org/comm-central/rev/dcc508446845
Add folders.query(). r=mkmelin

Status: ASSIGNED → RESOLVED
Closed: 1 year ago
Resolution: --- → FIXED

search bugmail for "addons1234" to delete these messages

You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: