Bug 1563694 - Stop GData migration code listening for dialogaccept on the main mail window. r+a=philipp
authorGeoff Lankow <geoff@darktrojan.net>
Fri, 05 Jul 2019 21:43:46 +1200
changeset 35256 8471b4a999142dfac8de2540abd2b999f53ecffb
parent 35255 49293e4e1bf2180a64b48d56f96f589f93fb342a
child 35257 8f2a29618eed9f467cc11c2aeff48a216a29d736
push id2472
push usermozilla@jorgk.com
push dateTue, 23 Jul 2019 18:04:43 +0000
treeherdercomm-beta@eef322757b67 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1563694
Bug 1563694 - Stop GData migration code listening for dialogaccept on the main mail window. r+a=philipp
calendar/providers/gdata/content/gdata-migration.js
--- a/calendar/providers/gdata/content/gdata-migration.js
+++ b/calendar/providers/gdata/content/gdata-migration.js
@@ -5,50 +5,52 @@
 /* import-globals-from ../../../base/content/calendar-ui-utils.js */
 
 var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
 var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
 
 /**
  * Migrate the calendar selected in the wizard from ics to gdata.
  */
-document.addEventListener("dialogaccept", () => {
-    let listbox = document.getElementById("calendars-listbox");
-    let calmgr = cal.getCalendarManager();
+if (document.documentElement.id == "gdata-migration-wizard") {
+    document.addEventListener("dialogaccept", () => {
+        let listbox = document.getElementById("calendars-listbox");
+        let calmgr = cal.getCalendarManager();
 
-    for (let i = 0; i < listbox.childNodes.length; i++) {
-        let item = listbox.childNodes[i];
-        if (item.checked) {
-            // Migrate the calendar to a gdata calendar
-            let newCal = calmgr.createCalendar("gdata", item.calendar.uri);
-            calmgr.removeCalendar(item.calendar);
+        for (let i = 0; i < listbox.childNodes.length; i++) {
+            let item = listbox.childNodes[i];
+            if (item.checked) {
+                // Migrate the calendar to a gdata calendar
+                let newCal = calmgr.createCalendar("gdata", item.calendar.uri);
+                calmgr.removeCalendar(item.calendar);
 
-            // Copy some properties to the new calendar
-            newCal.name = item.calendar.name;
-            newCal.setProperty("color",
-                               item.calendar.getProperty("color"));
-            newCal.setProperty("disabled",
-                               item.calendar.getProperty("disabled"));
-            newCal.setProperty("cache.enabled",
-                               item.calendar.getProperty("cache.enabled"));
-            newCal.setProperty("suppressAlarms",
-                               item.calendar.getProperty("suppressAlarms"));
-            newCal.setProperty("calendar-main-in-composite",
-                               item.calendar.getProperty("calendar-main-in-composite"));
-            newCal.setProperty("calendar-main-default",
-                               item.calendar.getProperty("calendar-main-default"));
+                // Copy some properties to the new calendar
+                newCal.name = item.calendar.name;
+                newCal.setProperty("color",
+                                   item.calendar.getProperty("color"));
+                newCal.setProperty("disabled",
+                                   item.calendar.getProperty("disabled"));
+                newCal.setProperty("cache.enabled",
+                                   item.calendar.getProperty("cache.enabled"));
+                newCal.setProperty("suppressAlarms",
+                                   item.calendar.getProperty("suppressAlarms"));
+                newCal.setProperty("calendar-main-in-composite",
+                                   item.calendar.getProperty("calendar-main-in-composite"));
+                newCal.setProperty("calendar-main-default",
+                                   item.calendar.getProperty("calendar-main-default"));
 
-            calmgr.registerCalendar(newCal);
+                calmgr.registerCalendar(newCal);
+            }
         }
-    }
 
-    // Only bring up the dialog on the next startup if the user wants us to.
-    Services.prefs.setBoolPref("calendar.google.migrate",
-                               document.getElementById("showagain-checkbox").checked);
-});
+        // Only bring up the dialog on the next startup if the user wants us to.
+        Services.prefs.setBoolPref("calendar.google.migrate",
+                                   document.getElementById("showagain-checkbox").checked);
+    });
+}
 
 /**
  * Get all calendars that are ics and point to a google calendar
  *
  * @return An array of calendars that are migratable
  */
 function getMigratableCalendars() {
     function isMigratable(calendar) {