sort mail servers in accounts_to_exclude option
This commit is contained in:
parent
3d0aaae494
commit
dccc716af3
|
@ -29,8 +29,7 @@ mozt.UIOptions = {
|
|||
// the DOM parent where we do appendChild
|
||||
let targetNode = document.getElementById(parentId);
|
||||
|
||||
// TODO: sort servers by type, name
|
||||
let accounts = new mozt.Messaging.Accounts();
|
||||
let accounts = new mozt.Messaging.Accounts(true);
|
||||
for (let accountServer in accounts) {
|
||||
if (mozt.Messaging.SERVER_TYPES_EXCLUDED.indexOf(accountServer.type) >= 0)
|
||||
continue;
|
||||
|
|
|
@ -66,7 +66,6 @@ mozt.Messaging = {
|
|||
* @param oldFlag: Old header flag (long).
|
||||
* @param newFlag: New header flag (long).
|
||||
*/
|
||||
// TODO: check if count correctly updated if folder/account creation/deletion
|
||||
OnItemIntPropertyChanged: function(folder, property, oldValue, newValue) {
|
||||
if (property.toString() === "TotalUnreadMessages" &&
|
||||
!(folder.flags & FLDR_UNINTERESTING)) {
|
||||
|
@ -131,25 +130,54 @@ mozt.Messaging = {
|
|||
throw "negative message count"; // should never happen
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Accounts constructor for iterating over account servers
|
||||
*/
|
||||
Accounts: function() {
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* make Accounts a Iterator/Generator
|
||||
* Accounts Iterator/Generator for iterating over account servers
|
||||
* @param sortByTypeAndName: boolean
|
||||
*/
|
||||
mozt.Messaging.Accounts = function(sortByTypeAndName) {
|
||||
if (typeof(sortByTypeAndName) == "undefined") {
|
||||
this.sortByTypeAndName = false;
|
||||
return;
|
||||
}
|
||||
if (typeof(sortByTypeAndName) !== "boolean")
|
||||
throw "sort arg must be a boolean";
|
||||
|
||||
this.sortByTypeAndName = sortByTypeAndName;
|
||||
};
|
||||
mozt.Messaging.Accounts.prototype.__iterator__ = function() {
|
||||
let accounts = MailServices.accounts.accounts;
|
||||
LOG("sortByTypeAndName="+this.sortByTypeAndName);
|
||||
|
||||
// NOTE: sort() not provided by nsIMsgAccountManager.accounts
|
||||
// (nsISupportsArray?). Should be OK to re-build a JS-Array for few accounts
|
||||
let accountServers = [];
|
||||
for (let i = 0; i < accounts.Count(); i++) {
|
||||
let account = accounts.QueryElementAt(i, Ci.nsIMsgAccount);
|
||||
let accountServer = account.incomingServer;
|
||||
LOG("ACCOUNT: "+accountServer.prettyName+" type: "+accountServer.type);
|
||||
yield accountServer;
|
||||
accountServers[i] = accountServer;
|
||||
}
|
||||
}
|
||||
|
||||
if (this.sortByTypeAndName) {
|
||||
accountServers.sort(function(a,b) {
|
||||
if (a.type < b.type)
|
||||
return -1;
|
||||
if (a.type > b.type)
|
||||
return 1;
|
||||
if (a.name < b.name)
|
||||
return -1;
|
||||
if (a.name > b.name)
|
||||
return 1;
|
||||
return 0; // no sorting
|
||||
});
|
||||
}
|
||||
|
||||
for (i = 0; i < accountServers.length; i++) {
|
||||
LOG("ACCOUNT: "+accountServers[i].prettyName+" type: "+accountServers[i].type);
|
||||
yield accountServers[i];
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue