diff --git a/ui/component/collectionPreviewTile/view.jsx b/ui/component/collectionPreviewTile/view.jsx index 1038b54cb..979175851 100644 --- a/ui/component/collectionPreviewTile/view.jsx +++ b/ui/component/collectionPreviewTile/view.jsx @@ -3,13 +3,13 @@ import React from 'react'; import classnames from 'classnames'; import { NavLink, useHistory } from 'react-router-dom'; import ClaimPreviewTile from 'component/claimPreviewTile'; -import CollectionPreviewOverlay from 'component/collectionPreviewOverlay'; import TruncatedText from 'component/common/truncated-text'; import CollectionCount from './collectionCount'; import CollectionPrivate from './collectionPrivate'; import CollectionMenuList from 'component/collectionMenuList'; import { formatLbryUrlForWeb } from 'util/url'; import { COLLECTIONS_CONSTS } from 'lbry-redux'; +import FileThumbnail from 'component/fileThumbnail'; type Props = { uri: string, @@ -141,16 +141,13 @@ function CollectionPreviewTile(props: Props) { return (
  • -
    + -
    - -
    -
    +

    diff --git a/ui/component/fileThumbnail/thumb.jsx b/ui/component/fileThumbnail/thumb.jsx new file mode 100644 index 000000000..a531ecd27 --- /dev/null +++ b/ui/component/fileThumbnail/thumb.jsx @@ -0,0 +1,24 @@ +// @flow +import React from 'react'; +import classnames from 'classnames'; +import type { Node } from 'react'; +import useLazyLoading from 'effects/use-lazy-loading'; + +type Props = { + thumb: string, + children?: Node, +}; + +const Thumb = (props: Props) => { + const { thumb, children } = props; + const thumbnailRef = React.useRef(null); + useLazyLoading(thumbnailRef); + + return ( +
    + {children} +
    + ); +}; + +export default Thumb; diff --git a/ui/component/fileThumbnail/view.jsx b/ui/component/fileThumbnail/view.jsx index 3cad42f9c..b9216e973 100644 --- a/ui/component/fileThumbnail/view.jsx +++ b/ui/component/fileThumbnail/view.jsx @@ -5,7 +5,7 @@ import React from 'react'; import FreezeframeWrapper from './FreezeframeWrapper'; import Placeholder from './placeholder.png'; import classnames from 'classnames'; -import useLazyLoading from 'effects/use-lazy-loading'; +import Thumb from './thumb'; type Props = { uri: string, @@ -24,7 +24,6 @@ function FileThumbnail(props: Props) { uri && claim && claim.value && claim.value.thumbnail ? claim.value.thumbnail.url : undefined; const thumbnail = passedThumbnail || thumbnailFromClaim; const hasResolvedClaim = claim !== undefined; - const thumbnailRef = React.useRef(null); React.useEffect(() => { if (!hasResolvedClaim && uri) { @@ -32,8 +31,6 @@ function FileThumbnail(props: Props) { } }, [hasResolvedClaim, uri, doResolveUri]); - useLazyLoading(thumbnailRef); - if (!allowGifs && thumbnail && thumbnail.endsWith('gif')) { return ( @@ -52,23 +49,11 @@ function FileThumbnail(props: Props) { const thumnailUrl = url ? url.replace(/'/g, "\\'") : ''; - if (!hasResolvedClaim) { - return ( -
    - {children} -
    - ); + if (hasResolvedClaim || thumnailUrl) { + return {children}; } return (