mirror of https://github.com/BTCPrivate/copay.git
better state handling at home
This commit is contained in:
parent
f490f4a661
commit
f4fd6c24f7
|
@ -16,6 +16,20 @@ angular.module('copayApp.controllers').controller('HomeController', function($sc
|
|||
|
||||
Compatibility.check($scope);
|
||||
|
||||
$scope.done = function() {
|
||||
$rootScope.starting = false;
|
||||
};
|
||||
|
||||
|
||||
$scope.$on("$destroy", function(){
|
||||
var iden = $rootScope.iden;
|
||||
if (iden) {
|
||||
iden.removeListener('newWallets', $scope.done );
|
||||
iden.removeListener('noWallets', $scope.done );
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
$scope.openProfile = function(form) {
|
||||
$scope.confirmedEmail = false;
|
||||
if (form && form.$invalid) {
|
||||
|
@ -24,8 +38,8 @@ angular.module('copayApp.controllers').controller('HomeController', function($sc
|
|||
}
|
||||
$rootScope.starting = true;
|
||||
identityService.open(form.email.$modelValue, form.password.$modelValue, function(err, iden) {
|
||||
$rootScope.starting = false;
|
||||
if (err) {
|
||||
$rootScope.starting = false;
|
||||
copay.logger.warn(err);
|
||||
if ((err.toString() || '').match('PNOTFOUND')) {
|
||||
$scope.error = 'Invalid email or password';
|
||||
|
@ -33,6 +47,11 @@ angular.module('copayApp.controllers').controller('HomeController', function($sc
|
|||
$scope.error = 'Unknown error';
|
||||
}
|
||||
}
|
||||
|
||||
if (iden) {
|
||||
iden.on('newWallet', $scope.done);
|
||||
iden.on('noWallets', $scope.done);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue