mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Empty balance while switching network (#14354)
This commit is contained in:
parent
88286664b5
commit
f9edbf50ce
@ -7,7 +7,7 @@ import AssetListItem from '../asset-list-item';
|
||||
import { PRIMARY, SECONDARY } from '../../../helpers/constants/common';
|
||||
import { useUserPreferencedCurrency } from '../../../hooks/useUserPreferencedCurrency';
|
||||
import {
|
||||
getCurrentAccountWithSendEtherInfo,
|
||||
getSelectedAccountCachedBalance,
|
||||
getShouldShowFiat,
|
||||
getNativeCurrencyImage,
|
||||
getDetectedTokensInCurrentNetwork,
|
||||
@ -33,9 +33,7 @@ const AssetList = ({ onClickAsset }) => {
|
||||
|
||||
const [showDetectedTokens, setShowDetectedTokens] = useState(false);
|
||||
|
||||
const selectedAccountBalance = useSelector(
|
||||
(state) => getCurrentAccountWithSendEtherInfo(state).balance,
|
||||
);
|
||||
const selectedAccountBalance = useSelector(getSelectedAccountCachedBalance);
|
||||
const nativeCurrency = useSelector(getNativeCurrency);
|
||||
const showFiat = useSelector(getShouldShowFiat);
|
||||
const trackEvent = useContext(MetaMetricsContext);
|
||||
|
@ -16,13 +16,13 @@ import { PRIMARY, SECONDARY } from '../../../helpers/constants/common';
|
||||
import { showModal } from '../../../store/actions';
|
||||
import {
|
||||
isBalanceCached,
|
||||
getSelectedAccount,
|
||||
getShouldShowFiat,
|
||||
getCurrentKeyring,
|
||||
getSwapsDefaultToken,
|
||||
getIsSwapsChain,
|
||||
getIsBuyableChain,
|
||||
getNativeCurrencyImage,
|
||||
getSelectedAccountCachedBalance,
|
||||
} from '../../../selectors/selectors';
|
||||
import SwapIcon from '../../ui/icon/swap-icon.component';
|
||||
import BuyIcon from '../../ui/icon/overview-buy-icon.component';
|
||||
@ -32,6 +32,7 @@ import IconButton from '../../ui/icon-button';
|
||||
import { isHardwareKeyring } from '../../../helpers/utils/hardware';
|
||||
import { MetaMetricsContext } from '../../../contexts/metametrics';
|
||||
import { EVENT } from '../../../../shared/constants/metametrics';
|
||||
import Spinner from '../../ui/spinner';
|
||||
import WalletOverview from './wallet-overview';
|
||||
|
||||
const EthOverview = ({ className }) => {
|
||||
@ -43,8 +44,7 @@ const EthOverview = ({ className }) => {
|
||||
const usingHardwareWallet = isHardwareKeyring(keyring?.type);
|
||||
const balanceIsCached = useSelector(isBalanceCached);
|
||||
const showFiat = useSelector(getShouldShowFiat);
|
||||
const selectedAccount = useSelector(getSelectedAccount);
|
||||
const { balance } = selectedAccount;
|
||||
const balance = useSelector(getSelectedAccountCachedBalance);
|
||||
const isSwapsChain = useSelector(getIsSwapsChain);
|
||||
const isBuyableChain = useSelector(getIsBuyableChain);
|
||||
const primaryTokenImage = useSelector(getNativeCurrencyImage);
|
||||
@ -60,6 +60,7 @@ const EthOverview = ({ className }) => {
|
||||
>
|
||||
<div className="eth-overview__balance">
|
||||
<div className="eth-overview__primary-container">
|
||||
{balance ? (
|
||||
<UserPreferencedCurrencyDisplay
|
||||
className={classnames('eth-overview__primary-balance', {
|
||||
'eth-overview__cached-balance': balanceIsCached,
|
||||
@ -70,11 +71,17 @@ const EthOverview = ({ className }) => {
|
||||
ethNumberOfDecimals={4}
|
||||
hideTitle
|
||||
/>
|
||||
) : (
|
||||
<Spinner
|
||||
color="var(--color-secondary-default)"
|
||||
className="loading-overlay__spinner"
|
||||
/>
|
||||
)}
|
||||
{balanceIsCached ? (
|
||||
<span className="eth-overview__cached-star">*</span>
|
||||
) : null}
|
||||
</div>
|
||||
{showFiat && (
|
||||
{showFiat && balance && (
|
||||
<UserPreferencedCurrencyDisplay
|
||||
className={classnames({
|
||||
'eth-overview__cached-secondary-balance': balanceIsCached,
|
||||
|
Loading…
x
Reference in New Issue
Block a user