diff --git a/js/controllers/copayers.js b/js/controllers/copayers.js index 10e011c18..a6b38989c 100644 --- a/js/controllers/copayers.js +++ b/js/controllers/copayers.js @@ -1,18 +1,33 @@ 'use strict'; angular.module('copayApp.controllers').controller('CopayersController', - function($scope, $rootScope, $location) { + function($scope, $rootScope, $timeout, go) { + + console.log('[copayers.js.5]'); //TODO $scope.init = function() { + var w = $rootScope.wallet; $rootScope.title = 'Waiting copayers for ' + $rootScope.wallet.getName(); $scope.loading = false; $scope.secret = $rootScope.wallet.getSecret(); + + w.on('publicKeyRingUpdated', $scope.updateList); + w.on('ready', $scope.updateList); + $scope.updateList(); }; - $scope.copayersList = function() { - if ($rootScope.wallet) { - $scope.copayers = $rootScope.wallet.getRegisteredPeerIds(); + $scope.updateList = function() { + var w = $rootScope.wallet; + + $scope.copayers = $rootScope.wallet.getRegisteredPeerIds(); + if (w.isComplete()) { + + w.removeListener('publicKeyRingUpdated', $scope.updateList); + w.removeListener('ready', $scope.updateList); + go.walletHome(); } - return $scope.copayers; - } + $timeout(function() { + $rootScope.$digest(); + }, 1); + }; }); diff --git a/js/controllers/homeWallet.js b/js/controllers/homeWallet.js index f2e1d51bd..ef0658492 100644 --- a/js/controllers/homeWallet.js +++ b/js/controllers/homeWallet.js @@ -1,15 +1,17 @@ 'use strict'; angular.module('copayApp.controllers').controller('HomeWalletController', function($scope, $rootScope, $timeout, $filter, $location, rateService, notification, identityService) { - $scope.init = function() { + $scope.initHome = function() { + var w = $rootScope.wallet; + $rootScope.title = 'Home'; - - $scope.rateService = rateService; $scope.isRateAvailable = false; - var w = $rootScope.wallet; - w.on('txProposalEvent', _updateTxs); + if (w.isShared()) + $scope.copayers = w.getRegisteredPeerIds(); + + w.on('txProposalEvent', _updateTxs); _updateTxs(); rateService.whenAvailable(function() { @@ -18,7 +20,9 @@ angular.module('copayApp.controllers').controller('HomeWalletController', functi }); }; - // This is necesarry, since wallet can change in homeWallet, without running init() again. + // This is necessary, since wallet can change in homeWallet, + // without running init() again. + var removeWatch; removeWatch = $rootScope.$watch('wallet.id', function(newWallet, oldWallet) { if ($rootScope.wallet && $rootScope.wallet.isComplete() && newWallet !== oldWallet) { diff --git a/js/controllers/receive.js b/js/controllers/receive.js index 660a02417..8f5038f83 100644 --- a/js/controllers/receive.js +++ b/js/controllers/receive.js @@ -21,10 +21,8 @@ angular.module('copayApp.controllers').controller('ReceiveController', var lastAddr = _.first(w.getAddressesOrderer()); var balance = w.balanceInfo.balanceByAddr; - if (balance[lastAddr]>0) - $scope.loading = true; - while (balance && balance[lastAddr] > 0) { + $scope.loading = true; $scope.newAddr(); lastAddr = w.generateAddress(null); }; diff --git a/js/models/Identity.js b/js/models/Identity.js index 85c568508..253af0d1c 100644 --- a/js/models/Identity.js +++ b/js/models/Identity.js @@ -509,6 +509,9 @@ Identity.prototype.bindWallet = function(w) { w.on('publicKeyRingUpdated', function() { Identity.storeWalletDebounced(self, w); }); + w.on('ready', function() { + Identity.storeWalletDebounced(self, w); + }); this.emitAndKeepAlive('newWallet', w.getId()); }; diff --git a/js/routes.js b/js/routes.js index d6f3e7245..9708f0276 100644 --- a/js/routes.js +++ b/js/routes.js @@ -22,11 +22,11 @@ angular template: " ", // just fire controller controller: 'EmailConfirmationController', }) - // Payment intents come here. - .when('/uri-payment/:data', { - template: " ", // just fire controller - controller: 'paymentUriController', - }) + // Payment intents come here. + .when('/uri-payment/:data', { + template: " ", // just fire controller + controller: 'paymentUriController', + }) .when('/selectWalletForPayment', { template: " ", // just fire controller controller: 'walletForPaymentController', @@ -127,6 +127,7 @@ angular } $rootScope.$on('$routeChangeStart', function(event, next, current) { + if (!ls || ls.length < 1) { $location.path('unsupported'); } else { @@ -134,7 +135,8 @@ angular $idle.unwatch(); $location.path('/'); } - if ($rootScope.wallet && !$rootScope.wallet.isComplete() && next.walletShouldBeComplete) { + if ($rootScope.wallet && !$rootScope.wallet.isComplete() + && next.walletShouldBeComplete) { $location.path('/copayers'); } } diff --git a/js/services/go.js b/js/services/go.js index 5159c8a90..ffd2b951e 100644 --- a/js/services/go.js +++ b/js/services/go.js @@ -57,24 +57,23 @@ angular.module('copayApp.services').factory('go', function($window, $rootScope, }; root.walletHome = function() { -console.log('[go.js.25:walletHome:]'); //TODO var w = $rootScope.wallet; preconditions.checkState(w); $rootScope.starting = false; + if (!w.isComplete()) { root.path('copayers'); } else { if ($rootScope.pendingPayment) { root.path('selectWalletForPayment'); } else { - -console.log('[go.js.36]'); //TODO root.path('homeWallet'); } } }; root.home = function() { +console.log('[go.js.48:home:]'); //TODO if ($rootScope.iden) root.walletHome(); else @@ -83,6 +82,8 @@ console.log('[go.js.36]'); //TODO root.send = function() { + +console.log('[go.js.58]'); //TODO $location.path('send'); }; diff --git a/test/mocks/FakeBlockchainSocket.js b/test/mocks/FakeBlockchainSocket.js index 941013ae6..f888c8150 100644 --- a/test/mocks/FakeBlockchainSocket.js +++ b/test/mocks/FakeBlockchainSocket.js @@ -26,7 +26,7 @@ var inherits = function(ctor, superCtor) { inherits(FakeSocket, EventEmitter); -FakeSocket.prototype.removeEventListener = function() { +FakeSocket.prototype.removeListener = function() { return; } diff --git a/views/copayers.html b/views/copayers.html index f2477315b..efea1ce53 100644 --- a/views/copayers.html +++ b/views/copayers.html @@ -1,4 +1,4 @@ -
+

@@ -12,6 +12,13 @@

Share this secret with your other copayers +
+ Personal Wallet + + Multisignature wallet [{{$root.wallet.requiredCopayers}} of {{$root.wallet.totalCopayers}} ] + + in TESTNET +

@@ -22,7 +29,7 @@
-
+

diff --git a/views/homeWallet.html b/views/homeWallet.html index 74a12a80f..45e9b65b4 100644 --- a/views/homeWallet.html +++ b/views/homeWallet.html @@ -1,4 +1,4 @@ -

+

Home

@@ -63,7 +63,7 @@

Copayers

-
+
diff --git a/views/includes/copayer.html b/views/includes/copayers.html similarity index 82% rename from views/includes/copayer.html rename to views/includes/copayers.html index be9e159ed..42ec854ce 100644 --- a/views/includes/copayer.html +++ b/views/includes/copayers.html @@ -1,5 +1,5 @@ -
-
+
+
diff --git a/views/includes/head.html b/views/includes/head.html index dce39e37c..b01b875db 100644 --- a/views/includes/head.html +++ b/views/includes/head.html @@ -2,7 +2,7 @@

{{$root.title}} - +