Skip to content

Commit

Permalink
Update limit price on refresh
Browse files Browse the repository at this point in the history
  • Loading branch information
jorbuedo authored and stackchain committed Sep 27, 2023
1 parent f986548 commit 126efb2
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {useSwapTouched} from '../../../../common/SwapFormProvider'
export const TopTokenActions = () => {
const strings = useStrings()
const orderTypeLabels = [strings.marketButton, strings.limitButton]
const {createOrder, orderTypeChanged} = useSwap()
const {createOrder, limitPriceChanged, orderTypeChanged} = useSwap()
const {isBuyTouched, isSellTouched} = useSwapTouched()
const isDisabled = !isBuyTouched || !isSellTouched || createOrder.selectedPool === undefined
const orderTypeIndex = createOrder.type === 'market' ? 0 : 1
Expand All @@ -32,6 +32,11 @@ export const TopTokenActions = () => {
}
}

const refresh = () => {
refetch()
limitPriceChanged(createOrder.marketPrice)
}

return (
<View style={styles.buttonsGroup}>
<ButtonGroup
Expand All @@ -40,7 +45,7 @@ export const TopTokenActions = () => {
selected={orderTypeIndex}
/>

<TouchableOpacity onPress={() => refetch()} disabled={isDisabled}>
<TouchableOpacity onPress={refresh} disabled={isDisabled}>
<Icon.Refresh size={24} color={isDisabled ? COLORS.DISABLED : ''} />
</TouchableOpacity>

Expand Down

0 comments on commit 126efb2

Please sign in to comment.