import React from 'react'; import lbry from '../lbry.js'; import lighthouse from '../lighthouse.js'; import lbryuri from '../lbryuri.js'; import {Video} from '../page/watch.js' import {TruncatedText, Thumbnail, FilePrice, BusyMessage} from '../component/common.js'; import {FileActions} from '../component/file-actions.js'; import {Link} from '../component/link.js'; import UriIndicator from '../component/channel-indicator.js'; var FormatItem = React.createClass({ propTypes: { metadata: React.PropTypes.object, contentType: React.PropTypes.string, uri: React.PropTypes.string, outpoint: React.PropTypes.string, }, render: function() { const {thumbnail, author, title, description, language, license} = this.props.metadata; const mediaType = lbry.getMediaType(this.props.contentType); if (!this.props.contentType && [author, language, license].filter().length === 0) { return null; } return (
Content-Type{this.props.contentType}
Author{author}
Language{language}
License{license}
); } }); let ShowPage = React.createClass({ _uri: null, _isMounted: false, propTypes: { uri: React.PropTypes.string, }, getInitialState: function() { return { outpoint: null, metadata: null, contentType: null, hasSignature: false, signatureIsValid: false, cost: null, costIncludesData: null, uriLookupComplete: null, isDownloaded: null, isFailed: false, }; }, componentWillUnmount: function() { this._isMounted = false; }, componentWillReceiveProps: function(nextProps) { if (nextProps.uri != this.props.uri) { this.loadUri(nextProps.uri); } }, componentWillMount: function() { this.loadUri(this.props.uri); }, loadUri: function(uri) { this._uri = lbryuri.normalize(uri); lbry.resolve({uri: this._uri}).then((resolveData) => { if (resolveData) { let {claim: {txid, nout, has_signature, signature_is_valid, value: {stream: {metadata, source: {contentType}}}}} = resolveData; const outpoint = txid + ':' + nout; lbry.file_list({outpoint}).then((fileInfo) => { this.setState({ isDownloaded: fileInfo.length > 0, }); }); lbry.setTitle(metadata.title ? metadata.title : this._uri) if (this._isMounted) { this.setState({ outpoint: outpoint, metadata: metadata, hasSignature: has_signature, signatureIsValid: signature_is_valid, contentType: contentType, uriLookupComplete: true, }); } lbry.getCostInfo(this._uri).then(({cost, includesData}) => { if (this._isMounted) { this.setState({ cost: cost, costIncludesData: includesData, }); } }); } else { if (this._isMounted) { this.setState(Object.assign({}, this.getInitialState(), { uriLookupComplete: true, isFailed: true })); } } }); }, render: function() { const metadata = this.state.metadata; const title = metadata ? this.state.metadata.title : this._uri; if (this.state.isFailed) { return

{this._uri}

This location is not yet in use. { ' ' } .

} return (
{ this.state.contentType && this.state.contentType.startsWith('video/') ?
{this.state.isDownloaded === false ? : null}

{title}

{ this.state.uriLookupComplete && this.state.outpoint ?
: '' }
{ this.state.uriLookupComplete ?
{metadata.description}
:
}
{ metadata ?
: '' }
); } }); export default ShowPage;