From a0423878049a085fce0def9d2a43f6e715859ecb Mon Sep 17 00:00:00 2001 From: Jamie Hewitt Date: Wed, 2 Nov 2022 18:40:55 +0300 Subject: [PATCH] Ensuring the market doesn't crash when asset has no services (#1768) * Ensuring the market doesn't crash when asset has no services * Showing no pricing schema available when there are no services for an asset * Shoing No file info available when there are no services available * removing logs * early return if asset has no services --- src/@context/Asset.tsx | 2 +- src/components/@shared/AssetTeaser/index.tsx | 2 +- src/components/@shared/FileIcon/index.tsx | 4 ++-- src/components/Asset/AssetActions/Download.tsx | 4 ++-- src/components/Asset/AssetContent/MetaMain/MetaAsset.tsx | 4 ++-- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/@context/Asset.tsx b/src/@context/Asset.tsx index 12c533aa4..6e46a1e59 100644 --- a/src/@context/Asset.tsx +++ b/src/@context/Asset.tsx @@ -120,7 +120,7 @@ function AssetProvider({ // Helper: Get and set asset access details // ----------------------------------- const fetchAccessDetails = useCallback(async (): Promise => { - if (!asset?.chainId || !asset?.services) return + if (!asset?.chainId || !asset?.services?.length) return const accessDetails = await getAccessDetails( asset.chainId, diff --git a/src/components/@shared/AssetTeaser/index.tsx b/src/components/@shared/AssetTeaser/index.tsx index f0db24936..8465f1783 100644 --- a/src/components/@shared/AssetTeaser/index.tsx +++ b/src/components/@shared/AssetTeaser/index.tsx @@ -58,7 +58,7 @@ export default function AssetTeaser({ {removeMarkdown(description?.substring(0, 300) || '')} - {isUnsupportedPricing ? ( + {isUnsupportedPricing || !asset.services.length ? ( No pricing schema available ) : ( diff --git a/src/components/@shared/FileIcon/index.tsx b/src/components/@shared/FileIcon/index.tsx index 0d0e3fbb0..562f39a43 100644 --- a/src/components/@shared/FileIcon/index.tsx +++ b/src/components/@shared/FileIcon/index.tsx @@ -30,9 +30,9 @@ export default function FileIcon({ return (
    - {!isLoading && file ? ( + {!isLoading ? ( <> - {file.contentType || file.contentLength ? ( + {file?.contentType || file?.contentLength ? ( <>
  • {cleanupContentType(file.contentType)}
  • diff --git a/src/components/Asset/AssetActions/Download.tsx b/src/components/Asset/AssetActions/Download.tsx index 669e2ddb9..c4ea8f7ae 100644 --- a/src/components/Asset/AssetActions/Download.tsx +++ b/src/components/Asset/AssetActions/Download.tsx @@ -173,7 +173,7 @@ export default function Download({ dtSymbol={asset?.datatokens[0]?.symbol} dtBalance={dtBalance} onClick={handleOrderOrDownload} - assetTimeout={secondsToString(asset.services[0].timeout)} + assetTimeout={secondsToString(asset?.services?.[0]?.timeout)} assetType={asset?.metadata?.type} stepText={statusText} isLoading={isLoading} @@ -195,7 +195,7 @@ export default function Download({ /> ) : ( <> - {isUnsupportedPricing ? ( + {isUnsupportedPricing || !asset.services.length ? ( {`Accessed with ${dataTokenSymbol}`}