Currency of available funds changes when the currency of the amount is changed.

This commit is contained in:
Brendon Duncan 2018-07-19 16:24:24 +12:00
commit 0076ff26e6

View file

@ -665,11 +665,31 @@ angular.module('copayApp.controllers').controller('amountController', function($
availableUnits[altUnitIndex].name = newAltCurrency.isoCode;
availableUnits[altUnitIndex].shortName = newAltCurrency.isoCode;
fiatCode = newAltCurrency.isoCode;
updateAvailableFiatIfNeeded();
updateUnitUI();
$scope.close();
});
};
function updateAvailableFiatIfNeeded() {
if ($scope.fromWalletId && availableSatoshis !== null) {
availableFundsInFiat = '';
$scope.availableFunds = availableFundsInCrypto;
var coin = availableUnits[altUnitIndex].isFiat ? availableUnits[unitIndex].id : availableUnits[altUnitIndex].id;
txFormatService.formatAlternativeStr(coin, availableSatoshis, function formatCallback(formatted){
if (formatted) {
availableFundsInFiat = formatted;
if (availableUnits[unitIndex].isFiat) {
$scope.availableFunds = availableFundsInFiat;
} else {
$scope.availableFunds = availableFundsInCrypto;
}
}
});
}
}
function updateAvailableFundsFromWallet(wallet) {
if (wallet.status && wallet.status.isValid) {
availableFundsInCrypto = wallet.status.spendableBalanceStr;