diff --git a/components/AmountInput.tsx b/components/AmountInput.tsx index 79bcafdeb..9f991402c 100644 --- a/components/AmountInput.tsx +++ b/components/AmountInput.tsx @@ -80,9 +80,10 @@ export default class AmountInput extends React.Component< constructor(props: any) { super(props); - const { amount } = props; + const { amount, onAmountChange } = props; let satAmount = '0'; if (amount) satAmount = getSatAmount(amount).toString(); + onAmountChange(amount, satAmount); this.state = { satAmount }; @@ -124,7 +125,9 @@ export default class AmountInput extends React.Component< return ( {title && ( - this.onChangeUnits()}> + !locked && this.onChangeUnits()} + > !locked && this.onChangeUnits()} /> {!hideConversion && ( - this.onChangeUnits()}> + !locked && this.onChangeUnits()} + > {fiat !== 'Disabled' && units !== 'fiat' && ( diff --git a/views/Receive.tsx b/views/Receive.tsx index 4f9815074..dd7b0e788 100644 --- a/views/Receive.tsx +++ b/views/Receive.tsx @@ -122,11 +122,11 @@ export default class Receive extends React.Component< const settings = await getSettings(); this.setState({ - addressType: settings.invoices.addressType || '1', - memo: settings.invoices.memo || '', - expiry: settings.invoices.expiry || '3600', - routeHints: settings.invoices.routeHints || false, - ampInvoice: settings.invoices.ampInvoice || false + addressType: settings?.invoices?.addressType || '1', + memo: settings?.invoices?.memo || '', + expiry: settings?.invoices?.expiry || '3600', + routeHints: settings?.invoices?.routeHints || false, + ampInvoice: settings?.invoices?.ampInvoice || false }); const lnOnly = @@ -165,15 +165,18 @@ export default class Receive extends React.Component< } if (lnurl) { + this.props.UnitsStore.resetUnits(); this.setState({ memo: lnurl.defaultDescription, - value: (lnurl.maxWithdrawable / 1000).toString() + value: (lnurl.maxWithdrawable / 1000).toString(), + satAmount: getSatAmount(lnurl.maxWithdrawable / 1000) }); } if (amount) { this.setState({ - value: amount + value: amount, + satAmount: getSatAmount(amount) }); } @@ -203,13 +206,22 @@ export default class Receive extends React.Component< const { reset } = InvoicesStore; reset(); + const amount: string = navigation.getParam('amount'); const lnurl: LNURLWithdrawParams | undefined = navigation.getParam('lnurlParams'); + if (amount) { + this.setState({ + value: amount, + satAmount: getSatAmount(amount) + }); + } + if (lnurl) { this.setState({ memo: lnurl.defaultDescription, - value: (lnurl.maxWithdrawable / 1000).toString() + value: (lnurl.maxWithdrawable / 1000).toString(), + satAmount: getSatAmount(lnurl.maxWithdrawable / 1000) }); } } diff --git a/views/handleAnythingQRScanner.tsx b/views/handleAnythingQRScanner.tsx index 658087251..9e84654d1 100644 --- a/views/handleAnythingQRScanner.tsx +++ b/views/handleAnythingQRScanner.tsx @@ -41,8 +41,8 @@ export default class handleAnythingQRScanner extends React.Component< this.setState({ loading: false }); - const [route, props] = response; - if (route) { + if (response) { + const [route, props] = response; navigation.navigate(route, props); } else { navigation.goBack();