diff --git a/js/controllers/home.js b/js/controllers/home.js index 1d9790804..0d50cb53b 100644 --- a/js/controllers/home.js +++ b/js/controllers/home.js @@ -24,7 +24,6 @@ angular.module('copayApp.controllers').controller('HomeController', function($sc } $rootScope.starting = true; identityService.open(form.email.$modelValue, form.password.$modelValue, function(err) { -console.log('[home.js.27]'); //TODO $rootScope.starting = false; if (err) { copay.logger.warn(err); diff --git a/js/controllers/sidebar.js b/js/controllers/sidebar.js index 38fea1870..63a1d208e 100644 --- a/js/controllers/sidebar.js +++ b/js/controllers/sidebar.js @@ -33,7 +33,9 @@ angular.module('copayApp.controllers').controller('SidebarController', function( }; $scope.switchWallet = function(wid) { + $scope.walletSelection = false; identityService.setFocusedWallet(wid); + identityService.goWalletHome(); }; $scope.toggleWalletSelection = function() { diff --git a/js/models/Identity.js b/js/models/Identity.js index 7e8ce6d38..283bb688e 100644 --- a/js/models/Identity.js +++ b/js/models/Identity.js @@ -185,7 +185,6 @@ Identity.prototype.openWallets = function() { return va < vb ? 1 : (va === vb ? 0 : -1); }); - console.log('[Identity.js.188]', self.walletIds, self.focusedTimestamps); //TODO // opens the wallets, in the order they were last accessed. Emits open events (newWallet) async.eachSeries(self.walletIds, function(walletId, a_cb) { self.readAndBindWallet(walletId, a_cb); diff --git a/js/services/identityService.js b/js/services/identityService.js index 4ab811224..886e48bee 100644 --- a/js/services/identityService.js +++ b/js/services/identityService.js @@ -109,7 +109,7 @@ angular.module('copayApp.services') $location.path('/send'); }; - root.setFocusedWallet = function(w) { + root.setFocusedWallet = function(w, dontUpdateIt) { if (!_.isObject(w)) w = $rootScope.iden.getWalletById(w); preconditions.checkState(w && _.isObject(w)); @@ -117,9 +117,10 @@ angular.module('copayApp.services') copay.logger.debug('Set focus:', w.getName()); $rootScope.wallet = w; - $rootScope.iden.updateFocusedTimestamp(w.getId()); - pendingTxsService.update(); + if (!dontUpdateIt) + $rootScope.iden.updateFocusedTimestamp(w.getId()); + pendingTxsService.update(); $timeout(function() { $rootScope.$digest(); }) @@ -143,7 +144,7 @@ angular.module('copayApp.services') }); w.on('ready', function() { var isFocused = root.isFocused(wid); - console.log('GOT READY [identityService.js.184:isFocused:]', w.getName(), isFocused); //TODO + copay.logger.debug('Wallet:' + w.getName() + ' is ready. Focused:', isFocused); balanceService.update(w, function() { $rootScope.$digest(); @@ -252,15 +253,15 @@ angular.module('copayApp.services') iden.on('newWallet', function(wid) { var w = iden.getWalletById(wid); - copay.logger.debug('newWallet:', w.getName()); + copay.logger.debug('newWallet:', w.getName(), wid, iden.getLastFocusedWalletId()); root.installWalletHandlers(w); - w.netStart(); if (wid == iden.getLastFocusedWalletId()) { - copay.logger.debug('GOT Focused wallet!', w.getName()); - root.setFocusedWallet(w); + copay.logger.debug('GOT Focused wallet:', w.getName()); + root.setFocusedWallet(w, true); root.goWalletHome(); - $rootScope.$digest() } + // At the end (after all handlers are in place)...start the wallet. + w.netStart(); }); iden.on('noWallets', function() { @@ -273,7 +274,7 @@ angular.module('copayApp.services') if ($rootScope.wallet.id === wid) { $rootScope.wallet = null; var lastFocused = iden.getLastFocusedWalletId(); - self.setFocusedWallet(lastFocused); + root.setFocusedWallet(lastFocused); } }); @@ -304,7 +305,7 @@ angular.module('copayApp.services') }); }; - root.importProfile = function(str, password, cb){ + root.importProfile = function(str, password, cb) { copay.Identity.importFromEncryptedFullJson(str, password, { pluginManager: pluginManager, network: config.network, diff --git a/views/home.html b/views/home.html index 03aa994e0..b6edc54d3 100644 --- a/views/home.html +++ b/views/home.html @@ -9,7 +9,6 @@
 
Accessing your profile... -13