import React from 'react'; import lbry from '../lbry.js'; import {Link} from '../component/link.js'; import {FileActions} from '../component/file-actions.js'; import {Thumbnail, TruncatedText, CreditAmount} from '../component/common.js'; let FilePrice = React.createClass({ _isMounted: false, propTypes: { name: React.PropTypes.string }, getInitialState: function() { return { cost: null, costIncludesData: null, } }, componentDidMount: function() { this._isMounted = true; lbry.getCostInfoForName(this.props.name, ({cost, includesData}) => { if (this._isMounted) { this.setState({ cost: cost, costIncludesData: includesData, }); } }); }, componentWillUnmount: function() { this._isMounted = false; }, render: function() { if (this.state.cost === null) { return null; } return ( ); } }); let FileTile = React.createClass({ _isMounted: false, propTypes: { name: React.PropTypes.string, sdHash: React.PropTypes.string, showPrice: React.PropTypes.bool, obscureNsfw: React.PropTypes.bool, hideOnRemove: React.PropTypes.bool }, getInitialState: function() { return { metadata: null, title: null, showNsfwHelp: false, isRemoved: false } }, getDefaultProps: function() { return { hideOnRemove: false, obscureNsfw: !lbry.getClientSetting('showNsfw'), showPrice: true } }, handleMouseOver: function() { if (this.props.obscureNsfw && this.state.metadata && this.state.metadata.nsfw) { this.setState({ showNsfwHelp: true, }); } }, handleMouseOut: function() { if (this.state.showNsfwHelp) { this.setState({ showNsfwHelp: false, }); } }, onRemove: function() { this.setState({ isRemoved: true, }); }, componentDidMount: function() { this._isMounted = true; lbry.resolveName(this.props.name, (metadata) => { if (this._isMounted) { this.setState({ metadata: metadata, title: metadata && metadata.title ? metadata.title : ('lbry://' + this.props.name), }); } }); }, componentWillUnmount: function() { this._isMounted = false; }, render: function() { if (this.state.metadata === null || (this.props.hideOnRemove && this.state.isRemoved)) { return null; } const obscureNsfw = this.props.obscureNsfw && this.state.metadata.nsfw; return ( { this.props.showPrice ? : null} lbry://{this.props.name} {this.state.metadata.title} {this.state.metadata.description} {this.state.showNsfwHelp ? This content is Not Safe For Work. To view adult content, please change your . : null} ); } }); export default FileTile;
{this.state.metadata.description}
This content is Not Safe For Work. To view adult content, please change your .