Skip to content

Commit

Permalink
Fix clearing asset type swap errors
Browse files Browse the repository at this point in the history
Navigation params were getting overrided after maybeClearError set them
  • Loading branch information
Jon-edge committed Sep 23, 2024
1 parent d72d711 commit 298c254
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/components/scenes/SwapCreateScene.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -231,8 +231,6 @@ export const SwapCreateScene = (props: Props) => {
//

const handleFlipWalletPress = useHandler(() => {
maybeClearError('asset')

// Flip params:
navigation.setParams({
fromWalletId: toWalletId,
Expand All @@ -241,6 +239,10 @@ export const SwapCreateScene = (props: Props) => {
toTokenId: fromTokenId,
errorDisplayInfo
})

// Clear error state:
maybeClearError('asset')

// Clear amount input state:
setInputNativeAmountFor(inputNativeAmountFor === 'from' ? 'to' : 'from')

Expand All @@ -259,9 +261,7 @@ export const SwapCreateScene = (props: Props) => {
})

const handleSelectWallet = useHandler(async (walletId: string, tokenId: EdgeTokenId, direction: 'from' | 'to') => {
maybeClearError('asset')

const params = {
navigation.setParams({
...route.params,
...(direction === 'to'
? {
Expand All @@ -272,8 +272,10 @@ export const SwapCreateScene = (props: Props) => {
fromWalletId: walletId,
fromTokenId: tokenId
})
}
navigation.setParams(params)
})

// Clear error state:
maybeClearError('asset')
})

const handleMaxPress = useHandler(() => {
Expand Down

0 comments on commit 298c254

Please sign in to comment.