Skip to content

Commit

Permalink
fix: price warning always visible
Browse files Browse the repository at this point in the history
  • Loading branch information
meeh0w committed Nov 25, 2024
1 parent a1f670b commit 3aea3cf
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/hooks/useTokenPriceIsMissing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { isBitcoinChainId } from '@src/background/services/network/utils/isBitco
import { useAccountsContext } from '@src/contexts/AccountsProvider';
import { useBalancesContext } from '@src/contexts/BalancesProvider';
import { useNetworkContext } from '@src/contexts/NetworkProvider';
import { useSettingsContext } from '@src/contexts/SettingsProvider';
import { useCallback, useMemo } from 'react';

type UseTokenPriceMissingProps = {
Expand All @@ -16,6 +17,7 @@ export function useTokenPriceMissing(): UseTokenPriceMissingProps {
accounts: { active: activeAccount },
} = useAccountsContext();
const { network: activeNetwork, favoriteNetworks } = useNetworkContext();
const { getTokenVisibility } = useSettingsContext();

const networksMissingPrice: Record<string, boolean> = useMemo(() => {
if (isTokensCached) {
Expand Down Expand Up @@ -52,10 +54,11 @@ export function useTokenPriceMissing(): UseTokenPriceMissingProps {
if (!tokensForActiveAccount) {
return;
}

const isMissingPrices = Object.values(tokensForActiveAccount).some(
(token) => token.priceInCurrency === undefined
);
const isMissingPrices = Object.values(tokensForActiveAccount)
.filter(getTokenVisibility) // Discard hidden tokens
.some(
(token) => token.balance > 0n && token.priceInCurrency === undefined
);

networksIsMissingPrices[networkId] = isMissingPrices;
});
Expand All @@ -66,6 +69,7 @@ export function useTokenPriceMissing(): UseTokenPriceMissingProps {
activeAccount?.addressC,
isTokensCached,
balances.tokens,
getTokenVisibility,
]);

const favoriteNetworksMissingPrice = useMemo(
Expand Down

0 comments on commit 3aea3cf

Please sign in to comment.