Merge pull request #3408 from cmgustavo/ref/delete-wallet-01

Ref delete wallet
This commit is contained in:
Matias Alejo Garcia 2015-11-06 17:05:03 -03:00
commit b28ecaad6d
3 changed files with 22 additions and 8 deletions

View file

@ -53,12 +53,9 @@ angular.module('copayApp.controllers').controller('preferencesDeleteWalletContro
if (err) { if (err) {
self.error = err.message || err; self.error = err.message || err;
} else { } else {
storageService.removeTxHistory(fc.credentials.walletId, function() { notification.success(gettextCatalog.getString('Success'), gettextCatalog.getString('The wallet "{{walletName}}" was deleted', {
notification.success(gettextCatalog.getString('Success'), gettextCatalog.getString('The wallet "{{walletName}}" was deleted', { walletName: walletName
walletName: walletName }));
}));
return;
});
} }
}); });
}; };

View file

@ -303,16 +303,29 @@ angular.module('copayApp.services')
root.deleteWalletFC = function(opts, cb) { root.deleteWalletFC = function(opts, cb) {
var fc = root.focusedClient; var fc = root.focusedClient;
var walletId = fc.credentials.walletId;
$log.debug('Deleting Wallet:', fc.credentials.walletName); $log.debug('Deleting Wallet:', fc.credentials.walletName);
fc.removeAllListeners(); fc.removeAllListeners();
root.profile.credentials = lodash.reject(root.profile.credentials, { root.profile.credentials = lodash.reject(root.profile.credentials, {
walletId: fc.credentials.walletId walletId: walletId
}); });
delete root.walletClients[fc.credentials.walletId]; delete root.walletClients[walletId];
root.focusedClient = null; root.focusedClient = null;
storageService.clearLastAddress(walletId, function(err) {
if (err) $log.warn(err);
});
storageService.removeTxHistory(walletId, function(err) {
if (err) $log.warn(err);
});
storageService.clearBackupFlag(walletId, function(err) {
if (err) $log.warn(err);
});
$timeout(function() { $timeout(function() {
root.setWalletClients(); root.setWalletClients();
root.setAndStoreFocus(null, function() { root.setAndStoreFocus(null, function() {

View file

@ -159,6 +159,10 @@ angular.module('copayApp.services')
storage.get('backup-' + walletId, cb); storage.get('backup-' + walletId, cb);
}; };
root.clearBackupFlag = function(walletId, cb) {
storage.remove('backup-' + walletId, cb);
};
root.setCleanAndScanAddresses = function(walletId, cb) { root.setCleanAndScanAddresses = function(walletId, cb) {
storage.set('CleanAndScanAddresses', walletId, cb); storage.set('CleanAndScanAddresses', walletId, cb);
}; };