Fix for when an amount changes from having a separate currency value, to the currency being one string with the amount.

This commit is contained in:
Brendon Duncan 2018-08-08 22:00:07 +12:00
commit 69e8c62f5c
3 changed files with 20 additions and 24 deletions

View file

@ -70,7 +70,6 @@ function amountController(configService, $filter, gettextCatalog, $ionicHistory,
initCurrencies(); initCurrencies();
passthroughParams = data.stateParams; passthroughParams = data.stateParams;
console.log('stateParams:', data.stateParams);
vm.fromWalletId = data.stateParams.fromWalletId; vm.fromWalletId = data.stateParams.fromWalletId;
vm.toWalletId = data.stateParams.toWalletId; vm.toWalletId = data.stateParams.toWalletId;
@ -90,7 +89,6 @@ function amountController(configService, $filter, gettextCatalog, $ionicHistory,
vm.toWallet = profileService.getWallet(vm.toWalletId); vm.toWallet = profileService.getWallet(vm.toWalletId);
shapeshiftService.getMarketData(vm.fromWallet.coin, vm.toWallet.coin, function(data) { shapeshiftService.getMarketData(vm.fromWallet.coin, vm.toWallet.coin, function(data) {
console.log(data);
vm.thirdParty.data['minAmount'] = vm.minAmount = parseFloat(data.minimum); vm.thirdParty.data['minAmount'] = vm.minAmount = parseFloat(data.minimum);
vm.thirdParty.data['maxAmount'] = vm.maxAmount = parseFloat(data.maxLimit); vm.thirdParty.data['maxAmount'] = vm.maxAmount = parseFloat(data.maxLimit);
}); });
@ -472,8 +470,6 @@ function amountController(configService, $filter, gettextCatalog, $ionicHistory,
confirmData['thirdParty'] = JSON.stringify(this.thirdParty); confirmData['thirdParty'] = JSON.stringify(this.thirdParty);
} }
console.log('confirmData:', confirmData);
if (!confirmData.fromWalletId) { if (!confirmData.fromWalletId) {
$state.transitionTo('tabs.paymentRequest.confirm', confirmData); $state.transitionTo('tabs.paymentRequest.confirm', confirmData);
} else { } else {
@ -594,20 +590,19 @@ function amountController(configService, $filter, gettextCatalog, $ionicHistory,
if (passthroughParams.fromWalletId && availableSatoshis !== null) { if (passthroughParams.fromWalletId && availableSatoshis !== null) {
availableFundsInFiat = ''; availableFundsInFiat = '';
vm.availableFunds = availableFundsInCrypto; vm.availableFunds = availableFundsInCrypto;
var coin = availableUnits[altUnitIndex].isFiat ? availableUnits[unitIndex].id : availableUnits[altUnitIndex].id;
txFormatService.formatAlternativeStr(coin, availableSatoshis, function formatCallback(formatted){
if (formatted) {
availableFundsInFiat = formatted;
$scope.$apply(function() { if (availableUnits[unitIndex].isFiat) {
if (availableUnits[unitIndex].isFiat) { var coin = availableUnits[altUnitIndex].id;
txFormatService.formatAlternativeStr(coin, availableSatoshis, function formatCallback(formatted){
if (formatted) {
availableFundsInFiat = formatted;
$scope.$apply(function() {
vm.availableFunds = availableFundsInFiat; vm.availableFunds = availableFundsInFiat;
} else { });
vm.availableFunds = availableFundsInCrypto; }
} });
}); }
}
});
} }
} }

View file

@ -63,15 +63,16 @@ angular.module('bitcoincom.directives')
}; };
var formatNumbers = function() { var formatNumbers = function() {
console.log('formatNumbers("' + $scope.value + '", "' + $scope.currency + '")');
if (!$scope.currency && $scope.value) { // If there is no currency available.. // During watch, may be changed from having a separate currency value,
// Try to extract currency from value.. // to both being in value. Don't want to use previous currency value.
var currencySplit = $scope.value.split(" "); // Try to extract currency from value..
if (currencySplit.length === 2) { var currencySplit = $scope.value.split(" ");
$scope.currency = currencySplit[1]; if (currencySplit.length === 2) {
} $scope.currency = currencySplit[1];
} }
var parsed = parseFloat($scope.value); var parsed = parseFloat($scope.value);
var valueFormatted = ''; var valueFormatted = '';
var valueProcessing = ''; var valueProcessing = '';

View file

@ -44,7 +44,7 @@
<div class="extra available-funds" <div class="extra available-funds"
ng-class="{warning: vm.fundsAreInsufficient}" ng-class="{warning: vm.fundsAreInsufficient}"
ng-if="!vm.isRequestingSpecificAmount" translate> ng-if="!vm.isRequestingSpecificAmount" translate>
<span>Available Funds:</span>&ensp;<span><formatted-amount value="{{vm.availableFunds}}"></formatted-amount></span> <span>Available Funds:</span>&ensp;<span><formatted-amount value="{{vm.availableFunds}}" size-equal="true"></formatted-amount></span>
</div> </div>
</div> </div>
</div> </div>