fix import wallet
This commit is contained in:
parent
3607056d64
commit
e5f4844ca5
4 changed files with 26 additions and 19 deletions
|
|
@ -22,7 +22,6 @@ angular.module('copayApp.controllers').controller('ImportController',
|
|||
|
||||
var updateStatus = function(status) {
|
||||
$scope.importStatus = status;
|
||||
$scope.$digest();
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -80,19 +79,20 @@ angular.module('copayApp.controllers').controller('ImportController',
|
|||
$scope.importOpts.skipFields = skipFields;
|
||||
|
||||
|
||||
if (backupFile) {
|
||||
reader.readAsBinaryString(backupFile);
|
||||
} else {
|
||||
updateStatus('Importing wallet - Procesing backup...');
|
||||
identityService.importWallet(encryptedObj, $scope.password, $scope.importOpts, function(err) {
|
||||
if (err) {
|
||||
$scope.loading = false;
|
||||
$scope.error = 'Could not read wallet. Please check your password';
|
||||
$rootScope.$digest();
|
||||
return;
|
||||
}
|
||||
copay.Compatibility.deleteOldWallet(backupOldWallet);
|
||||
});
|
||||
}
|
||||
$timeout(function() {
|
||||
if (backupFile) {
|
||||
reader.readAsBinaryString(backupFile);
|
||||
} else {
|
||||
updateStatus('Importing wallet - Procesing backup...');
|
||||
identityService.importWallet(backupText, $scope.password, $scope.importOpts, function(err) {
|
||||
if (err) {
|
||||
$scope.loading = false;
|
||||
$scope.error = 'Could not read wallet. Please check your password';
|
||||
$rootScope.$digest();
|
||||
return;
|
||||
}
|
||||
});
|
||||
}
|
||||
}, 1);
|
||||
};
|
||||
});
|
||||
|
|
|
|||
|
|
@ -50,8 +50,10 @@ angular.module('copayApp.controllers').controller('ImportProfileController',
|
|||
};
|
||||
|
||||
$scope.import = function(form) {
|
||||
$scope.loading = true;
|
||||
|
||||
if (form.$invalid) {
|
||||
$scope.loading = false;
|
||||
$scope.error = 'Please enter the required fields';
|
||||
return;
|
||||
}
|
||||
|
|
@ -60,11 +62,11 @@ angular.module('copayApp.controllers').controller('ImportProfileController',
|
|||
var password = form.password.$modelValue;
|
||||
|
||||
if (!backupFile && !backupText) {
|
||||
$scope.loading = false;
|
||||
$scope.error = 'Please, select your backup file';
|
||||
return;
|
||||
}
|
||||
|
||||
$scope.loading = true;
|
||||
$timeout(function() {
|
||||
if (backupFile) {
|
||||
reader.readAsBinaryString(backupFile);
|
||||
|
|
|
|||
|
|
@ -247,6 +247,7 @@ Compatibility.kdf = function(password) {
|
|||
};
|
||||
|
||||
Compatibility.deleteOldWallet = function(walletObj) {
|
||||
console.log('[Compatibility.js:249]',walletObj); //TODO
|
||||
localStorage.removeItem('wallet::' + walletObj.id + '_' + walletObj.name);
|
||||
log.info('Old wallet ' + walletObj.name + ' deleted: ' + walletObj.id);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -13,11 +13,15 @@
|
|||
<div class="large-12 columns">
|
||||
<div class="panel">
|
||||
<form name="importForm" ng-submit="import(importForm)" novalidate>
|
||||
<div class="text-warning size-12 m20b" ng-show="error">
|
||||
<i class="fi-x"></i> {{error|translate}}
|
||||
<div class="box-notification" ng-show="error">
|
||||
<div class="box-icon error">
|
||||
<i class="fi-x size-24"></i>
|
||||
</div>
|
||||
<span class="text-warning size-14">
|
||||
{{error|translate}}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
||||
<div ng-show="!is_iOS && !backupOldWallet">
|
||||
<legend for="backupFile" class="m10b">
|
||||
<span translate>Choose backup file from your computer</span> <i class="fi-laptop"></i>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue