Bug 1079450 - Let uninstall listener handle removing add-on from list. r=mfinkle
--- 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) {
},