Skip to content

Commit

Permalink
Merge pull request #1427 from kaloudis/zeus-1419
Browse files Browse the repository at this point in the history
ZEUS-1419: LNURL-w fixed value patch
  • Loading branch information
kaloudis authored Apr 13, 2023
2 parents 420b620 + 80b8b56 commit 69b258c
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 14 deletions.
13 changes: 9 additions & 4 deletions components/AmountInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
};
Expand Down Expand Up @@ -124,7 +125,9 @@ export default class AmountInput extends React.Component<
return (
<React.Fragment>
{title && (
<TouchableOpacity onPress={() => this.onChangeUnits()}>
<TouchableOpacity
onPress={() => !locked && this.onChangeUnits()}
>
<Text
style={{
fontFamily: 'Lato-Regular',
Expand Down Expand Up @@ -160,10 +163,12 @@ export default class AmountInput extends React.Component<
units === 'fiat' &&
getSymbol().symbol
}
toggleUnits={this.onChangeUnits}
toggleUnits={() => !locked && this.onChangeUnits()}
/>
{!hideConversion && (
<TouchableOpacity onPress={() => this.onChangeUnits()}>
<TouchableOpacity
onPress={() => !locked && this.onChangeUnits()}
>
<View style={{ marginBottom: 10 }}>
{fiat !== 'Disabled' && units !== 'fiat' && (
<Amount sats={satAmount} fixedUnits="fiat" />
Expand Down
28 changes: 20 additions & 8 deletions views/Receive.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down Expand Up @@ -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)
});
}

Expand Down Expand Up @@ -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)
});
}
}
Expand Down
4 changes: 2 additions & 2 deletions views/handleAnythingQRScanner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 69b258c

Please sign in to comment.