// @flow import * as React from 'react'; import * as icons from 'constants/icons'; import type { Claim, Metadata } from 'types/claim'; import { normalizeURI, parseURI } from 'lbry-redux'; import CardMedia from 'component/cardMedia'; import TruncatedText from 'component/common/truncated-text'; import Icon from 'component/common/icon'; import Button from 'component/button'; import classnames from 'classnames'; import FilePrice from 'component/filePrice'; import UriIndicator from 'component/uriIndicator'; type Props = { showUri: boolean, showLocal: boolean, obscureNsfw: boolean, claimIsMine: boolean, isDownloaded: boolean, uri: string, isResolvingUri: boolean, rewardedContentClaimIds: Array, claim: ?Claim, metadata: ?Metadata, resolveUri: string => void, navigate: (string, ?{}) => void, clearPublish: () => void, updatePublishForm: ({}) => void, hideNoResult: boolean, // don't show the tile if there is no claim at this uri displayHiddenMessage?: boolean, displayDescription?: boolean, size: string, }; class FileTile extends React.PureComponent { static defaultProps = { showUri: false, showLocal: false, displayDescription: true, size: 'regular', }; componentDidMount() { const { isResolvingUri, claim, uri, resolveUri } = this.props; if (!isResolvingUri && !claim && uri) resolveUri(uri); } componentWillReceiveProps(nextProps: Props) { const { isResolvingUri, claim, uri, resolveUri } = nextProps; if (!isResolvingUri && claim === undefined && uri) resolveUri(uri); } render() { const { claim, metadata, isResolvingUri, navigate, rewardedContentClaimIds, showUri, obscureNsfw, claimIsMine, showLocal, isDownloaded, clearPublish, updatePublishForm, hideNoResult, displayHiddenMessage, displayDescription, size, } = this.props; const shouldHide = !claimIsMine && obscureNsfw && metadata && metadata.nsfw; if (shouldHide) { return displayHiddenMessage ? ( {__('This file is hidden because it is marked NSFW. Update your')}{' '}