refactor root.installStartupHandlers
This commit is contained in:
parent
618bff3895
commit
ec859355c6
3 changed files with 33 additions and 22 deletions
|
|
@ -84,7 +84,7 @@ angular.module('copayApp.controllers').controller('SetupController',
|
|||
passphrase: passphrase,
|
||||
};
|
||||
var w = walletFactory.create(opts);
|
||||
controllerUtils.startNetwork(w);
|
||||
controllerUtils.startNetwork(w, $scope);
|
||||
});
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -34,8 +34,7 @@ angular.module('copayApp.controllers').controller('SigninController',
|
|||
$rootScope.$digest();
|
||||
return;
|
||||
}
|
||||
installStartupHandlers(w);
|
||||
controllerUtils.startNetwork(w);
|
||||
controllerUtils.startNetwork(w, $scope);
|
||||
});
|
||||
};
|
||||
|
||||
|
|
@ -65,25 +64,9 @@ angular.module('copayApp.controllers').controller('SigninController',
|
|||
$rootScope.$flashMessage = { message: 'Unknown error', type: 'error'};
|
||||
controllerUtils.onErrorDigest();
|
||||
} else {
|
||||
controllerUtils.startNetwork(w);
|
||||
installStartupHandlers(w);
|
||||
controllerUtils.startNetwork(w, $scope);
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
function installStartupHandlers(wallet) {
|
||||
wallet.on('serverError', function(msg) {
|
||||
$rootScope.$flashMessage = {
|
||||
message: 'There was an error connecting to the PeerJS server.'
|
||||
+(msg||'Check you settings and Internet connection.'),
|
||||
type: 'error',
|
||||
};
|
||||
controllerUtils.onErrorDigest($scope);
|
||||
});
|
||||
wallet.on('ready', function() {
|
||||
$scope.loading = false;
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
|
|
|
|||
|
|
@ -39,9 +39,37 @@ angular.module('copayApp.services')
|
|||
message: msg
|
||||
};
|
||||
$rootScope.$digest();
|
||||
}
|
||||
};
|
||||
|
||||
root.installStartupHandlers = function(wallet, $scope) {
|
||||
wallet.on('serverError', function(msg) {
|
||||
$rootScope.$flashMessage = {
|
||||
message: 'There was an error connecting to the PeerJS server.'
|
||||
+(msg||'Check you settings and Internet connection.'),
|
||||
type: 'error',
|
||||
};
|
||||
root.onErrorDigest($scope);
|
||||
$location.path('addresses');
|
||||
});
|
||||
wallet.on('connectionError', function() {
|
||||
var message = "Looks like you are already connected to this wallet, please logout from it and try importing it again.";
|
||||
$rootScope.$flashMessage = { message: message, type: 'error'};
|
||||
root.onErrorDigest($scope);
|
||||
});
|
||||
wallet.on('serverError', function() {
|
||||
$rootScope.$flashMessage = { message: 'The PeerJS server is not responding, please try again', type: 'error'};
|
||||
root.onErrorDigest($scope);
|
||||
});
|
||||
wallet.on('ready', function() {
|
||||
$scope.loading = false;
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
root.startNetwork = function(w, $scope) {
|
||||
|
||||
root.installStartupHandlers(w, $scope);
|
||||
|
||||
root.startNetwork = function(w) {
|
||||
var handlePeerVideo = function(err, peerID, url) {
|
||||
if (err) {
|
||||
delete $rootScope.videoInfo[peerID];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue