From 74b61624e5891f14fee25bd1bcc38d1f30efc530 Mon Sep 17 00:00:00 2001 From: Gustavo Maximiliano Cortez Date: Tue, 11 Nov 2014 12:54:52 -0300 Subject: [PATCH] deleting wallet with callback --- js/controllers/more.js | 8 +++++++- js/services/controllerUtils.js | 11 ++++------- views/manage.html | 2 +- views/more.html | 8 +++++++- 4 files changed, 19 insertions(+), 10 deletions(-) diff --git a/js/controllers/more.js b/js/controllers/more.js index 5af6313a9..f1e129e4a 100644 --- a/js/controllers/more.js +++ b/js/controllers/more.js @@ -88,7 +88,13 @@ angular.module('copayApp.controllers').controller('MoreController', }; $scope.deleteWallet = function() { - controllerUtils.deleteWallet($scope); + $scope.loading = true; + controllerUtils.deleteWallet($scope, $rootScope.wallet, function() { + $rootScope.wallet = null; + var lastFocused = $rootScope.iden.getLastFocusedWallet(); + controllerUtils.bindProfile($scope, $rootScope.iden, lastFocused); + $scope.loading = false; + }); }; $scope.purge = function(deleteAll) { diff --git a/js/services/controllerUtils.js b/js/services/controllerUtils.js index 73ea2d818..b54f62d2b 100644 --- a/js/services/controllerUtils.js +++ b/js/services/controllerUtils.js @@ -359,15 +359,12 @@ angular.module('copayApp.services') $rootScope.pendingTxCount = res.pendingForUs; }; - root.deleteWallet = function($scope, w, skipBind) { - w = w || $rootScope.wallet; + root.deleteWallet = function($scope, w, cb) { + if (!w) return root.onErrorDigest(); var name = w.getName(); $rootScope.iden.deleteWallet(w.id, function() { - notification.info(name + ' deleted', $filter('translate')('Wallet deleted')); - if (skipBind) return skipBind(); - $rootScope.wallet = null; - var lastFocused = $rootScope.iden.getLastFocusedWallet(); - root.bindProfile($scope, $rootScope.iden, lastFocused); + notification.info(name + ' deleted', $filter('translate')('This wallet was deleted')); + return cb(); }); }; diff --git a/views/manage.html b/views/manage.html index 1e5f8fe45..c952c85c9 100644 --- a/views/manage.html +++ b/views/manage.html @@ -56,7 +56,7 @@ Delete diff --git a/views/more.html b/views/more.html index 108151341..59a9e29ad 100644 --- a/views/more.html +++ b/views/more.html @@ -48,7 +48,13 @@

Delete Wallet

If all funds have been removed from your wallet and you do not wish to have the wallet data stored on your computer anymore, you can delete your wallet.

- Delete + + Delete + Deleting... +