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,
|
passphrase: passphrase,
|
||||||
};
|
};
|
||||||
var w = walletFactory.create(opts);
|
var w = walletFactory.create(opts);
|
||||||
controllerUtils.startNetwork(w);
|
controllerUtils.startNetwork(w, $scope);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -34,8 +34,7 @@ angular.module('copayApp.controllers').controller('SigninController',
|
||||||
$rootScope.$digest();
|
$rootScope.$digest();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
installStartupHandlers(w);
|
controllerUtils.startNetwork(w, $scope);
|
||||||
controllerUtils.startNetwork(w);
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -65,25 +64,9 @@ angular.module('copayApp.controllers').controller('SigninController',
|
||||||
$rootScope.$flashMessage = { message: 'Unknown error', type: 'error'};
|
$rootScope.$flashMessage = { message: 'Unknown error', type: 'error'};
|
||||||
controllerUtils.onErrorDigest();
|
controllerUtils.onErrorDigest();
|
||||||
} else {
|
} else {
|
||||||
controllerUtils.startNetwork(w);
|
controllerUtils.startNetwork(w, $scope);
|
||||||
installStartupHandlers(w);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
|
||||||
|
|
||||||
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
|
message: msg
|
||||||
};
|
};
|
||||||
$rootScope.$digest();
|
$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) {
|
var handlePeerVideo = function(err, peerID, url) {
|
||||||
if (err) {
|
if (err) {
|
||||||
delete $rootScope.videoInfo[peerID];
|
delete $rootScope.videoInfo[peerID];
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue