// @flow import React, { useEffect } from 'react'; import classnames from 'classnames'; import { convertToShareLink } from 'lbry-redux'; import { withRouter } from 'react-router-dom'; import { openCopyLinkMenu } from 'util/context-menu'; import { formatLbryUriForWeb } from 'util/uri'; import CardMedia from 'component/cardMedia'; import UriIndicator from 'component/uriIndicator'; import TruncatedText from 'component/common/truncated-text'; import DateTime from 'component/dateTime'; import FileProperties from 'component/fileProperties'; import FileTags from 'component/fileTags'; import SubscribeButton from 'component/subscribeButton'; import ChannelThumbnail from 'component/channelThumbnail'; type Props = { uri: string, claim: ?Claim, obscureNsfw: boolean, claimIsMine: boolean, pending?: boolean, resolveUri: string => void, isResolvingUri: boolean, preventResolve: boolean, history: { push: string => void }, thumbnail: string, title: string, nsfw: boolean, large: boolean, placeholder: boolean, slim: boolean, }; function FileListItem(props: Props) { const { obscureNsfw, claimIsMine, pending, history, uri, isResolvingUri, thumbnail, title, nsfw, resolveUri, claim, large, placeholder, slim, } = props; const haventFetched = claim === undefined; const abandoned = !isResolvingUri && !claim; const shouldHide = abandoned || (!claimIsMine && obscureNsfw && nsfw); const isChannel = claim && claim.value_type === 'channel'; const claimsInChannel = (claim && claim.meta.claims_in_channel) || 0; function handleContextMenu(e) { e.preventDefault(); e.stopPropagation(); if (claim) { openCopyLinkMenu(convertToShareLink(claim.permanent_url), e); } } function onClick(e) { if ((isChannel || title) && !pending) { history.push(formatLbryUriForWeb(uri)); } } useEffect(() => { if (!isResolvingUri && haventFetched && uri) { resolveUri(uri); } }, [isResolvingUri, uri, resolveUri, haventFetched]); if (shouldHide) { return null; } if (placeholder && !claim) { return (
  • ); } return (
  • {isChannel ? : }
    {!slim && (
    {isChannel && } {!isChannel && }
    )}
    {pending &&
    Pending...
    }
    {isChannel ? `${claimsInChannel} ${__('publishes')}` : }
  • ); } export default withRouter(FileListItem);