import React from 'react'; import lbry from 'lbry.js'; import lbryuri from 'lbryuri.js'; import Link from 'component/link'; import {Thumbnail, TruncatedText,} from 'component/common'; import FilePrice from 'component/filePrice' import UriIndicator from 'component/uriIndicator'; class FileCardStream extends React.Component { constructor(props) { super(props) this._fileInfoSubscribeId = null this._isMounted = null this._metadata = null this.state = { showNsfwHelp: false, isHidden: false, } } componentDidMount() { this._isMounted = true; if (this.props.hideOnRemove) { this._fileInfoSubscribeId = lbry.fileInfoSubscribe(this.props.outpoint, this.onFileInfoUpdate); } } componentWillUnmount() { if (this._fileInfoSubscribeId) { lbry.fileInfoUnsubscribe(this.props.outpoint, this._fileInfoSubscribeId); } } onFileInfoUpdate(fileInfo) { if (!fileInfo && this._isMounted && this.props.hideOnRemove) { this.setState({ isHidden: true }); } } handleMouseOver() { this.setState({ hovered: true, }); } handleMouseOut() { this.setState({ hovered: false, }); } render() { if (this.state.isHidden) { return null; } const { metadata, isResolvingUri, navigate, hidePrice, } = this.props const uri = lbryuri.normalize(this.props.uri); const isConfirmed = !!metadata; const title = isConfirmed ? metadata.title : uri; const obscureNsfw = this.props.obscureNsfw && isConfirmed && metadata.nsfw; const primaryUrl = 'show=' + uri; let description = "" if (isConfirmed) { description = metadata.description } else if (isResolvingUri) { description = "Loading..." } else { description = This file is pending confirmation } return (
navigate(primaryUrl)} className="card__link">
{title}
{ !hidePrice ? : null}
{metadata &&
}
{description}
{this.state.showNsfwHelp && this.state.hovered ?

This content is Not Safe For Work. To view adult content, please change your .

: null}
); } } export default FileCardStream