Hide token logos from holdings if unavailable (#11912)

This commit is contained in:
Justin Starry 2020-08-30 22:27:05 +08:00 committed by GitHub
parent 8932e4821d
commit 729c4a9399
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 5 deletions

View File

@ -92,7 +92,8 @@ function HoldingsDetailTable({ tokens }: { tokens: TokenInfoWithPubkey[] }) {
const detailsList: React.ReactNode[] = [];
const { cluster } = useCluster();
const showLogos = tokens.some(
(t) => TokenRegistry.get(t.info.mint.toBase58(), cluster) !== undefined
(t) =>
TokenRegistry.get(t.info.mint.toBase58(), cluster)?.icon !== undefined
);
tokens.forEach((tokenAccount) => {
const address = tokenAccount.pubkey.toBase58();
@ -102,7 +103,7 @@ function HoldingsDetailTable({ tokens }: { tokens: TokenInfoWithPubkey[] }) {
<tr key={address}>
{showLogos && (
<td className="w-1 p-0 text-center">
{tokenDetails && (
{tokenDetails?.icon && (
<img
src={tokenDetails.icon}
alt="token icon"
@ -160,8 +161,9 @@ function HoldingsSummaryTable({ tokens }: { tokens: TokenInfoWithPubkey[] }) {
}
const detailsList: React.ReactNode[] = [];
const showLogos = tokens.some((t) =>
TokenRegistry.get(t.info.mint.toBase58(), cluster)
const showLogos = tokens.some(
(t) =>
TokenRegistry.get(t.info.mint.toBase58(), cluster)?.icon !== undefined
);
mappedTokens.forEach((totalByMint, mintAddress) => {
const tokenDetails = TokenRegistry.get(mintAddress, cluster);
@ -169,7 +171,7 @@ function HoldingsSummaryTable({ tokens }: { tokens: TokenInfoWithPubkey[] }) {
<tr key={mintAddress}>
{showLogos && (
<td className="w-1 p-0 text-center">
{tokenDetails && (
{tokenDetails?.icon && (
<img
src={tokenDetails.icon}
alt="token icon"