options for running with local peerJs server. Ux fixes

This commit is contained in:
Matias Alejo Garcia 2014-04-17 16:27:15 -03:00
commit 1e64031ec3
7 changed files with 85 additions and 31 deletions

View file

@ -2,7 +2,32 @@
angular.module('copay.controllerUtils').factory('controllerUtils', function ($rootScope, $location, Socket) {
var root = {};
root.logout = function(scope) {
delete $rootScope['wallet'];
$rootScope.totalBalance = 0;
$location.path('signin');
};
root.onError = function(scope) {
if (scope) scope.loading = false;
$rootScope.flashMessage = {type:'error', message: 'Could not connect to peer'};
root.logout();
}
root.onErrorDigest = function(scope) {
root.onError(scope);
$rootScope.$digest();
}
root.setupUxHandlers = function(w) {
w.on('badMessage', function(peerId) {
$rootScope.flashMessage = {type:'error', message: 'Received wrong message from peer id:' + peerId};
});
w.on('created', function() {
$location.path('peer');
$rootScope.wallet = w;
@ -14,14 +39,11 @@ angular.module('copay.controllerUtils').factory('controllerUtils', function ($ro
});
});
w.on('refresh', function() {
console.log('[controllerUtils.js] RECEIVED REFRESH'); //TODO
});
w.on('openError', function(){
$scope.loading = false;
$rootScope.flashMessage = {type:'error', message: 'Wallet not found'};
$location.path('signin');
console.log('[controllerUtils.js] Refreshing'); //TODO
$rootScope.$digest();
});
w.on('openError', root.onErrorDigest);
w.on('close', root.onErrorDigest);
};
root.handleTransactionByAddress = function(scope) {