better state handling at home
This commit is contained in:
parent
f490f4a661
commit
f4fd6c24f7
1 changed files with 21 additions and 2 deletions
|
|
@ -16,6 +16,20 @@ angular.module('copayApp.controllers').controller('HomeController', function($sc
|
||||||
|
|
||||||
Compatibility.check($scope);
|
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.openProfile = function(form) {
|
||||||
$scope.confirmedEmail = false;
|
$scope.confirmedEmail = false;
|
||||||
if (form && form.$invalid) {
|
if (form && form.$invalid) {
|
||||||
|
|
@ -24,8 +38,8 @@ angular.module('copayApp.controllers').controller('HomeController', function($sc
|
||||||
}
|
}
|
||||||
$rootScope.starting = true;
|
$rootScope.starting = true;
|
||||||
identityService.open(form.email.$modelValue, form.password.$modelValue, function(err, iden) {
|
identityService.open(form.email.$modelValue, form.password.$modelValue, function(err, iden) {
|
||||||
$rootScope.starting = false;
|
if (err) {
|
||||||
if (err) {
|
$rootScope.starting = false;
|
||||||
copay.logger.warn(err);
|
copay.logger.warn(err);
|
||||||
if ((err.toString() || '').match('PNOTFOUND')) {
|
if ((err.toString() || '').match('PNOTFOUND')) {
|
||||||
$scope.error = 'Invalid email or password';
|
$scope.error = 'Invalid email or password';
|
||||||
|
|
@ -33,6 +47,11 @@ angular.module('copayApp.controllers').controller('HomeController', function($sc
|
||||||
$scope.error = 'Unknown error';
|
$scope.error = 'Unknown error';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (iden) {
|
||||||
|
iden.on('newWallet', $scope.done);
|
||||||
|
iden.on('noWallets', $scope.done);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue