FIX: Added withFormatting option

This commit is contained in:
Marcos Rodriguez Vélez 2019-01-06 14:34:01 -05:00
parent 00845ef838
commit 5876b9e9ef
5 changed files with 11 additions and 10 deletions

View file

@ -1168,8 +1168,9 @@ export class BlueBitcoinAmount extends Component {
<View style={{ alignItems: 'center', marginBottom: 22, marginTop: 4 }}>
<Text style={{ fontSize: 18, color: '#d4d4d4', fontWeight: '600' }}>
{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,
)}
</Text>
</View>

View file

@ -33,7 +33,7 @@
</dict>
</array>
<key>CFBundleVersion</key>
<string>216</string>
<string>217</string>
<key>ITSAppUsesNonExemptEncryption</key>
<false/>
<key>LSRequiresIPhoneOS</key>

View file

@ -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);
}

View file

@ -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,

View file

@ -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();
}
};