Bug 809513 - Only notify for new mail in Inbox and non-special/virtual folders. r=aceman a=jorgk
authorJorg K <jorgk@jorgk.com>
Fri, 30 Nov 2018 22:39:30 +0100
changeset 31983 bf0d776d3044be78117b7d198e44299ed954de43
parent 31982 076be5ca12a94eaf19618618977ed1f5f2101be4
child 31984 c4abcd141b6ccc281c26765731795005784210c7
push id124
push usermozilla@jorgk.com
push dateWed, 12 Dec 2018 15:12:19 +0000
treeherdercomm-esr60@3510ade6c2cb [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersaceman, jorgk
bugs809513
Bug 809513 - Only notify for new mail in Inbox and non-special/virtual folders. r=aceman a=jorgk
mailnews/base/content/newmailalert.js
mailnews/base/src/nsMessengerUnixIntegration.cpp
--- a/mailnews/base/content/newmailalert.js
+++ b/mailnews/base/content/newmailalert.js
@@ -51,22 +51,30 @@ function prefillAlertInfo()
 
   // This is really the root folder and we have to walk through the list to
   // find the real folder that has new mail in it...:(
   let allFolders = rootFolder.descendants;
   var folderSummaryInfoEl = document.getElementById('folderSummaryInfo');
   folderSummaryInfoEl.mMaxMsgHdrsInPopup = gNumNewMsgsToShowInAlert;
   for (let folder of fixIterator(allFolders, Ci.nsIMsgFolder))
   {
-    if (folder.hasNewMessages && !folder.getFlag(Ci.nsMsgFolderFlags.Virtual))
-    {
-      var asyncFetch = {};
-      folderSummaryInfoEl.parseFolder(folder, new urlListener(folder), asyncFetch);
-      if (asyncFetch.value)
-        gPendingPreviewFetchRequests++;
+    if (folder.hasNewMessages) {
+      let notify =
+        // Any folder which is an inbox or ...
+        folder.getFlag(Ci.nsMsgFolderFlags.Inbox) ||
+        // any non-special or non-virtual folder. In other words, we don't
+        // notify for Drafts|Trash|SentMail|Templates|Junk|Archive|Queue or virtual.
+        !(folder.flags & (Ci.nsMsgFolderFlags.SpecialUse | Ci.nsMsgFolderFlags.Virtual));
+
+      if (notify) {
+        var asyncFetch = {};
+        folderSummaryInfoEl.parseFolder(folder, new urlListener(folder), asyncFetch);
+        if (asyncFetch.value)
+          gPendingPreviewFetchRequests++;
+      }
     }
   }
 }
 
 function urlListener(aFolder)
 {
   this.mFolder = aFolder;
 }
--- a/mailnews/base/src/nsMessengerUnixIntegration.cpp
+++ b/mailnews/base/src/nsMessengerUnixIntegration.cpp
@@ -603,20 +603,24 @@ nsresult nsMessengerUnixIntegration::Get
         continue;
 
       uint32_t flags;
       rv = msgFolder->GetFlags(&flags);
 
       if (NS_FAILED(rv))
         continue;
 
-      // Unless we're dealing with an Inbox, we don't care
-      // about Drafts, Queue, SentMail, Template, or Junk folders
-      if (!(flags & nsMsgFolderFlags::Inbox) &&
-           (flags & (nsMsgFolderFlags::SpecialUse & ~nsMsgFolderFlags::Inbox)))
+      bool notify =
+        // Any folder which is an inbox or ...
+        flags & nsMsgFolderFlags::Inbox ||
+        // any non-special or non-virtual folder. In other words, we don't
+        // notify for Drafts|Trash|SentMail|Templates|Junk|Archive|Queue or virtual.
+        !(flags & (nsMsgFolderFlags::SpecialUse | nsMsgFolderFlags::Virtual));
+
+      if (!notify)
         continue;
 
       nsCString folderURI;
       msgFolder->GetURI(folderURI);
       bool hasNew = false;
       rv = msgFolder->GetHasNewMessages(&hasNew);
 
       if (NS_FAILED(rv))