mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Disable the swaps submit button after the first time it is clicked (#10162)
This commit is contained in:
parent
5b6e524c90
commit
36ef9a228a
@ -83,6 +83,7 @@ export default function ViewQuote() {
|
|||||||
const metaMetricsEvent = useContext(MetaMetricsContext)
|
const metaMetricsEvent = useContext(MetaMetricsContext)
|
||||||
|
|
||||||
const [dispatchedSafeRefetch, setDispatchedSafeRefetch] = useState(false)
|
const [dispatchedSafeRefetch, setDispatchedSafeRefetch] = useState(false)
|
||||||
|
const [submitClicked, setSubmitClicked] = useState(false)
|
||||||
const [selectQuotePopoverShown, setSelectQuotePopoverShown] = useState(false)
|
const [selectQuotePopoverShown, setSelectQuotePopoverShown] = useState(false)
|
||||||
const [warningHidden, setWarningHidden] = useState(false)
|
const [warningHidden, setWarningHidden] = useState(false)
|
||||||
const [originalApproveAmount, setOriginalApproveAmount] = useState(null)
|
const [originalApproveAmount, setOriginalApproveAmount] = useState(null)
|
||||||
@ -570,6 +571,7 @@ export default function ViewQuote() {
|
|||||||
</div>
|
</div>
|
||||||
<SwapsFooter
|
<SwapsFooter
|
||||||
onSubmit={() => {
|
onSubmit={() => {
|
||||||
|
setSubmitClicked(true)
|
||||||
if (!balanceError) {
|
if (!balanceError) {
|
||||||
dispatch(signAndSendTransactions(history, metaMetricsEvent))
|
dispatch(signAndSendTransactions(history, metaMetricsEvent))
|
||||||
} else if (destinationToken.symbol === 'ETH') {
|
} else if (destinationToken.symbol === 'ETH') {
|
||||||
@ -580,7 +582,12 @@ export default function ViewQuote() {
|
|||||||
}}
|
}}
|
||||||
submitText={t('swap')}
|
submitText={t('swap')}
|
||||||
onCancel={async () => await dispatch(navigateBackToBuildQuote(history))}
|
onCancel={async () => await dispatch(navigateBackToBuildQuote(history))}
|
||||||
disabled={balanceError || gasPrice === null || gasPrice === undefined}
|
disabled={
|
||||||
|
submitClicked ||
|
||||||
|
balanceError ||
|
||||||
|
gasPrice === null ||
|
||||||
|
gasPrice === undefined
|
||||||
|
}
|
||||||
className={isShowingWarning && 'view-quote__thin-swaps-footer'}
|
className={isShowingWarning && 'view-quote__thin-swaps-footer'}
|
||||||
showTopBorder
|
showTopBorder
|
||||||
/>
|
/>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user