diff --git a/src/js/controllers/wallet-selector.controller.js b/src/js/controllers/wallet-selector.controller.js index 06e6179da..3fe10b931 100644 --- a/src/js/controllers/wallet-selector.controller.js +++ b/src/js/controllers/wallet-selector.controller.js @@ -1,6 +1,6 @@ 'use strict'; -angular.module('copayApp.controllers').controller('walletSelectorController', function($scope, $state, sendFlowService, configService, gettextCatalog, profileService, txFormatService) { +angular.module('copayApp.controllers').controller('walletSelectorController', function($scope, $state, sendFlowService, configService, gettextCatalog, ongoingProcess, profileService, walletService, txFormatService) { var fromWalletId = ''; var priceDisplayAsFiat = false; @@ -116,15 +116,27 @@ angular.module('copayApp.controllers').controller('walletSelectorController', fu if ($scope.type === 'origin') { $scope.headerTitle = gettextCatalog.getString('Choose a wallet to send from'); - if ($scope.params.amount) { + if ($scope.params.amount || $scope.coin) { walletsAll = profileService.getWallets({coin: $scope.coin}); - - walletsAll.forEach(function forWallet(wallet){ - if (wallet.status.availableBalanceSat > $scope.params.amount) { - walletsSufficientFunds.push(wallet); + ongoingProcess.set('scanning', true); + walletsAll.forEach(function forWallet(wallet) { + if (!wallet.status) { + walletService.getStatus(wallet, {}, function(err, status) { + if (status.availableBalanceSat > ($scope.params.amount ? $scope.params.amount : 0)) { + walletsSufficientFunds.push(wallet); + } else { + $scope.walletsInsufficientFunds.push(wallet); + } + ongoingProcess.set('scanning', false); + }); } else { - $scope.walletsInsufficientFunds.push(wallet); + if (wallet.status.availableBalanceSat > ($scope.params.amount ? $scope.params.amount : 0)) { + walletsSufficientFunds.push(wallet); + } else { + $scope.walletsInsufficientFunds.push(wallet); + } + ongoingProcess.set('scanning', false); } }); @@ -133,22 +145,6 @@ angular.module('copayApp.controllers').controller('walletSelectorController', fu } else { $scope.walletsBch = walletsSufficientFunds; } - - } else if ($scope.coin) { - walletsAll = profileService.getWallets({coin: $scope.coin}); - walletsAll.forEach(function forWallet(wallet){ - if (wallet.status.availableBalanceSat > 0) { - walletsSufficientFunds.push(wallet); - } else { - $scope.walletsInsufficientFunds.push(wallet); - } - }); - - if ($scope.coin === 'btc') { - $scope.walletsBtc = walletsSufficientFunds; - } else { - $scope.walletsBch = walletsSufficientFunds; - } } else { $scope.walletsBch = profileService.getWallets({coin: 'bch', hasFunds: true}); $scope.walletsBtc = profileService.getWallets({coin: 'btc', hasFunds: true}); diff --git a/www/views/walletSelector.html b/www/views/walletSelector.html index 2e4c4bc31..a9712adf9 100644 --- a/www/views/walletSelector.html +++ b/www/views/walletSelector.html @@ -13,7 +13,7 @@
{{requestAmountSecondary}} {{requestCurrencySecondary}}
-
+
{{headerTitle}}