[Pkg-mozext-commits] [firetray] 186/399: drop use of bogus getNumNewMessages() in favor of folder.hasNewMessages
David Prévot
taffit at alioth.debian.org
Tue Oct 29 18:23:40 UTC 2013
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch dfsg-clean
in repository firetray.
commit 69f9f312c45c0e649396f8dae601d0b2f24876fb
Author: foudfou <foudil.newbie+git at gmail.com>
Date: Sun Mar 4 15:29:12 2012 +0100
drop use of bogus getNumNewMessages() in favor of folder.hasNewMessages
---
src/modules/FiretrayMessaging.jsm | 31 ++++++++++++++++++++-----------
1 file changed, 20 insertions(+), 11 deletions(-)
diff --git a/src/modules/FiretrayMessaging.jsm b/src/modules/FiretrayMessaging.jsm
index 7058cb4..6996a9b 100644
--- a/src/modules/FiretrayMessaging.jsm
+++ b/src/modules/FiretrayMessaging.jsm
@@ -148,19 +148,17 @@ firetray.Messaging = {
},
/**
- * computes total unread message count.
- * NOTE: new messages can(?) be filtered and mark read, but still be
- * considered new, so we may have to use nsMsgFolderFlagType.GotNew on all
- * folders
+ * computes total unread or new message count.
*/
countMessages: function() {
let msgCountType = firetray.Utils.prefService.getIntPref("message_count_type");
LOG("msgCountType="+msgCountType);
- let folderCountFunctionName;
+
+ let folderCountFunction;
if (msgCountType === FIRETRAY_MESSAGE_COUNT_TYPE_UNREAD) {
- folderCountFunctionName = 'getNumUnread';
+ folderCountFunction = this.unreadMsgCountIterate;
} else if (msgCountType === FIRETRAY_MESSAGE_COUNT_TYPE_NEW) {
- folderCountFunctionName = 'getNumNewMessages'; // perfectly bogus if > 0
+ folderCountFunction = this.newMsgCountIterate;
} else
ERROR('unknown message count type');
@@ -186,9 +184,7 @@ firetray.Messaging = {
while(subFolders.hasMoreElements()) {
let folder = subFolders.getNext().QueryInterface(Ci.nsIMsgFolder);
if (!(folder.flags & excludedFoldersFlags)) {
- let folderNewMsgCount = folder[folderCountFunctionName](true); // includes subfolders
- LOG(folder.prettyName+" "+folderCountFunctionName+"="+folderNewMsgCount);
- newMsgCount += folderNewMsgCount;
+ newMsgCount = folderCountFunction(folder, newMsgCount);
}
}
}
@@ -196,8 +192,21 @@ firetray.Messaging = {
} catch (x) {
ERROR(x);
}
- LOG("Total Unread="+newMsgCount);
+ LOG("Total New="+newMsgCount);
return newMsgCount;
+ },
+
+ unreadMsgCountIterate: function(folder, accumulator) {
+ let folderCountFunctionName = 'getNumUnread';
+ let folderNewMsgCount = folder[folderCountFunctionName](true); // includes subfolders
+ LOG(folder.prettyName+" "+folderCountFunctionName+"="+folderNewMsgCount);
+ return accumulator + folderNewMsgCount;
+ },
+
+ newMsgCountIterate: function(folder, accumulator) {
+ let folderNewMsgCount = folder.hasNewMessages;
+ LOG(folder.prettyName+" hasNewMessages="+folderNewMsgCount);
+ return accumulator || folderNewMsgCount;
}
};
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/firetray.git
More information about the Pkg-mozext-commits
mailing list