2015-11-16 17:43:54 -03:00
|
|
|
'use strict';
|
|
|
|
|
|
2016-08-17 15:53:17 -03:00
|
|
|
angular.module('copayApp.controllers').controller('preferencesDeleteWordsController', function($scope, $state, $stateParams, confirmDialog, lodash, notification, profileService, walletService, gettext) {
|
|
|
|
|
|
|
|
|
|
var wallet = profileService.getWallet($stateParams.walletId);
|
2016-06-04 16:19:19 -03:00
|
|
|
var msg = gettext('Are you sure you want to delete the recovery phrase?');
|
|
|
|
|
var successMsg = gettext('Recovery phrase deleted');
|
2015-11-16 17:43:54 -03:00
|
|
|
|
2016-08-17 15:53:17 -03:00
|
|
|
walletService.needsBackup(wallet, function(needsBackup) {
|
|
|
|
|
$scope.needsBackup = needsBackup;
|
|
|
|
|
});
|
|
|
|
|
if (lodash.isEmpty(wallet.credentials.mnemonic) && lodash.isEmpty(wallet.credentials.mnemonicEncrypted))
|
2016-06-13 16:13:35 -03:00
|
|
|
$scope.deleted = true;
|
2015-12-04 13:30:51 -03:00
|
|
|
|
2016-06-13 16:13:35 -03:00
|
|
|
$scope.delete = function() {
|
2016-06-04 16:19:19 -03:00
|
|
|
confirmDialog.show(msg, function(ok) {
|
|
|
|
|
if (ok) {
|
2016-08-17 15:53:17 -03:00
|
|
|
wallet.clearMnemonic();
|
|
|
|
|
profileService.updateCredentials(JSON.parse(wallet.export()), function() {
|
2016-06-04 16:19:19 -03:00
|
|
|
notification.success(successMsg);
|
2016-08-17 15:53:17 -03:00
|
|
|
$state.go('wallet.details');
|
2015-11-16 17:43:54 -03:00
|
|
|
});
|
2016-06-04 16:19:19 -03:00
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
});
|