Wallet/src/js/controllers/preferencesDelete.js

29 lines
1.2 KiB
JavaScript
Raw Normal View History

2015-03-06 12:00:10 -03:00
'use strict';
angular.module('copayApp.controllers').controller('preferencesDeleteWalletController',
function($scope, $stateParams, $ionicHistory, gettextCatalog, lodash, profileService, $state, ongoingProcess, popupService) {
2016-08-19 12:50:52 -03:00
var wallet = profileService.getWallet($stateParams.walletId);
$scope.alias = lodash.isEqual(wallet.name, wallet.credentials.walletName) ? null : wallet.name + ' ';
2016-09-26 10:35:33 -04:00
$scope.walletName = wallet.credentials.walletName;
2015-03-06 12:00:10 -03:00
2016-08-19 12:50:52 -03:00
$scope.showDeletePopup = function() {
var title = gettextCatalog.getString('Warning!');
var message = gettextCatalog.getString('Are you sure you want to delete this wallet?');
2016-09-12 13:58:36 -03:00
popupService.showConfirm(title, message, null, null, function(res) {
if (res) deleteWallet();
2015-03-06 12:00:10 -03:00
});
};
2016-08-19 12:50:52 -03:00
function deleteWallet() {
2016-06-13 15:25:40 -03:00
ongoingProcess.set('deletingWallet', true);
2016-08-19 12:50:52 -03:00
profileService.deleteWalletClient(wallet, function(err) {
2016-06-13 15:25:40 -03:00
ongoingProcess.set('deletingWallet', false);
if (err) {
2016-09-01 10:56:13 -03:00
popupService.showAlert(gettextCatalog.getString('Error'), err.message || err);
} else {
$ionicHistory.removeBackView();
2016-08-19 13:07:18 -03:00
$state.go('tabs.home');
}
});
2015-03-06 12:00:10 -03:00
};
2015-07-29 12:37:51 -03:00
});