drop overly complicated exludeCondition for Accounts iterator

This commit is contained in:
foudfou 2011-09-23 00:47:48 +02:00
parent acbbff4f7b
commit 3d0aaae494
2 changed files with 11 additions and 25 deletions

View File

@ -30,12 +30,11 @@ mozt.UIOptions = {
let targetNode = document.getElementById(parentId);
// TODO: sort servers by type, name
let exclCond = function(account) {
return (mozt.Messaging.SERVER_TYPES_EXCLUDED.indexOf(account.type) >= 0);
};
let accounts = new mozt.Messaging.Accounts(exclCond);
let accounts = new mozt.Messaging.Accounts();
for (let accountServer in accounts) {
if (mozt.Messaging.SERVER_TYPES_EXCLUDED.indexOf(accountServer.type) >= 0)
continue;
let nodeAccount = document.createElement("checkbox");
let accountServerKey = accountServer.key.toString();
nodeAccount.setAttribute('id', accountServerKey);

View File

@ -93,13 +93,12 @@ mozt.Messaging = {
this._unreadMsgCount = 0; // reset
try {
let exclCond = function(account) {
return ( (mozt.Messaging.SERVER_TYPES_EXCLUDED.indexOf(account.type) >= 0)
|| (mozt.Messaging.getPrefAccountsExcluded().indexOf(account.key) >= 0) );
};
let accounts = new this.Accounts(exclCond);
let accounts = new this.Accounts();
for (let accountServer in accounts) {
if ( (this.SERVER_TYPES_EXCLUDED.indexOf(accountServer.type) >= 0)
|| (this.getPrefAccountsExcluded().indexOf(accountServer.key) >= 0) )
continue;
let rootFolder = accountServer.rootFolder; // nsIMsgFolder
if (rootFolder.hasSubFolders) {
let subFolders = rootFolder.subFolders; // nsIMsgFolder
@ -136,17 +135,8 @@ mozt.Messaging = {
/**
* Accounts constructor for iterating over account servers
* @param exclusionCondition: a function which expresses a condition for excluding accounts
*/
Accounts: function(exclusionCondition) {
if (typeof(exclusionCondition) == "undefined") {
this.exclusionCondition = function(){return false;};
return;
} else if (typeof(exclusionCondition) != "function") {
throw "arg must be a function";
return;
} else
this.exclusionCondition = exclusionCondition;
Accounts: function() {
}
};
@ -160,9 +150,6 @@ mozt.Messaging.Accounts.prototype.__iterator__ = function() {
let account = accounts.QueryElementAt(i, Ci.nsIMsgAccount);
let accountServer = account.incomingServer;
LOG("ACCOUNT: "+accountServer.prettyName+" type: "+accountServer.type);
if ( this.exclusionCondition.call(this, accountServer) )
continue;
yield accountServer;
yield accountServer;
}
}