This commit is contained in:
Matias Alejo Garcia 2014-12-06 15:30:32 -03:00
commit de54f3aac8
6 changed files with 13 additions and 32 deletions

View file

@ -56,21 +56,6 @@ angular.module('copayApp.controllers').controller('HomeController', function($sc
}
});
$scope.done = function() {
$rootScope.starting = false;
$rootScope.$digest();
};
$scope.$on("$destroy", function() {
var iden = $rootScope.iden;
if (iden) {
iden.removeListener('newWallet', $scope.done);
iden.removeListener('noWallets', $scope.done);
}
});
$scope.openWithPin = function(pin) {
if (!pin) {
@ -92,11 +77,8 @@ angular.module('copayApp.controllers').controller('HomeController', function($sc
$scope.openWallets = function() {
preconditions.checkState($rootScope.iden);
var iden = $rootScope.iden;
$rootScope.hideNavigation = false;
$rootScope.starting = true;
iden.on('newWallet', $scope.done);
iden.on('noWallets', $scope.done);
iden.openWallets();
};
@ -169,7 +151,6 @@ angular.module('copayApp.controllers').controller('HomeController', function($sc
// mobile
if ($scope.isMobile && !$rootScope.hasPin) {
$scope.done();
_credentials = {
email: email,
password: password,

View file

@ -68,7 +68,7 @@ angular.module('copayApp.controllers').controller('HomeWalletController', functi
removeWatch();
w.removeListener('txProposalEvent', _updateTxs);
};
});
});
$scope.setAlternativeAmount = function(w, tx, cb) {
rateService.whenAvailable(function() {

View file

@ -31,6 +31,7 @@ angular.module('copayApp.services')
root.goWalletHome = function() {
var w = $rootScope.wallet;
if (w) {
$rootScope.starting = false;
if (!w.isComplete()) {
$location.path('/copayers');
} else {
@ -233,7 +234,7 @@ angular.module('copayApp.services')
w.on('txProposalEvent', function(e) {
if (root.isFocused(wid)) {
pendingTxsService.update();
pendingTxsService.update();
}
balanceService.update(w, function() {
@ -288,7 +289,6 @@ angular.module('copayApp.services')
var self = this;
root.setupGlobalVariables(iden);
iden.on('newWallet', function(wid) {
var w = iden.getWalletById(wid);
copay.logger.debug('newWallet:', w.getName(), wid, iden.getLastFocusedWalletId());
@ -298,20 +298,25 @@ angular.module('copayApp.services')
root.setFocusedWallet(w, true);
root.goWalletHome();
}
// At the end (after all handlers are in place)...start the wallet.
w.netStart();
});
iden.on('noWallets', function() {
notification.warning('No Wallets','Your profile has no wallet. Create one here');
$rootScope.starting = false;
$location.path('/create');
$rootScope.$digest()
$timeout(function() {
$rootScope.$digest();
}, 1);
});
iden.on('walletDeleted', function(wid) {
// do nothing. this is handled 'on sync' on controller.
});
iden.on('walletStorageError', function (wid, message) {
iden.on('walletStorageError', function(wid, message) {
notification.error('Error storing wallet', message);
});