diff --git a/ui/effects/use-get-thumbnail.js b/ui/effects/use-get-thumbnail.js index b9cf22d66..83e59334c 100644 --- a/ui/effects/use-get-thumbnail.js +++ b/ui/effects/use-get-thumbnail.js @@ -1,6 +1,5 @@ // @flow import React from 'react'; -import { generateStreamUrl } from 'util/web'; import { MISSING_THUMB_DEFAULT } from 'config'; export default function useGetThumbnail( @@ -18,16 +17,28 @@ export default function useGetThumbnail( const isFree = claim && claim.value && (!claim.value.fee || Number(claim.value.fee.amount) <= 0); const isCollection = claim && claim.value_type === 'collection'; const thumbnailInClaim = claim && claim.value && claim.value.thumbnail && claim.value.thumbnail.url; + let shouldFetchFileInfo = false; if (thumbnailInClaim) { thumbnailToUse = thumbnailInClaim; } else if (claim && isImage && isFree) { - thumbnailToUse = generateStreamUrl(claim.name, claim.claim_id); + if (streamingUrl) { + thumbnailToUse = streamingUrl; + } else if (!shouldHide) { + shouldFetchFileInfo = true; + } } else if (isCollection) { thumbnailToUse = MISSING_THUMB_DEFAULT; } const [thumbnail, setThumbnail] = React.useState(thumbnailToUse); + + React.useEffect(() => { + if (shouldFetchFileInfo) { + getFile(uri); + } + }, [shouldFetchFileInfo, uri]); + React.useEffect(() => { setThumbnail(thumbnailToUse); }, [thumbnailToUse]);