From cc325b2fbe79b0b181cf64d2d7eb04b98b48ebb5 Mon Sep 17 00:00:00 2001 From: eddie <66155195+just-toby@users.noreply.github.com> Date: Tue, 3 Oct 2023 14:33:48 -0700 Subject: [PATCH] fix: no stale trade when otherCurrency is missing (#7403) --- src/hooks/useDebouncedTrade.ts | 1 + src/state/routing/usePreviewTrade.ts | 3 ++- src/state/routing/useRoutingAPITrade.ts | 3 ++- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/hooks/useDebouncedTrade.ts b/src/hooks/useDebouncedTrade.ts index 592990e28b..c37bf8c761 100644 --- a/src/hooks/useDebouncedTrade.ts +++ b/src/hooks/useDebouncedTrade.ts @@ -96,6 +96,7 @@ export function useDebouncedTrade( const skipBothFetches = !autoRouterSupported || !isWindowVisible || isWrap const skipRoutingFetch = skipBothFetches || isDebouncing + const skipPreviewTradeFetch = skipBothFetches || routerPreference === RouterPreference.CLIENT || isPreviewTradeDebouncing diff --git a/src/state/routing/usePreviewTrade.ts b/src/state/routing/usePreviewTrade.ts index fb4ac262d0..cee90197f9 100644 --- a/src/state/routing/usePreviewTrade.ts +++ b/src/state/routing/usePreviewTrade.ts @@ -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, ]) } diff --git a/src/state/routing/useRoutingAPITrade.ts b/src/state/routing/useRoutingAPITrade.ts index 4a79e09c3e..38a29be163 100644 --- a/src/state/routing/useRoutingAPITrade.ts +++ b/src/state/routing/useRoutingAPITrade.ts @@ -104,7 +104,7 @@ export function useRoutingAPITrade( 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( tradeResult?.state, tradeResult?.trade, currentData?.trade, + otherCurrency, ]) }