Bug 809513 - Prevent unread Drafts from showing in new mail notification. r=aceman
authorGene Smith <gds@chartertn.net>
Mon, 06 Aug 2018 22:10:03 -0400
changeset 33815 6d2e32bd972987445f659ef51d701d54fa286618
parent 33814 70a161f6a58b31113ed2bc62eda86073db82cec9
child 33816 dd4e2acab2ab99e6f53b72268d8b72aad1745632
push id388
push userclokep@gmail.com
push dateMon, 28 Jan 2019 20:54:56 +0000
reviewersaceman
bugs809513
Bug 809513 - Prevent unread Drafts from showing in new mail notification. r=aceman Change mainly affects Windows. However, Linux integration also changed so that it also allows new mail notification to occur for folder with SentMail flag.
mailnews/base/content/newmailalert.js
mailnews/base/src/nsMessengerUnixIntegration.cpp
--- a/mailnews/base/content/newmailalert.js
+++ b/mailnews/base/content/newmailalert.js
@@ -51,17 +51,23 @@ 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))
+    // Enable new mail notification if folder has new messages and folder is not
+    // Virtual and not SpecialUse unless folder is Inbox or SentMail. Note: SpecialUse
+    // includes Inbox and SentMail as well as Drafts, Trash, Junk, Archive, Templates
+    // and Queue.
+    if (folder.hasNewMessages &&
+        !folder.getFlag((Ci.nsMsgFolderFlags.SpecialUse | Ci.nsMsgFolderFlags.Virtual) &
+                       ~(Ci.nsMsgFolderFlags.Inbox | Ci.nsMsgFolderFlags.SentMail)))
     {
       var asyncFetch = {};
       folderSummaryInfoEl.parseFolder(folder, new urlListener(folder), asyncFetch);
       if (asyncFetch.value)
         gPendingPreviewFetchRequests++;
     }
   }
 }
--- a/mailnews/base/src/nsMessengerUnixIntegration.cpp
+++ b/mailnews/base/src/nsMessengerUnixIntegration.cpp
@@ -602,20 +602,22 @@ 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)))
+      // Skip check for new mail if folder is Virtual or SpecialUse but not Inbox
+      // or SentMail. Note: SpecialUse includes Inbox and SentMail as well as
+      // Drafts, Trash, Junk, Archive Templates and Queue. A notification of new
+      // mail will not be produced for folders that are skipped.
+      if (flags & ((nsMsgFolderFlags::SpecialUse | nsMsgFolderFlags::Virtual) &
+          ~(nsMsgFolderFlags::Inbox | nsMsgFolderFlags::SentMail)))
         continue;
 
       nsCString folderURI;
       msgFolder->GetURI(folderURI);
       bool hasNew = false;
       rv = msgFolder->GetHasNewMessages(&hasNew);
 
       if (NS_FAILED(rv))