From 9c4326186cbd2370111308664b2a80de9d71effd Mon Sep 17 00:00:00 2001 From: marcosrdz Date: Wed, 11 Nov 2020 20:32:43 -0500 Subject: [PATCH 1/4] FIX: Set '0.' on BTC Amount --- BlueComponents.js | 9 ++------- screen/wallets/viewEditMultisigCosigners.js | 4 +--- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/BlueComponents.js b/BlueComponents.js index 4226ca1e9..8563ff4ae 100644 --- a/BlueComponents.js +++ b/BlueComponents.js @@ -2348,10 +2348,6 @@ export class BlueBitcoinAmount extends Component { if (text.startsWith('.')) { text = '0.'; } - text = text.replace(/(0{1,}.)\./g, '$1'); - if (this.state.unit !== BitcoinUnit.BTC) { - text = text.replace(/[^0-9.]/g, ''); - } } else if (this.state.unit === BitcoinUnit.LOCAL_CURRENCY) { text = text.replace(/,/gi, ''); if (text.split('.').length > 2) { @@ -2367,9 +2363,8 @@ export class BlueBitcoinAmount extends Component { } text = rez; } - text = text.replace(/[^\d.,-]/g, ''); // remove all but numberd, dots & commas + text = text.replace(/[^\d.,-]/g, ''); // remove all but numbers, dots & commas } - this.props.onChangeText(text); }} onBlur={() => { @@ -2382,7 +2377,7 @@ export class BlueBitcoinAmount extends Component { maxLength={this.maxLength()} ref={textInput => (this.textInput = textInput)} editable={!this.props.isLoading && !this.props.disabled} - value={parseFloat(amount) > 0 || amount === BitcoinUnit.MAX ? amount : undefined} + value={parseFloat(amount) >= 0 || amount === BitcoinUnit.MAX ? amount : undefined} placeholderTextColor={ this.props.disabled ? BlueCurrentTheme.colors.buttonDisabledTextColor : BlueCurrentTheme.colors.alternativeTextColor2 } diff --git a/screen/wallets/viewEditMultisigCosigners.js b/screen/wallets/viewEditMultisigCosigners.js index 4282b5cdf..3180bf84b 100644 --- a/screen/wallets/viewEditMultisigCosigners.js +++ b/screen/wallets/viewEditMultisigCosigners.js @@ -458,9 +458,7 @@ const ViewEditMultisigCosigners = () => { ); - const footer = ( - - ); + const footer = ; return ( From 10a03b0a2f3d66bb59eaa5fe2b8047451512136d Mon Sep 17 00:00:00 2001 From: marcosrdz Date: Wed, 11 Nov 2020 20:52:31 -0500 Subject: [PATCH 2/4] Update BlueComponents.js --- BlueComponents.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/BlueComponents.js b/BlueComponents.js index 8563ff4ae..64953f7a2 100644 --- a/BlueComponents.js +++ b/BlueComponents.js @@ -2342,12 +2342,10 @@ export class BlueBitcoinAmount extends Component { } else { text = `${parseInt(split[0], 10)}`; } - text = this.state.unit === BitcoinUnit.BTC ? text.replace(/[^0-9.]/g, '') : text.replace(/[^0-9]/g, ''); - text = text.replace(/(\..*)\./g, '$1'); - if (text.startsWith('.')) { text = '0.'; } + text = this.state.unit === BitcoinUnit.BTC ? text.replace(/[^0-9.]/g, '') : text.replace(/[^0-9]/g, ''); } else if (this.state.unit === BitcoinUnit.LOCAL_CURRENCY) { text = text.replace(/,/gi, ''); if (text.split('.').length > 2) { @@ -2364,6 +2362,7 @@ export class BlueBitcoinAmount extends Component { text = rez; } text = text.replace(/[^\d.,-]/g, ''); // remove all but numbers, dots & commas + text = text.replace(/(\..*)\./g, '$1'); } this.props.onChangeText(text); }} From 9e02617d12e693faa91f336ec5108d008d0146c2 Mon Sep 17 00:00:00 2001 From: marcosrdz Date: Thu, 12 Nov 2020 10:36:18 -0500 Subject: [PATCH 3/4] Update BlueComponents.js --- BlueComponents.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/BlueComponents.js b/BlueComponents.js index 64953f7a2..ec4afb409 100644 --- a/BlueComponents.js +++ b/BlueComponents.js @@ -2290,19 +2290,19 @@ export class BlueBitcoinAmount extends Component { secondaryDisplayCurrency = formatBalanceWithoutSuffix(sat, BitcoinUnit.LOCAL_CURRENCY, false); break; case BitcoinUnit.SATS: - secondaryDisplayCurrency = formatBalanceWithoutSuffix(amount.toString(), BitcoinUnit.LOCAL_CURRENCY, false); + secondaryDisplayCurrency = formatBalanceWithoutSuffix((isNaN(amount) ? 0 : amount).toString(), BitcoinUnit.LOCAL_CURRENCY, false); break; case BitcoinUnit.LOCAL_CURRENCY: - secondaryDisplayCurrency = currency.fiatToBTC(parseFloat(amount)); - if (BlueBitcoinAmount.conversionCache[amount + BitcoinUnit.LOCAL_CURRENCY]) { - // cache hit! we reuse old value that supposedly doesnt have rounding errors - const sats = BlueBitcoinAmount.conversionCache[amount + BitcoinUnit.LOCAL_CURRENCY]; + secondaryDisplayCurrency = currency.fiatToBTC(parseFloat(isNaN(amount) ? 0 : amount)); + if (BlueBitcoinAmount.conversionCache[isNaN(amount) ? 0 : amount + BitcoinUnit.LOCAL_CURRENCY]) { + // cache hit! we reuse old value that supposedly doesn't have rounding errors + const sats = BlueBitcoinAmount.conversionCache[isNaN(amount) ? 0 : amount + BitcoinUnit.LOCAL_CURRENCY]; secondaryDisplayCurrency = currency.satoshiToBTC(sats); } break; } - if (amount === BitcoinUnit.MAX) secondaryDisplayCurrency = ''; // we dont want to display NaN + if (amount === BitcoinUnit.MAX) secondaryDisplayCurrency = ''; // we don't want to display NaN return ( this.textInput.focus()}> From e5006de72854e1fed93a6f4d5ea97626476abce9 Mon Sep 17 00:00:00 2001 From: marcosrdz Date: Fri, 13 Nov 2020 23:08:32 -0500 Subject: [PATCH 4/4] Update BlueComponents.js --- BlueComponents.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/BlueComponents.js b/BlueComponents.js index ec4afb409..c68c0c4d8 100644 --- a/BlueComponents.js +++ b/BlueComponents.js @@ -2342,10 +2342,12 @@ export class BlueBitcoinAmount extends Component { } else { text = `${parseInt(split[0], 10)}`; } + + text = this.state.unit === BitcoinUnit.BTC ? text.replace(/[^0-9.]/g, '') : text.replace(/[^0-9]/g, ''); + if (text.startsWith('.')) { text = '0.'; } - text = this.state.unit === BitcoinUnit.BTC ? text.replace(/[^0-9.]/g, '') : text.replace(/[^0-9]/g, ''); } else if (this.state.unit === BitcoinUnit.LOCAL_CURRENCY) { text = text.replace(/,/gi, ''); if (text.split('.').length > 2) {