Bug 809513 - Only notify for new mail in Inbox and non-special/virtual folders. r=aceman
authorJorg K <jorgk@jorgk.com>
Fri, 30 Nov 2018 22:39:30 +0100
changeset 33825 fa17a20f549165e5218def02eea6978e03a5208c
parent 33824 23e639499671242b915d89b4cc4144410365e699
child 33826 58068a9cedef38f2689291dc7b63476df24f6bb9
push id388
push userclokep@gmail.com
push dateMon, 28 Jan 2019 20:54:56 +0000
reviewersaceman
bugs809513
Bug 809513 - Only notify for new mail in Inbox and non-special/virtual folders. r=aceman
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
@@ -602,20 +602,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))