Skip to content

Commit

Permalink
fix: NFT value statistics for account totals (#3652)
Browse files Browse the repository at this point in the history
  • Loading branch information
qwang1113 authored Oct 16, 2023
1 parent ccfe635 commit ee255dd
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion packages/kit/src/views/Wallet/AccountInfo/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import type { FC } from 'react';
import { memo, useCallback, useEffect, useMemo, useState } from 'react';

import BigNumber from 'bignumber.js';
import stringify from 'fast-json-stable-stringify';
import { useIntl } from 'react-intl';

Expand Down Expand Up @@ -350,8 +351,24 @@ const SummedValueComp = memo(
s.overview.overviewStats?.[networkId]?.[accountId]?.summary?.totalValue,
);

const nftTotalValue = useAppSelector(
(s) =>
s.overview.overviewStats?.[networkId]?.[accountId]?.nfts?.totalValue,
);

const includeNFTsInTotal = useAppSelector(
(s) => s.settings.includeNFTsInTotal,
);

const isWatching = isWatchingAccount({ accountId });

const summaryTotalValue = useMemo(() => {
if (!totalValue || includeNFTsInTotal) {
return totalValue;
}
return new BigNumber(totalValue).minus(nftTotalValue ?? 0).toFixed();
}, [includeNFTsInTotal, nftTotalValue, totalValue]);

return (
<Box flexDirection="row" alignItems="center" mt={1} w="full">
{typeof totalValue === 'undefined' ? (
Expand All @@ -362,7 +379,7 @@ const SummedValueComp = memo(
<FormatCurrencyNumber
decimals={2}
value={0}
convertValue={totalValue}
convertValue={summaryTotalValue}
/>
</Typography.Display2XLarge>
{isWatching && isBTCNetwork(networkId) ? null : (
Expand Down

0 comments on commit ee255dd

Please sign in to comment.