fix delete profile

This commit is contained in:
Gustavo Maximiliano Cortez 2015-01-14 15:33:19 -03:00
commit 1a6f0aacf1
2 changed files with 20 additions and 8 deletions

View file

@ -1,5 +1,5 @@
'use strict';
angular.module('copayApp.controllers').controller('ProfileController', function($scope, $rootScope, $location, $modal, $filter, $timeout, backupService, identityService, isMobile, isCordova) {
angular.module('copayApp.controllers').controller('ProfileController', function($scope, $rootScope, $location, $modal, $filter, $timeout, backupService, identityService, isMobile, isCordova, notification) {
$scope.username = $rootScope.iden.getName();
$scope.isSafari = isMobile.Safari();
$scope.isCordova = isCordova;
@ -26,16 +26,20 @@ angular.module('copayApp.controllers').controller('ProfileController', function(
};
$scope.deleteProfile = function() {
$scope.loading = true;
identityService.deleteProfile(function(err, res) {
$scope.loading = false;
if (err) {
log.warn(err);
notification.error('Error', 'Could not delete profile');
return;
$timeout(function () { $scope.$digest(); });
}
else {
$location.path('/');
$timeout(function() {
notification.success('Success', 'Profile successfully deleted');
});
}
$location.path('/');
$timeout(function() {
notification.error('Success', 'Profile successfully deleted');
});
});
};
});