From 5876b9e9ef3b71eb85772afebffb9561ce33a325 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Rodriguez=20Ve=CC=81lez?= Date: Sun, 6 Jan 2019 14:34:01 -0500 Subject: [PATCH] FIX: Added withFormatting option --- BlueComponents.js | 3 ++- ios/BlueWallet/Info.plist | 2 +- loc/index.js | 8 ++++---- screen/send/details.js | 2 +- screen/wallets/transactions.js | 6 +++--- 5 files changed, 11 insertions(+), 10 deletions(-) diff --git a/BlueComponents.js b/BlueComponents.js index 3badbbebe..c1d3da6e4 100644 --- a/BlueComponents.js +++ b/BlueComponents.js @@ -1168,8 +1168,9 @@ export class BlueBitcoinAmount extends Component { {loc.formatBalance( - this.props.unit === BitcoinUnit.BTC ? amount || 0 : loc.formatBalanceWithoutSuffix(amount || 0, BitcoinUnit.BTC), + this.props.unit === BitcoinUnit.BTC ? amount || 0 : loc.formatBalanceWithoutSuffix(amount || 0, BitcoinUnit.BTC, false), BitcoinUnit.LOCAL_CURRENCY, + false, )} diff --git a/ios/BlueWallet/Info.plist b/ios/BlueWallet/Info.plist index 53f7b135e..79f32994d 100644 --- a/ios/BlueWallet/Info.plist +++ b/ios/BlueWallet/Info.plist @@ -33,7 +33,7 @@ CFBundleVersion - 216 + 217 ITSAppUsesNonExemptEncryption LSRequiresIPhoneOS diff --git a/loc/index.js b/loc/index.js index 2c9b9038d..fb16ecdad 100644 --- a/loc/index.js +++ b/loc/index.js @@ -100,7 +100,7 @@ function removeTrailingZeros(value) { * @param toUnit {String} Value from models/bitcoinUnits.js * @returns {string} */ -strings.formatBalance = (balance, toUnit) => { +strings.formatBalance = (balance, toUnit, withFormatting = false) => { if (toUnit === undefined) { return balance + ' ' + BitcoinUnit.BTC; } @@ -108,7 +108,7 @@ strings.formatBalance = (balance, toUnit) => { return balance + ' ' + BitcoinUnit.BTC; } else if (toUnit === BitcoinUnit.SATS) { const value = new BigNumber(balance).multipliedBy(100000000); - return new Intl.NumberFormat().format(value.toString()) + ' ' + BitcoinUnit.SATS; + return withFormatting ? new Intl.NumberFormat().format(value.toString()) : balance + ' ' + BitcoinUnit.SATS; } else if (toUnit === BitcoinUnit.LOCAL_CURRENCY) { return currency.BTCToLocalCurrency(balance); } @@ -120,7 +120,7 @@ strings.formatBalance = (balance, toUnit) => { * @param toUnit {String} Value from models/bitcoinUnits.js * @returns {string} */ -strings.formatBalanceWithoutSuffix = (balance, toUnit) => { +strings.formatBalanceWithoutSuffix = (balance, toUnit, withFormatting = false) => { if (toUnit === undefined) { return balance; } @@ -129,7 +129,7 @@ strings.formatBalanceWithoutSuffix = (balance, toUnit) => { const value = new BigNumber(balance).dividedBy(100000000).toFixed(8); return removeTrailingZeros(value); } else if (toUnit === BitcoinUnit.SATS) { - return new Intl.NumberFormat().format(balance); + return withFormatting ? new Intl.NumberFormat().format(balance) : balance; } else if (toUnit === BitcoinUnit.LOCAL_CURRENCY) { return currency.satoshiToLocalCurrency(balance); } diff --git a/screen/send/details.js b/screen/send/details.js index 2f2b341c7..777881e7f 100644 --- a/screen/send/details.js +++ b/screen/send/details.js @@ -220,7 +220,7 @@ export default class SendDetails extends Component { .then(response => { this.setState({ address: response.address, - amount: loc.formatBalanceWithoutSuffix(response.amount, BitcoinUnit.BTC), + amount: loc.formatBalanceWithoutSuffix(response.amount, BitcoinUnit.BTC, false), memo: response.memo, fee: response.fee, bip70TransactionExpiration: response.expires, diff --git a/screen/wallets/transactions.js b/screen/wallets/transactions.js index 1892fbd66..5c19f2342 100644 --- a/screen/wallets/transactions.js +++ b/screen/wallets/transactions.js @@ -311,16 +311,16 @@ export default class WalletTransactions extends Component { const invoiceExpiration = item.timestamp + item.expire_time; if (invoiceExpiration > now) { - return loc.formatBalanceWithoutSuffix(item.value && item.value, this.state.wallet.getPreferredBalanceUnit()).toString(); + return loc.formatBalanceWithoutSuffix(item.value && item.value, this.state.wallet.getPreferredBalanceUnit(), true).toString(); } else if (invoiceExpiration < now) { if (item.ispaid) { - return loc.formatBalanceWithoutSuffix(item.value && item.value, this.state.wallet.getPreferredBalanceUnit()).toString(); + return loc.formatBalanceWithoutSuffix(item.value && item.value, this.state.wallet.getPreferredBalanceUnit(), true).toString(); } else { return loc.lnd.expired; } } } else { - return loc.formatBalanceWithoutSuffix(item.value && item.value, this.state.wallet.getPreferredBalanceUnit()).toString(); + return loc.formatBalanceWithoutSuffix(item.value && item.value, this.state.wallet.getPreferredBalanceUnit(), true).toString(); } };