import React from 'react'; import lbry from 'lbry.js'; import lbryuri from 'lbryuri.js'; import Link from 'component/link'; import FileActions from 'component/fileActions'; import {Thumbnail, TruncatedText,} from 'component/common.js'; import FilePrice from 'component/filePrice' import UriIndicator from 'component/uriIndicator'; class FileTile extends React.Component { static SHOW_EMPTY_PUBLISH = "publish" static SHOW_EMPTY_PENDING = "pending" constructor(props) { super(props) this.state = { showNsfwHelp: false, } } componentDidMount() { const { isResolvingUri, resolveUri, claim, uri, } = this.props if(!isResolvingUri && !claim && uri) { resolveUri(uri) } } handleMouseOver() { if (this.props.obscureNsfw && this.props.metadata && this.props.metadata.nsfw) { this.setState({ showNsfwHelp: true, }); } } handleMouseOut() { if (this.state.showNsfwHelp) { this.setState({ showNsfwHelp: false, }); } } render() { const { claim, metadata, isResolvingUri, showEmpty, navigate, hidePrice, } = this.props const uri = lbryuri.normalize(this.props.uri); const isClaimed = !!claim; const isClaimable = lbryuri.isClaimable(uri) const title = isClaimed && metadata && metadata.title ? metadata.title : uri; const obscureNsfw = this.props.obscureNsfw && metadata && metadata.nsfw; let onClick = () => navigate('/show', { uri }) let description = "" if (isClaimed) { description = metadata && metadata.description } else if (isResolvingUri) { description = __("Loading...") } else if (showEmpty === FileTile.SHOW_EMPTY_PUBLISH) { onClick = () => navigate('/publish', { }) description = {__("This location is unused.")} { ' ' } { isClaimable && {__("Put something here!")} } } else if (showEmpty === FileTile.SHOW_EMPTY_PENDING) { description = {__("This file is pending confirmation.")} } return ( { !hidePrice ? : null} {uri} {title} {description} {this.state.showNsfwHelp ? {__("This content is Not Safe For Work. To view adult content, please change your")} navigate('/settings')} label={__("Settings")} />. : null} ); } } export default FileTile
{__("This content is Not Safe For Work. To view adult content, please change your")} navigate('/settings')} label={__("Settings")} />.