From a2d19f313e32f344c1c06afc4780061569bb5cea Mon Sep 17 00:00:00 2001 From: jinchung Date: Thu, 31 Oct 2024 11:57:51 -0400 Subject: [PATCH] Update enabled logic for userAssetsQuery from userAssetsSync --- src/state/sync/UserAssetsSync.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/state/sync/UserAssetsSync.tsx b/src/state/sync/UserAssetsSync.tsx index b5368fa1cb0..697c01f68fd 100644 --- a/src/state/sync/UserAssetsSync.tsx +++ b/src/state/sync/UserAssetsSync.tsx @@ -9,6 +9,8 @@ import { ChainId } from '@/chains/types'; export const UserAssetsSync = function UserAssetsSync() { const { accountAddress, nativeCurrency: currentCurrency } = useAccountSettings(); const isSwapsOpen = useSwapsStore(state => state.isSwapsOpen); + const isUserAssetsStoreMissingData = userAssetsStore.getState().getUserAssets()?.length === 0; + const enabled = (!isSwapsOpen || isUserAssetsStoreMissingData) && !!accountAddress && !!currentCurrency; useUserAssets( { @@ -16,13 +18,13 @@ export const UserAssetsSync = function UserAssetsSync() { currency: currentCurrency, }, { + enabled, select: data => selectorFilterByUserChains({ data, selector: selectUserAssetsList, }), onSuccess: data => { - const isUserAssetsStoreMissingData = userAssetsStore.getState().getUserAssets()?.length === 0; if (!isSwapsOpen || isUserAssetsStoreMissingData) { userAssetsStore.getState().setUserAssets(data as ParsedSearchAsset[]);