diff --git a/js/controllers/import.js b/js/controllers/import.js index f0df43bee..b091bfc1e 100644 --- a/js/controllers/import.js +++ b/js/controllers/import.js @@ -34,8 +34,11 @@ angular.module('copayApp.controllers').controller('ImportController', updateStatus('Importing wallet - Procesing backup...'); identityService.importWallet(encryptedObj, $scope.password, {}, function(err) { if (err) { - $scope.loading = false; + $rootScope.starting = false; $scope.error = 'Could not read wallet. Please check your password'; + $timeout(function() { + $rootScope.$digest(); + }, 1); } }); } @@ -43,10 +46,8 @@ angular.module('copayApp.controllers').controller('ImportController', }; $scope.import = function(form) { - $scope.loading = true; if (form.$invalid) { - $scope.loading = false; $scope.error = 'There is an error in the form'; return; } @@ -61,11 +62,12 @@ angular.module('copayApp.controllers').controller('ImportController', } if (!backupFile && !backupText) { - $scope.loading = false; $scope.error = 'Please, select your backup file'; return; } + $rootScope.starting = true; + $scope.importOpts = {}; var skipFields = []; @@ -79,21 +81,19 @@ angular.module('copayApp.controllers').controller('ImportController', if (skipFields) $scope.importOpts.skipFields = skipFields; - - $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'; + if (backupFile) { + reader.readAsBinaryString(backupFile); + } else { + updateStatus('Importing wallet - Procesing backup...'); + identityService.importWallet(backupText, $scope.password, $scope.importOpts, function(err) { + if (err) { + $rootScope.starting = false; + $scope.error = 'Could not read wallet. Please check your password'; + $timeout(function() { $rootScope.$digest(); - return; - } - }); - } - }, 1); + }, 1); + } + }); + } }; }); diff --git a/js/controllers/importProfile.js b/js/controllers/importProfile.js index bd9dd0361..5b75f4645 100644 --- a/js/controllers/importProfile.js +++ b/js/controllers/importProfile.js @@ -26,8 +26,8 @@ angular.module('copayApp.controllers').controller('ImportProfileController', updateStatus('Importing profile - Setting things up...'); identityService.importProfile(str,password, function(err, iden) { - $scope.loading = false; if (err) { + $rootScope.starting = false; copay.logger.warn(err); if ((err.toString() || '').match('BADSTR')) { $scope.error = 'Bad password or corrupt profile file'; @@ -36,6 +36,9 @@ angular.module('copayApp.controllers').controller('ImportProfileController', } else { $scope.error = 'Unknown error'; } + $timeout(function() { + $rootScope.$digest(); + }, 1); } }); }; @@ -51,10 +54,8 @@ 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; } @@ -63,17 +64,16 @@ 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; } + + $rootScope.starting = true; - $timeout(function() { - if (backupFile) { - reader.readAsBinaryString(backupFile); - } else { - _importBackup(backupText); - } - }, 1); + if (backupFile) { + reader.readAsBinaryString(backupFile); + } else { + _importBackup(backupText); + } }; }); diff --git a/js/services/identityService.js b/js/services/identityService.js index 8dcc89a04..373880a13 100644 --- a/js/services/identityService.js +++ b/js/services/identityService.js @@ -136,7 +136,7 @@ angular.module('copayApp.services') pendingTxsService.update(); $timeout(function() { $rootScope.$digest(); - }) + }, 1); }; root.notifyTxProposalEvent = function(w, e) { diff --git a/views/import.html b/views/import.html index 790cb08ae..8494c69a4 100644 --- a/views/import.html +++ b/views/import.html @@ -1,9 +1,9 @@