Bug 1638339 - remove some unnneded enigmail calls. Not needed since we do not cache the compose window. r=PatrickBrunschwig
authorMagnus Melin <mkmelin+mozilla@iki.fi>
Sat, 23 May 2020 22:43:16 +0300
changeset 39244 e31d162b318bb64bae37f5860d305c983a4e0884
parent 39243 313a28f7f5d3b7bea5104b967addd70868b80eb8
child 39245 250b57b853c4ddd05e8037a81791b08bc6b5b407
push id402
push userclokep@gmail.com
push dateMon, 29 Jun 2020 20:48:04 +0000
reviewersPatrickBrunschwig
bugs1638339
Bug 1638339 - remove some unnneded enigmail calls. Not needed since we do not cache the compose window. r=PatrickBrunschwig
mail/extensions/openpgp/content/ui/enigmailMsgComposeOverlay.js
--- a/mail/extensions/openpgp/content/ui/enigmailMsgComposeOverlay.js
+++ b/mail/extensions/openpgp/content/ui/enigmailMsgComposeOverlay.js
@@ -191,32 +191,34 @@ Enigmail.msg = {
       smimeButton.setAttribute("label", "S/MIME");
       if (toolbar && toolbar.getAttribute("currentset").length === 0) {
         // remove S/MIME button if the toolbar is displaying the default set
         toolbar.removeChild(smimeButton);
       }
     }
     */
 
-    var msgId = document.getElementById("msgIdentityPopup");
-    if (msgId) {
-      msgId.addEventListener("command", Enigmail.msg.setIdentityCallback);
-    }
-
-    var subj = document.getElementById("msgSubject");
-    subj.addEventListener("focus", Enigmail.msg.fireSendFlags);
+    document
+      .getElementById("msgIdentityPopup")
+      .addEventListener("command", () => {
+        this.setIdentityDefaults();
+      });
+
+    document.getElementById("msgSubject").addEventListener("focus", () => {
+      this.fireSendFlags();
+    });
+
+    this.setIdentityDefaults();
 
     /*
     let numCerts = EnigmailFuncs.getNumOfX509Certs();
     this.addrOnChangeTimeout = Math.max((numCerts - 250) * 2, 250);
     EnigmailLog.DEBUG(`enigmailMsgComposeOverlay.js: composeStartup: numCerts=${numCerts}; setting timeout to ${this.addrOnChangeTimeout}\n`);
     */
 
-    Enigmail.msg.msgComposeReset(false); // false => not closing => call setIdentityDefaults()
-
     // TODO implement migration code for old prefs, possibly in configure.jsm
     // Use a new pref identityEnigmailPrefsMigrated, default false.
     // Only if we're doing this for the first time for an identity,
     // try to read old prefs and if found, store as new prefs,
     // then set identityEnigmailPrefsMigrated=true
     // Enigmail account prefs that need to be handled:
     // - defaultEncryptionPolicy
     // - autoSendEncrypted
@@ -250,28 +252,16 @@ Enigmail.msg = {
         break;
       case 0:
         this.doPgpButton(modifyType);
         break;
     }
   },
   */
 
-  setIdentityCallback(elementId) {
-    EnigmailLog.DEBUG(
-      "enigmailMsgComposeOverlay.js: Enigmail.msg.setIdentityCallback: elementId=" +
-        elementId +
-        "\n"
-    );
-
-    EnigmailTimer.setTimeout(function() {
-      Enigmail.msg.setIdentityDefaults();
-    }, 100);
-  },
-
   /* return whether the account specific setting key is enabled or disabled
    */
   /*
   getAccDefault: function(key) {
     //EnigmailLog.DEBUG("enigmailMsgComposeOverlay.js: Enigmail.msg.getAccDefault: identity="+this.identity.key+"("+this.identity.email+") key="+key+"\n");
     let res = null;
     let mimePreferOpenPGP = this.identity.getIntAttribute("mimePreferOpenPGP");
     let isSmimeEnabled = Enigmail.msg.isSmimeEnabled();
@@ -865,53 +855,16 @@ Enigmail.msg = {
               "\n"
           );
         }
       }.bind(Enigmail.msg),
       1500
     );
   },
 
-  msgComposeClose() {
-    EnigmailLog.DEBUG(
-      "enigmailMsgComposeOverlay.js: Enigmail.msg.msgComposeClose\n"
-    );
-
-    this.msgComposeReset(true); // true => closing => don't call setIdentityDefaults()
-  },
-
-  msgComposeReset(closing) {
-    EnigmailLog.DEBUG(
-      "enigmailMsgComposeOverlay.js: Enigmail.msg.msgComposeReset\n"
-    );
-
-    this.dirty = 0;
-    this.processed = null;
-    this.timeoutId = null;
-
-    this.modifiedAttach = null;
-    //this.sendMode = 0;
-    //this.sendModeDirty = false;
-
-    this.statusEncryptedStr = "???";
-    this.statusSignedStr = "???";
-    //this.statusPGPMimeStr = "???";
-    //this.statusInlinePGPStr = "???";
-    this.statusAttachOwnKey = "???";
-    this.identity = null;
-    this.sendProcess = false;
-    this.trustAllKeys = false;
-    //this.mimePreferOpenPGP = 0;
-    this.keyLookupDone = [];
-
-    if (!closing) {
-      this.setIdentityDefaults();
-    }
-  },
-
   initRadioMenu(prefName, optionIds) {
     EnigmailLog.DEBUG(
       "enigmailMessengerOverlay.js: Enigmail.msg.initRadioMenu: " +
         prefName +
         "\n"
     );
 
     var prefValue = EnigmailPrefs.getPref(prefName);
@@ -3848,74 +3801,22 @@ Enigmail.composeStateListener = {
     }
   },
 
   SaveInFolderDone(folderURI) {
     //EnigmailLog.DEBUG("enigmailMsgComposeOverlay.js: ECSL.SaveInFolderDone\n");
   },
 };
 
-/**
- * Unload Enigmail for update or uninstallation
- */
-Enigmail.composeUnload = function() {
-  window.removeEventListener("unload-enigmail", Enigmail.composeUnload);
-  window.removeEventListener("load-enigmail", Enigmail.msg.composeStartup);
-  window.removeEventListener(
-    "compose-window-unload",
-    Enigmail.msg.msgComposeClose,
-    true
-  );
-  window.removeEventListener(
-    "compose-send-message",
-    Enigmail.msg.sendMessageListener,
-    true
-  );
-  window.removeEventListener(
-    "compose-from-changed",
-    Enigmail.msg.fromChangedListener,
-    true
-  );
-
-  gMsgCompose.UnregisterStateListener(Enigmail.composeStateListener);
-
-  let msgId = document.getElementById("msgIdentityPopup");
-  if (msgId) {
-    msgId.removeEventListener("command", Enigmail.msg.setIdentityCallback);
+window.addEventListener(
+  "load",
+  Enigmail.msg.composeStartup.bind(Enigmail.msg),
+  {
+    capture: false,
+    once: true,
   }
-
-  let subj = document.getElementById("msgSubject");
-  subj.removeEventListener("focus", Enigmail.msg.fireSendFlags);
-
-  // check rules for status bar icons on each change of the recipients
-  let rep = new RegExp("; Enigmail.msg.addressOnChange\\(this\\);");
-  var adrCol = document.getElementById("addressCol2#1"); // recipients field
-  if (adrCol) {
-    let attr = adrCol.getAttribute("oninput");
-    adrCol.setAttribute("oninput", attr.replace(rep, ""));
-    attr = adrCol.getAttribute("onchange");
-    adrCol.setAttribute("onchange", attr.replace(rep, ""));
-  }
-  adrCol = document.getElementById("addressCol1#1"); // to/cc/bcc/... field
-  if (adrCol) {
-    let attr = adrCol.getAttribute("oncommand");
-    adrCol.setAttribute("oncommand", attr.replace(rep, ""));
+);
+
+window.addEventListener("compose-window-unload", () => {
+  if (gMsgCompose) {
+    gMsgCompose.UnregisterStateListener(Enigmail.composeStateListener);
   }
-
-  // finally unload Enigmail entirely
-  Enigmail = undefined;
-};
-
-addEventListener("load", Enigmail.msg.composeStartup.bind(Enigmail.msg), {
-  capture: false,
-  once: true,
 });
-
-window.addEventListener(
-  "unload-enigmail",
-  Enigmail.composeUnload.bind(Enigmail.msg)
-);
-
-window.addEventListener(
-  "compose-window-unload",
-  Enigmail.msg.msgComposeClose.bind(Enigmail.msg),
-  true
-);