From 8836bdf86a01f3c87a071090b85fc2c5f652bed3 Mon Sep 17 00:00:00 2001 From: Manuel Araoz Date: Tue, 6 May 2014 17:36:16 -0300 Subject: [PATCH] optimize address page and refresh UI calls. --- js/controllers/header.js | 2 +- js/models/core/Wallet.js | 4 ++-- js/services/controllerUtils.js | 3 --- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/js/controllers/header.js b/js/controllers/header.js index 93f77bfbe..6f69a5d3a 100644 --- a/js/controllers/header.js +++ b/js/controllers/header.js @@ -44,8 +44,8 @@ angular.module('copay.header').controller('HeaderController', $scope.refresh = function() { var w = $rootScope.wallet; + w.connectToAll(); controllerUtils.updateBalance(function() { - w.connectToAll(); $rootScope.$digest(); }); }; diff --git a/js/models/core/Wallet.js b/js/models/core/Wallet.js index 39a451de7..f7180c3c0 100644 --- a/js/models/core/Wallet.js +++ b/js/models/core/Wallet.js @@ -56,7 +56,6 @@ Wallet.prototype.connectToAll = function() { this.sendWalletReady(this.firstCopayerId); this.firstCopayerId = null; } - this.emit('refresh'); }; Wallet.prototype._handlePublicKeyRing = function(senderId, data, isInbound) { @@ -206,8 +205,9 @@ Wallet.prototype.netStart = function() { } net.start(startOpts, function() { - self.emit('created', net.getPeer()); self.connectToAll(); + self.emit('created', net.getPeer()); + self.emit('refresh'); }); }; diff --git a/js/services/controllerUtils.js b/js/services/controllerUtils.js index edf5152c1..a3fbcc757 100644 --- a/js/services/controllerUtils.js +++ b/js/services/controllerUtils.js @@ -59,14 +59,12 @@ angular.module('copay.controllerUtils') $location.path('addresses'); }); w.on('refresh', function() { - alert('refresh'); root.updateBalance(function() { $rootScope.$digest(); }); $rootScope.$digest(); }); w.on('publicKeyRingUpdated', function() { - alert('pkr updated'); root.updateBalance(function() { $rootScope.$digest(); }); @@ -80,7 +78,6 @@ angular.module('copay.controllerUtils') }; root.updateBalance = function(cb) { - alert('update balance'); root.setSocketHandlers(); $rootScope.balanceByAddr = {}; var w = $rootScope.wallet;