Bug 1552725 - Copy Firefox code for getting the active update. r=mkmelin
authorGeoff Lankow <geoff@darktrojan.net>
Thu, 06 Jun 2019 22:01:12 +1200
changeset 35964 94f38909bfab2a9a0ee5bf604d05993cf48e7afb
parent 35963 a32a7dd507912e310334745f46a2788848b146e3
child 35965 840547c2b3203c96b7aed00c995411b20bd23c5b
push id392
push userclokep@gmail.com
push dateMon, 02 Sep 2019 20:17:19 +0000
reviewersmkmelin
bugs1552725
Bug 1552725 - Copy Firefox code for getting the active update. r=mkmelin
mail/base/content/specialTabs.js
--- a/mail/base/content/specialTabs.js
+++ b/mail/base/content/specialTabs.js
@@ -885,24 +885,32 @@ var specialTabs = {
   },
 
   /**
    * Shows the what's new page in a content tab.
    */
   showWhatsNewPage() {
     let um = Cc["@mozilla.org/updates/update-manager;1"]
                .getService(Ci.nsIUpdateManager);
-
-    try {
+    let update;
+    // The active update should be present when this code is called. If for
+    // whatever reason it isn't fallback to the latest update in the update
+    // history.
+    if (um.activeUpdate) {
+      update = um.activeUpdate
+                 .QueryInterface(Ci.nsIWritablePropertyBag);
+    } else {
       // If the updates.xml file is deleted then getUpdateAt will throw.
-      var update = um.getUpdateAt(0)
-                     .QueryInterface(Ci.nsIWritablePropertyBag);
-    } catch (x) {
-      Cu.reportError("Unable to find update: " + x);
-      return;
+      try {
+        update = um.getUpdateAt(0)
+                   .QueryInterface(Ci.nsIPropertyBag);
+      } catch (e) {
+        Cu.reportError("Unable to find update: " + e);
+        return;
+      }
     }
 
     let actions = update.getProperty("actions");
     if (actions && actions.includes("silent"))
       return;
 
     openWhatsNew();
   },