fix: no stale trade when otherCurrency is missing (#7403)

This commit is contained in:
eddie 2023-10-03 14:33:48 -07:00 committed by GitHub
parent 2694379c97
commit cc325b2fbe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 2 deletions

@ -96,6 +96,7 @@ export function useDebouncedTrade(
const skipBothFetches = !autoRouterSupported || !isWindowVisible || isWrap
const skipRoutingFetch = skipBothFetches || isDebouncing
const skipPreviewTradeFetch =
skipBothFetches || routerPreference === RouterPreference.CLIENT || isPreviewTradeDebouncing

@ -88,7 +88,7 @@ export function usePreviewTrade(
const isFetching = currentData !== tradeResult || !currentData
return useMemo(() => {
if (amountSpecified && queryArgs === skipToken) {
if (amountSpecified && otherCurrency && queryArgs === skipToken) {
return {
state: TradeState.STALE,
trade: tradeResult?.trade,
@ -124,5 +124,6 @@ export function usePreviewTrade(
tradeResult?.state,
tradeResult?.trade,
currentData?.trade,
otherCurrency,
])
}

@ -104,7 +104,7 @@ export function useRoutingAPITrade<TTradeType extends TradeType>(
const isFetching = currentData !== tradeResult || !currentData
return useMemo(() => {
if (amountSpecified && queryArgs === skipToken) {
if (amountSpecified && otherCurrency && queryArgs === skipToken) {
return {
state: TradeState.STALE,
trade: tradeResult?.trade,
@ -140,5 +140,6 @@ export function useRoutingAPITrade<TTradeType extends TradeType>(
tradeResult?.state,
tradeResult?.trade,
currentData?.trade,
otherCurrency,
])
}