Thunderbird/NextGeneration/Collections: Difference between revisions

Smart folders
(Sample code for 3 pane window)
(Smart folders)
Line 74: Line 74:


This is most the UI code necessary for basic message reading.
This is most the UI code necessary for basic message reading.
If new messages arrive, or the user creates a new folder, the UI will be automatically updated. That's all in the above code, thanks to the collection classes and the generic list widget.
== Smart folders ==
Smart folders that update immediately when the underlying folders change are also possible with the Collection classes. Given that Collections can merge and subtract collections and dynamically update the result list of these operations, displaying a smart folder is just a matter of assigning the right collection to the message list.
For example, to show all mails from 2 inboxes:
var globalInbox = mergeColl(account1.inbox.messages, account2.inbox.messages);
gMessageListE.showCollection(globalInbox);
As new mails are incoming, they will immediately appear, without any further code.
For example, to show all mails in AllMail that are *not* in Sent folder:
var incomingMails = allMailFolder.messages.subtract(sentFolder.messages);
gMessageListE.showCollection(incomingMails);
As you move mails to the Sent folder, they will immediately disappear from the list.
Confirmed users
591

edits