Bug 1556462 - make GetFolderMessages() work without a default account. r=alta88,IanN
authoraceman <acelists@atlas.sk>
Mon, 03 Jun 2019 11:18:00 +0200
changeset 35756 f48dd749bd7016f7384e0a509becdfceeedfbc41
parent 35755 af589662271683181930592f05f4959291dee392
child 35757 d2a2d9de473d7f9dc377906bc3e75be14bd15246
push id392
push userclokep@gmail.com
push dateMon, 02 Sep 2019 20:17:19 +0000
reviewersalta88, IanN
bugs1556462
Bug 1556462 - make GetFolderMessages() work without a default account. r=alta88,IanN
mail/base/content/mailWindowOverlay.js
suite/mailnews/content/mailWindowOverlay.js
--- a/mail/base/content/mailWindowOverlay.js
+++ b/mail/base/content/mailWindowOverlay.js
@@ -2281,40 +2281,42 @@ function GetDefaultAccountRootFolder() {
 /**
  * Check for new messages for all selected folders, or for the default account
  * in case no folders are selected.
  */
 function GetFolderMessages() {
   var selectedFolders = GetSelectedMsgFolders();
   var defaultAccountRootFolder = GetDefaultAccountRootFolder();
 
-  // If no default account, GetNewMsgs isn't going to do anything anyways
-  // so bail out.
-  if (!defaultAccountRootFolder)
-    return;
-
   // if nothing selected, use the default
   var folders = (selectedFolders.length) ? selectedFolders : [defaultAccountRootFolder];
+
+  if (!folders[0])
+    return;
+
   for (var i = 0; i < folders.length; i++) {
     var serverType = folders[i].server.type;
     if (folders[i].isServer && (serverType == "nntp")) {
       // If we're doing "get msgs" on a news server,
       // update unread counts on this server.
       folders[i].server.performExpand(msgWindow);
     } else if (serverType == "none") {
       // If "Local Folders" is selected and the user does "Get Msgs" and
       // LocalFolders is not deferred to, get new mail for the default account
       //
       // XXX TODO
       // Should shift click get mail for all (authenticated) accounts?
       // see bug #125885.
-      if (!folders[i].server.isDeferredTo)
+      if (!folders[i].server.isDeferredTo) {
+        if (!defaultAccountRootFolder)
+          continue;
         GetNewMsgs(defaultAccountRootFolder.server, defaultAccountRootFolder);
-      else
+      } else {
         GetNewMsgs(folders[i].server, folders[i]);
+      }
     } else {
       GetNewMsgs(folders[i].server, folders[i]);
     }
   }
 }
 
 /**
  * Gets new messages for the given server, for the given folder.
--- a/suite/mailnews/content/mailWindowOverlay.js
+++ b/suite/mailnews/content/mailWindowOverlay.js
@@ -2333,24 +2333,22 @@ function GetDefaultAccountRootFolder()
   return null;
 }
 
 function GetFolderMessages()
 {
   var selectedFolders = GetSelectedMsgFolders();
   var defaultAccountRootFolder = GetDefaultAccountRootFolder();
 
-  // if no default account, get msg isn't going do anything anyways
-  // so bail out
-  if (!defaultAccountRootFolder)
-    return;
-
   // if nothing selected, use the default
   var folder = selectedFolders.length ? selectedFolders[0] : defaultAccountRootFolder;
 
+  if (!folder)
+    return;
+
   var serverType = folder.server.type;
 
   if (folder.isServer && (serverType == "nntp")) {
     // if we're doing "get msgs" on a news server
     // update unread counts on this server
     folder.server.performExpand(msgWindow);
     return;
   }
@@ -2362,18 +2360,20 @@ function GetFolderMessages()
     //
     // XXX TODO
     // should shift click get mail for all (authenticated) accounts?
     // see bug #125885
     if (!folder.server.isDeferredTo)
       folder = defaultAccountRootFolder;
   }
 
-  var folders = new Array(1);
-  folders[0] = folder;
+  if (!folder)
+    return;
+
+  var folders = [folder];
 
   GetNewMessages(folders, folder.server);
 }
 
 function SendUnsentMessages()
 {
   var msgSendlater = Cc["@mozilla.org/messengercompose/sendlater;1"]
                .getService(Ci.nsIMsgSendLater);