From 977478587ec48a79b95e77da4ce27d1d299676f5 Mon Sep 17 00:00:00 2001 From: pkxro Date: Wed, 29 May 2024 11:05:52 -0400 Subject: [PATCH] fix: simplify logic --- app/address/[address]/layout.tsx | 27 ++++++++++----------------- 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/app/address/[address]/layout.tsx b/app/address/[address]/layout.tsx index 8edea4fd..96b46e9e 100644 --- a/app/address/[address]/layout.tsx +++ b/app/address/[address]/layout.tsx @@ -266,25 +266,18 @@ function AccountHeader({ address, account, tokenInfo, isTokenInfoLoading }: { ad // Checks the uri, if it's json, return the the json's image tag - try { - if (tokenMetadata.uri.endsWith('.json')) { - fetch(tokenMetadata.uri) - .then(response => response.json()) - .then(metadata => { - if (metadata && metadata.image) { - token.logoURI = metadata.image; - } - }) - .catch(e => { - token.logoURI = tokenMetadata.uri; - }); - } else { - token.logoURI = tokenMetadata.uri; - } - } catch { + if (tokenMetadata.uri.endsWith('.json')) { + fetch(tokenMetadata.uri) + .then(response => response.json()) + .then(metadata => { + token.logoURI = metadata?.image || tokenMetadata.uri; + }) + .catch(() => { + token.logoURI = tokenMetadata.uri; + }); + } else { token.logoURI = tokenMetadata.uri; } - } // Fall back to legacy token list when there is stub metadata (blank uri), updatable by default by the mint authority