2015-03-06 12:00:10 -03:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
|
|
angular.module('copayApp.controllers').controller('preferencesDeleteWalletController',
|
2016-09-22 11:55:23 -03:00
|
|
|
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() {
|
2016-09-05 17:36:11 -03:00
|
|
|
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) {
|
2016-09-05 17:36:11 -03:00
|
|
|
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);
|
2015-04-30 13:03:30 -03:00
|
|
|
if (err) {
|
2016-09-01 10:56:13 -03:00
|
|
|
popupService.showAlert(gettextCatalog.getString('Error'), err.message || err);
|
2015-04-30 13:03:30 -03:00
|
|
|
} else {
|
2016-09-22 16:43:35 -03:00
|
|
|
$ionicHistory.removeBackView();
|
2016-08-19 13:07:18 -03:00
|
|
|
$state.go('tabs.home');
|
2015-04-30 13:03:30 -03:00
|
|
|
}
|
|
|
|
|
});
|
2015-03-06 12:00:10 -03:00
|
|
|
};
|
2015-07-29 12:37:51 -03:00
|
|
|
});
|