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 { PRIMARY, SECONDARY } from '../../../helpers/constants/common';
|
||||||
import { useUserPreferencedCurrency } from '../../../hooks/useUserPreferencedCurrency';
|
import { useUserPreferencedCurrency } from '../../../hooks/useUserPreferencedCurrency';
|
||||||
import {
|
import {
|
||||||
getCurrentAccountWithSendEtherInfo,
|
getSelectedAccountCachedBalance,
|
||||||
getShouldShowFiat,
|
getShouldShowFiat,
|
||||||
getNativeCurrencyImage,
|
getNativeCurrencyImage,
|
||||||
getDetectedTokensInCurrentNetwork,
|
getDetectedTokensInCurrentNetwork,
|
||||||
@ -33,9 +33,7 @@ const AssetList = ({ onClickAsset }) => {
|
|||||||
|
|
||||||
const [showDetectedTokens, setShowDetectedTokens] = useState(false);
|
const [showDetectedTokens, setShowDetectedTokens] = useState(false);
|
||||||
|
|
||||||
const selectedAccountBalance = useSelector(
|
const selectedAccountBalance = useSelector(getSelectedAccountCachedBalance);
|
||||||
(state) => getCurrentAccountWithSendEtherInfo(state).balance,
|
|
||||||
);
|
|
||||||
const nativeCurrency = useSelector(getNativeCurrency);
|
const nativeCurrency = useSelector(getNativeCurrency);
|
||||||
const showFiat = useSelector(getShouldShowFiat);
|
const showFiat = useSelector(getShouldShowFiat);
|
||||||
const trackEvent = useContext(MetaMetricsContext);
|
const trackEvent = useContext(MetaMetricsContext);
|
||||||
|
@ -16,13 +16,13 @@ import { PRIMARY, SECONDARY } from '../../../helpers/constants/common';
|
|||||||
import { showModal } from '../../../store/actions';
|
import { showModal } from '../../../store/actions';
|
||||||
import {
|
import {
|
||||||
isBalanceCached,
|
isBalanceCached,
|
||||||
getSelectedAccount,
|
|
||||||
getShouldShowFiat,
|
getShouldShowFiat,
|
||||||
getCurrentKeyring,
|
getCurrentKeyring,
|
||||||
getSwapsDefaultToken,
|
getSwapsDefaultToken,
|
||||||
getIsSwapsChain,
|
getIsSwapsChain,
|
||||||
getIsBuyableChain,
|
getIsBuyableChain,
|
||||||
getNativeCurrencyImage,
|
getNativeCurrencyImage,
|
||||||
|
getSelectedAccountCachedBalance,
|
||||||
} from '../../../selectors/selectors';
|
} from '../../../selectors/selectors';
|
||||||
import SwapIcon from '../../ui/icon/swap-icon.component';
|
import SwapIcon from '../../ui/icon/swap-icon.component';
|
||||||
import BuyIcon from '../../ui/icon/overview-buy-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 { isHardwareKeyring } from '../../../helpers/utils/hardware';
|
||||||
import { MetaMetricsContext } from '../../../contexts/metametrics';
|
import { MetaMetricsContext } from '../../../contexts/metametrics';
|
||||||
import { EVENT } from '../../../../shared/constants/metametrics';
|
import { EVENT } from '../../../../shared/constants/metametrics';
|
||||||
|
import Spinner from '../../ui/spinner';
|
||||||
import WalletOverview from './wallet-overview';
|
import WalletOverview from './wallet-overview';
|
||||||
|
|
||||||
const EthOverview = ({ className }) => {
|
const EthOverview = ({ className }) => {
|
||||||
@ -43,8 +44,7 @@ const EthOverview = ({ className }) => {
|
|||||||
const usingHardwareWallet = isHardwareKeyring(keyring?.type);
|
const usingHardwareWallet = isHardwareKeyring(keyring?.type);
|
||||||
const balanceIsCached = useSelector(isBalanceCached);
|
const balanceIsCached = useSelector(isBalanceCached);
|
||||||
const showFiat = useSelector(getShouldShowFiat);
|
const showFiat = useSelector(getShouldShowFiat);
|
||||||
const selectedAccount = useSelector(getSelectedAccount);
|
const balance = useSelector(getSelectedAccountCachedBalance);
|
||||||
const { balance } = selectedAccount;
|
|
||||||
const isSwapsChain = useSelector(getIsSwapsChain);
|
const isSwapsChain = useSelector(getIsSwapsChain);
|
||||||
const isBuyableChain = useSelector(getIsBuyableChain);
|
const isBuyableChain = useSelector(getIsBuyableChain);
|
||||||
const primaryTokenImage = useSelector(getNativeCurrencyImage);
|
const primaryTokenImage = useSelector(getNativeCurrencyImage);
|
||||||
@ -60,21 +60,28 @@ const EthOverview = ({ className }) => {
|
|||||||
>
|
>
|
||||||
<div className="eth-overview__balance">
|
<div className="eth-overview__balance">
|
||||||
<div className="eth-overview__primary-container">
|
<div className="eth-overview__primary-container">
|
||||||
<UserPreferencedCurrencyDisplay
|
{balance ? (
|
||||||
className={classnames('eth-overview__primary-balance', {
|
<UserPreferencedCurrencyDisplay
|
||||||
'eth-overview__cached-balance': balanceIsCached,
|
className={classnames('eth-overview__primary-balance', {
|
||||||
})}
|
'eth-overview__cached-balance': balanceIsCached,
|
||||||
data-testid="eth-overview__primary-currency"
|
})}
|
||||||
value={balance}
|
data-testid="eth-overview__primary-currency"
|
||||||
type={PRIMARY}
|
value={balance}
|
||||||
ethNumberOfDecimals={4}
|
type={PRIMARY}
|
||||||
hideTitle
|
ethNumberOfDecimals={4}
|
||||||
/>
|
hideTitle
|
||||||
|
/>
|
||||||
|
) : (
|
||||||
|
<Spinner
|
||||||
|
color="var(--color-secondary-default)"
|
||||||
|
className="loading-overlay__spinner"
|
||||||
|
/>
|
||||||
|
)}
|
||||||
{balanceIsCached ? (
|
{balanceIsCached ? (
|
||||||
<span className="eth-overview__cached-star">*</span>
|
<span className="eth-overview__cached-star">*</span>
|
||||||
) : null}
|
) : null}
|
||||||
</div>
|
</div>
|
||||||
{showFiat && (
|
{showFiat && balance && (
|
||||||
<UserPreferencedCurrencyDisplay
|
<UserPreferencedCurrencyDisplay
|
||||||
className={classnames({
|
className={classnames({
|
||||||
'eth-overview__cached-secondary-balance': balanceIsCached,
|
'eth-overview__cached-secondary-balance': balanceIsCached,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user