Delete wallet function as service

This commit is contained in:
Gustavo Maximiliano Cortez 2014-10-21 14:26:58 -03:00 committed by Matias Alejo Garcia
commit c01cdb8b25
5 changed files with 29 additions and 19 deletions

View file

@ -34,20 +34,21 @@ angular.module('copayApp.controllers').controller('CopayersController',
$location.path('/receive');
};
$scope.deleteWallet = function() {
var w = $rootScope.iden;
iden.deleteWallet(w.id, function() {
controllerUtils.logout();
});
};
$scope.copayersList = function() {
$scope.copayers = $rootScope.wallet.getRegisteredPeerIds();
if ($rootScope.wallet) {
$scope.copayers = $rootScope.wallet.getRegisteredPeerIds();
}
return $scope.copayers;
}
$scope.isBackupReady = function(copayer) {
return $rootScope.wallet.publicKeyRing.isBackupReady(copayer.copayerId);
if ($rootScope.wallet) {
return $rootScope.wallet.publicKeyRing.isBackupReady(copayer.copayerId);
}
}
$scope.deleteWallet = function() {
controllerUtils.deleteWallet($scope);
}
});

View file

@ -52,6 +52,7 @@ angular.module('copayApp.controllers').controller('MoreController',
break;
}
}
$scope.save = function() {
w.changeSettings({
unitName: $scope.selectedUnit.shortName,
@ -83,12 +84,7 @@ angular.module('copayApp.controllers').controller('MoreController',
};
$scope.deleteWallet = function() {
$rootScope.iden.deleteWallet(w.id, function() {
notification.info('Wallet deleted', $filter('translate')('wallet deleted'));
$rootScope.wallet = null;
var lastFocused = $rootScope.iden.profile.getLastFocusedWallet();
controllerUtils.bindProfile($scope, $rootScope.iden, lastFocused);
});
controllerUtils.deleteWallet($scope);
};
$scope.purge = function(deleteAll) {

View file

@ -75,7 +75,9 @@ angular.module('copayApp.controllers').controller('SidebarController', function(
notification.warning('Session closed', 'Session closed because a long time of inactivity');
});
$scope.$on('$keepalive', function() {
$rootScope.wallet.keepAlive();
if ($rootScope.wallet) {
$rootScope.wallet.keepAlive();
}
});
}

View file

@ -388,6 +388,16 @@ angular.module('copayApp.services')
$rootScope.pendingTxCount = pendingForUs;
};
root.deleteWallet = function($scope, w) {
w = w || $rootScope.wallet;
$rootScope.iden.deleteWallet(w.id, function() {
notification.info('Wallet deleted', $filter('translate')('Wallet deleted'));
$rootScope.wallet = null;
var lastFocused = $rootScope.iden.profile.getLastFocusedWallet();
root.bindProfile($scope, $rootScope.iden, lastFocused);
});
};
function getActionList(actions) {
var peers = Object.keys(actions).map(function(i) {
return {