import React from 'react'; import lbry from 'lbry.js'; import lbryuri from 'lbryuri.js'; import Link from 'component/link'; import {FileActions} from 'component/file-actions.js'; import {Thumbnail, TruncatedText, FilePrice} from 'component/common.js'; import UriIndicator from 'component/channel-indicator.js'; const FileCardStream = React.createClass({ _fileInfoSubscribeId: null, _isMounted: null, _metadata: null, propTypes: { uri: React.PropTypes.string, claimInfo: React.PropTypes.object, outpoint: React.PropTypes.string, hideOnRemove: React.PropTypes.bool, hidePrice: React.PropTypes.bool, obscureNsfw: React.PropTypes.bool }, getInitialState: function() { return { showNsfwHelp: false, isHidden: false, } }, getDefaultProps: function() { return { obscureNsfw: !lbry.getClientSetting('showNsfw'), hidePrice: false, hasSignature: false, } }, componentDidMount: function() { this._isMounted = true; if (this.props.hideOnRemove) { this._fileInfoSubscribeId = lbry.fileInfoSubscribe(this.props.outpoint, this.onFileInfoUpdate); } }, componentWillUnmount: function() { if (this._fileInfoSubscribeId) { lbry.fileInfoUnsubscribe(this.props.outpoint, this._fileInfoSubscribeId); } }, onFileInfoUpdate: function(fileInfo) { if (!fileInfo && this._isMounted && this.props.hideOnRemove) { this.setState({ isHidden: true }); } }, handleMouseOver: function() { this.setState({ hovered: true, }); }, handleMouseOut: function() { this.setState({ hovered: false, }); }, render: function() { if (this.state.isHidden) { return null; } const uri = lbryuri.normalize(this.props.uri); const metadata = this.props.metadata; const isConfirmed = !!metadata; const title = isConfirmed ? metadata.title : uri; const obscureNsfw = this.props.obscureNsfw && isConfirmed && metadata.nsfw; const primaryUrl = 'show=' + uri; return (
this.props.navigate(primaryUrl)} className="card__link">
{title}
{ !this.props.hidePrice ? : null}
{isConfirmed ? metadata.description : This file is pending confirmation.}
{this.state.showNsfwHelp && this.state.hovered ?

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

: null}
); } }); export default FileCardStream