Bug 1749909 - Fix MailUtils undefined error in foldersummary.js. r=mkmelin
authorPing Chen <remotenonsense@gmail.com>
Sat, 15 Jan 2022 12:33:53 +0200
changeset 34772 a57046445d9d9cd9ec459384997394014e3fa4f0
parent 34771 e782e2de7f994f44bdc50cc5ac3960c8d34bbd4f
child 34773 5ba556911fa1c49706f3aba73705329cf07cb13b
push id19563
push usermkmelin@iki.fi
push dateSat, 15 Jan 2022 10:34:59 +0000
treeherdercomm-central@5ba556911fa1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmkmelin
bugs1749909
Bug 1749909 - Fix MailUtils undefined error in foldersummary.js. r=mkmelin Differential Revision: https://phabricator.services.mozilla.com/D135964
mail/base/content/widgets/foldersummary.js
--- a/mail/base/content/widgets/foldersummary.js
+++ b/mail/base/content/widgets/foldersummary.js
@@ -13,24 +13,16 @@
 {
   const { Services } = ChromeUtils.import(
     "resource://gre/modules/Services.jsm"
   );
   const { MailServices } = ChromeUtils.import(
     "resource:///modules/MailServices.jsm"
   );
 
-  const LazyModules = {};
-
-  ChromeUtils.defineModuleGetter(
-    LazyModules,
-    "MailUtils",
-    "resource:///modules/MailUtils.jsm"
-  );
-
   /**
    * MozFolderSummary displays a listing of NEW mails for the folder in question.
    * For each mail the subject, sender and a message preview can be included.
    * @extends {MozXULElement}
    */
   class MozFolderSummary extends MozXULElement {
     constructor() {
       super();
@@ -43,16 +35,22 @@
         "mail.biff.alert.show_sender"
       );
       this.showPreview = Services.prefs.getBoolPref(
         "mail.biff.alert.show_preview"
       );
       this.messengerBundle = Services.strings.createBundle(
         "chrome://messenger/locale/messenger.properties"
       );
+
+      ChromeUtils.defineModuleGetter(
+        this,
+        "MailUtils",
+        "resource:///modules/MailUtils.jsm"
+      );
     }
 
     hasMessages() {
       return this.lastElementChild;
     }
 
     static createFolderSummaryMessage() {
       let vbox = document.createXULElement("vbox");
@@ -116,17 +114,17 @@
       }
 
       if (folder.flags & Ci.nsMsgFolderFlags.Virtual) {
         let srchFolderUri = msgDatabase.dBFolderInfo.getCharProperty(
           "searchFolderUri"
         );
         let folderUris = srchFolderUri.split("|");
         for (let uri of folderUris) {
-          let realFolder = MailUtils.getOrCreateFolder(uri);
+          let realFolder = this.MailUtils.getOrCreateFolder(uri);
           if (!realFolder.isServer) {
             folderArray.push(realFolder);
           }
         }
       } else {
         folderArray.push(folder);
       }
 
@@ -194,17 +192,17 @@
           i++
         ) {
           let msgBox = MozFolderSummary.createFolderSummaryMessage();
           let msgHdr = msgDatabase.GetMsgHdrForKey(msgKeys[i]);
           msgBox.addEventListener("click", event => {
             if (event.button !== 0) {
               return;
             }
-            MailUtils.displayMessageInFolderTab(msgHdr);
+            this.MailUtils.displayMessageInFolderTab(msgHdr);
           });
 
           if (this.showSubject) {
             let msgSubject = msgHdr.mime2DecodedSubject;
             const kMsgFlagHasRe = 0x0010; // MSG_FLAG_HAS_RE
             if (msgHdr.flags & kMsgFlagHasRe) {
               msgSubject = msgSubject ? "Re: " + msgSubject : "Re: ";
             }
@@ -257,17 +255,17 @@
       let msgDatabase = folder.msgDatabase;
       for (let msgKey of msgKeys.slice(0, this.maxMsgHdrsInPopup)) {
         let msgBox = MozFolderSummary.createFolderSummaryMessage();
         let msgHdr = msgDatabase.GetMsgHdrForKey(msgKey);
         msgBox.addEventListener("click", event => {
           if (event.button !== 0) {
             return;
           }
-          MailUtils.displayMessageInFolderTab(msgHdr);
+          this.MailUtils.displayMessageInFolderTab(msgHdr);
         });
 
         if (this.showSubject) {
           let msgSubject = msgHdr.mime2DecodedSubject;
           const kMsgFlagHasRe = 0x0010; // MSG_FLAG_HAS_RE
           if (msgHdr.flags & kMsgFlagHasRe) {
             msgSubject = msgSubject ? "Re: " + msgSubject : "Re: ";
           }