diff --git a/js/controllers/import.js b/js/controllers/import.js index f1fcc7e0f..7089a1ccc 100644 --- a/js/controllers/import.js +++ b/js/controllers/import.js @@ -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); }; }); diff --git a/js/controllers/importProfile.js b/js/controllers/importProfile.js index 15d76cd4e..4ea348626 100644 --- a/js/controllers/importProfile.js +++ b/js/controllers/importProfile.js @@ -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); diff --git a/js/models/Compatibility.js b/js/models/Compatibility.js index bab4f5b57..94da67c59 100644 --- a/js/models/Compatibility.js +++ b/js/models/Compatibility.js @@ -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); }; diff --git a/views/import.html b/views/import.html index 6a37a559a..703aee06c 100644 --- a/views/import.html +++ b/views/import.html @@ -13,11 +13,15 @@