Skip to content

Commit

Permalink
Fix AmountInput and update SwapDetails view
Browse files Browse the repository at this point in the history
  • Loading branch information
shubhamkmr04 committed Dec 9, 2024
1 parent 3063d93 commit df172ee
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 12 deletions.
8 changes: 7 additions & 1 deletion components/AmountInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,13 @@ export default class AmountInput extends React.Component<
<TextInput
keyboardType="numeric"
placeholder={'0'}
value={amount || sats ? getAmount(sats) : undefined}
value={
amount !== undefined
? amount
: sats
? getAmount(sats)
: undefined
}
onChangeText={(text: string) => {
// remove spaces and non-numeric chars
const formatted = text.replace(/[^\d.,-]/g, '');
Expand Down
18 changes: 9 additions & 9 deletions views/SwapDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import { localeString } from '../utils/LocaleUtils';
import { themeColor } from '../utils/ThemeUtils';

import SwapStore from '../stores/SwapStore';
import TransactionsStore from '../stores/TransactionsStore';

import QR from '../assets/images/SVG/QR.svg';

Expand All @@ -34,7 +33,6 @@ interface SwapDetailsProps {
'SwapDetails',
{ swapData: any; keys: any; endpoint: any; invoice: any }
>;
TransactionsStore?: TransactionsStore;
SwapStore?: SwapStore;
}

Expand All @@ -44,13 +42,13 @@ interface SwapDetailsState {
loading: boolean;
}

@inject('TransactionsStore', 'SwapStore')
@inject('SwapStore')
@observer
export default class SwapDetails extends React.Component<
SwapDetailsProps,
SwapDetailsState
> {
pollingTimer: NodeJS.Timeout | null = null;
pollingTimer: any = null;

constructor(props: SwapDetailsProps) {
super(props);
Expand Down Expand Up @@ -184,7 +182,8 @@ export default class SwapDetails extends React.Component<
);
} else if (
data.status === 'transaction.claimed' ||
data.status === 'invoice.failedToPay'
data.status === 'invoice.failedToPay' ||
data.status === 'swap.expired'
) {
this.stopPolling(); // Stop polling
} else {
Expand Down Expand Up @@ -348,7 +347,7 @@ export default class SwapDetails extends React.Component<
};

render() {
const { navigation, TransactionsStore, SwapStore } = this.props;
const { navigation, SwapStore } = this.props;

const { updates, error } = this.state;
const swapData = this.props.route.params?.swapData ?? '';
Expand Down Expand Up @@ -462,9 +461,10 @@ export default class SwapDetails extends React.Component<
paddingVertical: 10
}}
onPress={() => {
console.log(swapData?.bip21);
TransactionsStore?.sendCoins(swapData?.bip21);
navigation.navigate('SendingOnChain');
navigation.navigate('Send', {
destination: swapData?.bip21,
transactionType: 'On-chain'
});
}}
secondary
/>
Expand Down
4 changes: 2 additions & 2 deletions views/Swaps.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ export default class SwapPane extends React.PureComponent<
invoice
});
});
} catch (error) {
} catch (error: any) {

Check warning on line 175 in views/Swaps.tsx

View workflow job for this annotation

GitHub Actions / lint

Value of 'error' may be overwritten in IE 8 and earlier
// Handle errors during API call
this.setState({
apiError: error.message || 'An unknown error occurred'
Expand Down Expand Up @@ -204,7 +204,7 @@ export default class SwapPane extends React.PureComponent<
// Save the updated swaps array back to Encrypted Storage
await EncryptedStorage.setItem('swaps', JSON.stringify(swaps));
console.log('Swap saved successfully to Encrypted Storage.');
} catch (error) {
} catch (error: any) {

Check warning on line 207 in views/Swaps.tsx

View workflow job for this annotation

GitHub Actions / lint

Value of 'error' may be overwritten in IE 8 and earlier
console.error('Error saving swap to storage:', error);
throw error;
}
Expand Down

0 comments on commit df172ee

Please sign in to comment.