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'; /*should be merged into FileTile once FileTile is refactored to take a single id*/ class FileTileStream extends React.Component { constructor(props) { super(props) this._fileInfoSubscribeId = null this._isMounted = 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() { 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() { if (this.state.isHidden) { return null; } const { metadata, navigate, } = 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; console.debug(this.props) return (
navigate(`show=${uri}`)}> {metadata && metadata.thumbnail ? : }
{ !this.props.hidePrice ? : null}

navigate(`show=${uri}`)} title={title}> {title}

{isConfirmed ? metadata.description : This file is pending confirmation.}

{this.state.showNsfwHelp ?

This content is Not Safe For Work. To view adult content, please change your navigate('settings')} label="Settings" />.

: null}
); } } export default FileTileStream