Merged 575.
This commit is contained in:
commit
cecad4a072
2 changed files with 172 additions and 157 deletions
|
|
@ -1,7 +1,12 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('walletSelectorController', function($scope, $state, sendFlowService, configService, gettextCatalog, profileService, txFormatService) {
|
||||
(function () {
|
||||
|
||||
angular
|
||||
.module('copayApp.controllers')
|
||||
.controller('walletSelectorController', walletSelectorController);
|
||||
|
||||
function walletSelectorController ($scope, $state, sendFlowService, configService, gettextCatalog, ongoingProcess, profileService, walletService, txFormatService) {
|
||||
var fromWalletId = '';
|
||||
var priceDisplayAsFiat = false;
|
||||
var unitDecimals = 0;
|
||||
|
|
@ -116,32 +121,41 @@ 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) {
|
||||
ongoingProcess.set('scanning', true);
|
||||
walletsAll.forEach(function forWallet(wallet) {
|
||||
if (!wallet.status && !wallet.cachedStatus) {
|
||||
walletService.getStatus(wallet, {}, function(err, status) {
|
||||
wallet.status = status;
|
||||
if (status.availableBalanceSat > ($scope.params.amount ? $scope.params.amount : 0)) {
|
||||
walletsSufficientFunds.push(wallet);
|
||||
} else {
|
||||
$scope.walletsInsufficientFunds.push(wallet);
|
||||
}
|
||||
});
|
||||
|
||||
if ($scope.coin === 'btc') {
|
||||
if ($scope.coin === 'btc') { // As this is a promise
|
||||
$scope.walletsBtc = walletsSufficientFunds;
|
||||
} else {
|
||||
$scope.walletsBch = walletsSufficientFunds;
|
||||
}
|
||||
ongoingProcess.set('scanning', false);
|
||||
});
|
||||
} else {
|
||||
var walletStatus = null;
|
||||
if (wallet.status && wallet.status.isValid) {
|
||||
walletStatus = wallet.status;
|
||||
} else if (wallet.cachedStatus && wallet.status.isValid) {
|
||||
walletStatus = wallet.cachedStatus;
|
||||
}
|
||||
|
||||
} else if ($scope.coin) {
|
||||
walletsAll = profileService.getWallets({coin: $scope.coin});
|
||||
walletsAll.forEach(function forWallet(wallet){
|
||||
if (wallet.status.availableBalanceSat > 0) {
|
||||
if (walletStatus && walletStatus.availableBalanceSat > ($scope.params.amount ? $scope.params.amount : 0)) {
|
||||
walletsSufficientFunds.push(wallet);
|
||||
} else {
|
||||
$scope.walletsInsufficientFunds.push(wallet);
|
||||
}
|
||||
ongoingProcess.set('scanning', false);
|
||||
}
|
||||
});
|
||||
|
||||
if ($scope.coin === 'btc') {
|
||||
|
|
@ -186,4 +200,5 @@ angular.module('copayApp.controllers').controller('walletSelectorController', fu
|
|||
sendFlowService.router.goBack();
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
})();
|
||||
|
|
@ -13,7 +13,7 @@
|
|||
<div class="header--request__amount-alt" ng-show="requestAmountSecondary" translate>{{requestAmountSecondary}} {{requestCurrencySecondary}}</div>
|
||||
</div>
|
||||
<div class="wallets-header">
|
||||
<div class="title">
|
||||
<div class="title" ng-if="walletsBch.length > 0 || walletsBtc.length > 0 || walletsInsufficientFunds.length > 0">
|
||||
{{headerTitle}}
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue