Skip to content

Commit

Permalink
Update enabled logic for userAssetsQuery from userAssetsSync
Browse files Browse the repository at this point in the history
  • Loading branch information
jinchung committed Oct 31, 2024
1 parent 601e736 commit a2d19f3
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/state/sync/UserAssetsSync.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,22 @@ 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(
{
address: accountAddress,
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[]);

Expand Down

0 comments on commit a2d19f3

Please sign in to comment.