Bug 840591 - Regression from bug 809066: fix folder picker if there are more than 15 recent folders. r=Neil
authoraceman <acelists@atlas.sk>
Sat, 16 Feb 2013 19:19:49 -0500
changeset 14870 ef54286ed6520bffa7ce4b73174fe2373661b303
parent 14869 5c10bc43843db30a68c7c014d31014dc87a25000
child 14871 bce8262aabcc6bb720ed18ec46b47e1f691be5ca
push id867
push userbugzilla@standard8.plus.com
push dateMon, 01 Apr 2013 20:44:27 +0000
treeherdercomm-beta@797726b8d244 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersNeil
bugs840591, 809066
Bug 840591 - Regression from bug 809066: fix folder picker if there are more than 15 recent folders. r=Neil
mailnews/base/content/folderWidgets.xml
--- a/mailnews/base/content/folderWidgets.xml
+++ b/mailnews/base/content/folderWidgets.xml
@@ -504,20 +504,16 @@
         <body><![CDATA[
           const Ci = Components.interfaces;
           // Iterate through all folders in all accounts, and check MRM_Time,
           // then take the most current 15 (_MAXRECENT).
 
           let recentFolders = [];
           let thisObj = this;
 
-          function sort_folders_by_MRMTime(a, b) {
-            return a.getStringProperty("MRMTime") < b.getStringProperty("MRMTime");
-          }
-
           /**
            * This function will add a folder to the recentFolders array if it
            * is among the 15 (_MAXRECENT) most recent. If we exceed 15 folders,
            * it will pop the oldest folder, ensuring that we end up with the
            * right number.
            *
            * @param aFolder  the folder to check
            */
@@ -525,53 +521,55 @@
           function addIfRecent(aFolder) {
             if (!aFolder.canFileMessages)
               return;
 
             let time = 0;
             try {
               time = aFolder.getStringProperty("MRMTime");
             } catch(ex) {}
-            if (time <= oldestTime)
+            if (!time || time <= oldestTime)
               return;
 
             if (recentFolders.length == thisObj._MAXRECENT) {
-              recentFolders.sort(sort_folders_by_MRMTime);
+              recentFolders.sort(function sort_folders_by_MRMTime(a, b) {
+                                 return a.MRMTime < b.MRMTime; });
               recentFolders.pop();
-              oldestTime = recentFolders[recentFolders.length - 1]
-                                        .getStringProperty("MRMTime");
+              oldestTime = recentFolders[recentFolders.length - 1].MRMTime;
             }
-            recentFolders.push({folder: aFolder});
+            recentFolders.push({ folder:  aFolder,
+                                 MRMTime: time,
+                                 name:    aFolder.prettyName });
           }
 
           // Check all folders if they are recent.
           for (let folder in this.fixIterator(this.MailServices.accounts.allFolders,
                                               Ci.nsIMsgFolder)) {
             addIfRecent(folder);
           }
 
           // Because we're scanning across multiple accounts, we can end up with
           // several folders with the same name. Find those dupes.
           let dupeNames = new Set();
           for (let i = 0; i < recentFolders.length; i++) {
             for (let j = i + 1; j < recentFolders.length; j++) {
-              if (recentFolders[i].folder.prettyName == recentFolders[j].folder.prettyName)
-                dupeNames.add(recentFolders[i].folder.prettyName);
+              if (recentFolders[i].name == recentFolders[j].name)
+                dupeNames.add(recentFolders[i].name);
             }
           }
 
           for (let folderItem of recentFolders) {
             // If this folder name appears multiple times in the recent list,
             // append the server name to disambiguate.
             // TODO:
             // - maybe this could use verboseFolderFormat from messenger.properties
             //   instead of hardcoded " - ".
             // - disambiguate folders with same name in same account
             //   (in different subtrees).
-            let label = folderItem.folder.prettyName;
+            let label = folderItem.name;
             if (dupeNames.has(label))
               label += " - " + folderItem.folder.server.prettyName;
 
             folderItem.label = label;
           }
 
           // Make sure the entries are sorted alphabetically.
           recentFolders.sort(function sort_folders_by_name(a, b) {