Bug 1079450 - Let uninstall listener handle removing add-on from list. r=mfinkle
authorMargaret Leibovic <margaret.leibovic@gmail.com>
Tue, 07 Oct 2014 15:32:28 -0700
changeset 209311 6ee8bbf1b8f2e652ed2bbdfeaf155183ff533ee2
parent 209310 e85576df82277dba460a6382968338941eac321c
child 209312 0554ceb29cdcac1eaad3a4c6d94f995aa79b80cd
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewersmfinkle
bugs1079450
milestone35.0a1
Bug 1079450 - Let uninstall listener handle removing add-on from list. r=mfinkle
mobile/android/chrome/content/aboutAddons.js
--- a/mobile/android/chrome/content/aboutAddons.js
+++ b/mobile/android/chrome/content/aboutAddons.js
@@ -438,39 +438,34 @@ var Addons = {
     let addon = detailItem.addon;
     if (!addon)
       return;
 
     this.uninstall(addon);
   },
 
   uninstall: function uninstall(aAddon) {
-    let list = document.getElementById("addons-list");
-
     if (!aAddon) {
-        return;
+      return;
     }
 
     let listItem = this._getElementForAddon(aAddon.id);
+    aAddon.uninstall();
 
-    aAddon.uninstall();
     if (aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL) {
       this.showRestart();
 
       // A disabled addon doesn't need a restart so it has no pending ops and
       // can't be cancelled
       let opType = this._getOpTypeForOperations(aAddon.pendingOperations);
       if (!aAddon.isActive && opType == "")
         opType = "needs-uninstall";
 
       detailItem.setAttribute("opType", opType);
       listItem.setAttribute("opType", opType);
-    } else {
-      list.removeChild(listItem);
-      history.back();
     }
   },
 
   cancelUninstall: function ev_cancelUninstall() {
     let detailItem = document.querySelector("#addons-details > .addon-item");
     let addon = detailItem.addon;
     if (!addon)
       return;
@@ -534,16 +529,22 @@ var Addons = {
       list.insertBefore(element, list.firstElementChild);
     }
   },
 
   onUninstalled: function(aAddon) {
     let list = document.getElementById("addons-list");
     let element = this._getElementForAddon(aAddon.id);
     list.removeChild(element);
+
+    // Go back if we're in the detail view of the add-on that was uninstalled.
+    let detailItem = document.querySelector("#addons-details > .addon-item");
+    if (detailItem.addon == aAddon) {
+      history.back();
+    }
   },
 
   onInstallFailed: function(aInstall) {
   },
 
   onDownloadProgress: function xpidm_onDownloadProgress(aInstall) {
   },