working with events
This commit is contained in:
parent
3ae6378678
commit
494c21132a
4 changed files with 26 additions and 10 deletions
|
|
@ -24,6 +24,7 @@ angular.module('copayApp.controllers').controller('HomeController', function($sc
|
||||||
}
|
}
|
||||||
$rootScope.starting = true;
|
$rootScope.starting = true;
|
||||||
identityService.open(form.email.$modelValue, form.password.$modelValue, function(err) {
|
identityService.open(form.email.$modelValue, form.password.$modelValue, function(err) {
|
||||||
|
console.log('[home.js.27]'); //TODO
|
||||||
$rootScope.starting = false;
|
$rootScope.starting = false;
|
||||||
if (err) {
|
if (err) {
|
||||||
copay.logger.warn(err);
|
copay.logger.warn(err);
|
||||||
|
|
|
||||||
|
|
@ -44,14 +44,30 @@ angular.module('copayApp.controllers').controller('SidebarController', function(
|
||||||
|
|
||||||
|
|
||||||
$scope.init = function() {
|
$scope.init = function() {
|
||||||
|
|
||||||
|
// Change focused wallet
|
||||||
if ($rootScope.wallet) {
|
if ($rootScope.wallet) {
|
||||||
$rootScope.$watch('wallet', function() {
|
$rootScope.$watch('wallet', function() {
|
||||||
$scope.walletSelection = false;
|
$scope.walletSelection = false;
|
||||||
$scope.setWallets();
|
$scope.setWallets();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
|
// Change wallet list
|
||||||
|
if ($rootScope.iden) {
|
||||||
|
var iden = $rootScope.iden;
|
||||||
|
iden.on('newWallet', function() {
|
||||||
|
$scope.walletSelection = false;
|
||||||
|
$scope.setWallets();
|
||||||
|
});
|
||||||
|
iden.on('deleteWallet', function() {
|
||||||
|
$scope.walletSelection = false;
|
||||||
|
$scope.setWallets();
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
$scope.setWallets = function() {
|
$scope.setWallets = function() {
|
||||||
if (!$rootScope.iden) return;
|
if (!$rootScope.iden) return;
|
||||||
|
|
|
||||||
|
|
@ -165,17 +165,16 @@ Identity.prototype.emitAndKeepAlive = function(args) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @desc open profile's wallets. Call it AFTER setting
|
* @desc open profile's wallets. Call it AFTER setting
|
||||||
* the proper even listeners
|
* the proper even listeners. no callback.
|
||||||
*
|
*
|
||||||
* @param cb
|
|
||||||
*/
|
*/
|
||||||
Identity.prototype.openWallets = function(cb) {
|
Identity.prototype.openWallets = function() {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
|
|
||||||
if (_.isEmpty(self.walletIds)) {
|
if (_.isEmpty(self.walletIds)) {
|
||||||
self.emitAndKeepAlive('noWallets')
|
self.emitAndKeepAlive('noWallets')
|
||||||
return cb();
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// First read the lastFocused wallet
|
// First read the lastFocused wallet
|
||||||
|
|
@ -187,10 +186,10 @@ Identity.prototype.openWallets = function(cb) {
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log('[Identity.js.188]', self.walletIds, self.focusedTimestamps); //TODO
|
console.log('[Identity.js.188]', self.walletIds, self.focusedTimestamps); //TODO
|
||||||
// Then read the rest of the wallets...
|
// opens the wallets, in the order they were last accessed. Emits open events (newWallet)
|
||||||
async.eachSeries(self.walletIds, function(walletId, a_cb) {
|
async.eachSeries(self.walletIds, function(walletId, a_cb) {
|
||||||
self.readAndBindWallet(walletId, a_cb);
|
self.readAndBindWallet(walletId, a_cb);
|
||||||
}, cb);
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -85,7 +85,8 @@ angular.module('copayApp.services')
|
||||||
if (err) return cb(err);
|
if (err) return cb(err);
|
||||||
console.log('[identityService.js.95] LISTO OPEN!!'); //TODO
|
console.log('[identityService.js.95] LISTO OPEN!!'); //TODO
|
||||||
root.bind(iden);
|
root.bind(iden);
|
||||||
return iden.openWallets(cb);
|
iden.openWallets();
|
||||||
|
return cb();
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -243,9 +244,8 @@ angular.module('copayApp.services')
|
||||||
};
|
};
|
||||||
|
|
||||||
root.bind = function(iden) {
|
root.bind = function(iden) {
|
||||||
|
|
||||||
console.log('[identityService.js.250] PROFILE BINE'); //TODO
|
|
||||||
preconditions.checkArgument(_.isObject(iden));
|
preconditions.checkArgument(_.isObject(iden));
|
||||||
|
copay.logger.debug('Binding profile...');
|
||||||
|
|
||||||
var self = this;
|
var self = this;
|
||||||
root.setupGlobalVariables(iden);
|
root.setupGlobalVariables(iden);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue