Stop any active app task on uninstall

This commit is contained in:
Girish Ramakrishnan
2019-09-29 16:52:57 -07:00
parent 47282afa22
commit cc833f0b73

View File

@@ -673,18 +673,23 @@ angular.module('Application').controller('AppController', ['$scope', '$location'
submit: function () {
$scope.uninstall.busy = true;
Client.uninstallApp($scope.app.id, function (error) {
if (error && error.statusCode === 402) { // unpurchase failed
Client.error('Relogin to Cloudron App Store');
} else if (error) {
Client.error(error);
} else {
$('#uninstallModal').modal('hide');
Client.refreshAppCache($scope.app.id); // reflect the new app state immediately
$location.path('/apps');
}
var NOOP = function (next) { return next(); };
var stopAppTask = $scope.app.taskId ? Client.stopTask.bind(null, $scope.app.taskId) : NOOP;
$scope.uninstall.busy = false;
stopAppTask(function () { // ignore error
Client.uninstallApp($scope.app.id, function (error) {
if (error && error.statusCode === 402) { // unpurchase failed
Client.error('Relogin to Cloudron App Store');
} else if (error) {
Client.error(error);
} else {
$('#uninstallModal').modal('hide');
Client.refreshAppCache($scope.app.id); // reflect the new app state immediately
$location.path('/apps');
}
$scope.uninstall.busy = false;
});
});
}
};