refactor root.installStartupHandlers

This commit is contained in:
Matias Alejo Garcia 2014-06-12 11:03:24 -03:00
commit ec859355c6
3 changed files with 33 additions and 22 deletions

View file

@ -84,7 +84,7 @@ angular.module('copayApp.controllers').controller('SetupController',
passphrase: passphrase,
};
var w = walletFactory.create(opts);
controllerUtils.startNetwork(w);
controllerUtils.startNetwork(w, $scope);
});
};

View file

@ -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;
});
}
});