Bug 1608610 - On startup uninstall Lightning addon if installed. r=darktrojan
authorPaul Morris <paul@thunderbird.net>
Tue, 28 Jan 2020 11:09:59 -0500
changeset 37254 81c1b4bf19a2651f61eeeb6f86d4eb7c0353b46d
parent 37253 f18c944f7f0e9e9fa1d31da18f2cdea663fc5e9b
child 37255 e49a12783ad37a4b64468eb32d071e966c0aebbb
push id2552
push userclokep@gmail.com
push dateMon, 10 Feb 2020 21:24:16 +0000
treeherdercomm-beta@f95a6f4408a3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdarktrojan
bugs1608610
Bug 1608610 - On startup uninstall Lightning addon if installed. r=darktrojan
calendar/lightning/content/messenger-overlay-sidebar.js
--- a/calendar/lightning/content/messenger-overlay-sidebar.js
+++ b/calendar/lightning/content/messenger-overlay-sidebar.js
@@ -370,16 +370,18 @@ var calendarItemTabType = {
 window.addEventListener("load", e => {
   let tabmail = document.getElementById("tabmail");
   tabmail.registerTabType(calendarTabType);
   tabmail.registerTabType(calendarItemTabType);
   tabmail.registerTabMonitor(calendarTabMonitor);
 });
 
 async function ltnOnLoad(event) {
+  await uninstallLightningAddon();
+
   // Check if the binary component was loaded
   checkCalendarBinaryComponent();
 
   document
     .getElementById("calendarDisplayDeck")
     .addEventListener("select", LtnObserveDisplayDeckChange, true);
 
   // Take care of common initialization
@@ -411,16 +413,30 @@ async function ltnOnLoad(event) {
     MailToolboxCustomizeDone(aEvent, "CustomizeTaskToolbar");
   };
 
   updateTodayPaneButton();
 
   Services.obs.notifyObservers(window, "lightning-startup-done");
 }
 
+/**
+ * Uninstall the Lightning calendar addon, now that calendar is in Thunderbird.
+ */
+async function uninstallLightningAddon() {
+  try {
+    let addon = await AddonManager.getAddonByID("{e2fda1a4-762b-4020-b5ad-a41df1933103}");
+    if (addon) {
+      await addon.uninstall();
+    }
+  } catch (err) {
+    console.error("Error while attempting to uninstall Lightning addon:", err);
+  }
+}
+
 /* Called at midnight to tell us to redraw date-specific widgets.  Do NOT call
  * this for normal refresh, since it also calls scheduleMidnightRefresh.
  */
 function refreshUIBits() {
   try {
     getMinimonth().refreshDisplay();
 
     // Refresh the current view and just allow the refresh for the others