import React from 'react'; import lbry from 'lbry.js'; import lighthouse from 'lighthouse.js'; import lbryuri from 'lbryuri.js'; import Video from 'component/video' import { TruncatedText, Thumbnail, BusyMessage, } from 'component/common'; import FilePrice from 'component/filePrice' import FileActions from 'component/fileActions'; import Link from 'component/link'; import UriIndicator from 'component/uriIndicator'; const FormatItem = (props) => { const { contentType, metadata: { author, language, license, } } = props const mediaType = lbry.getMediaType(contentType); return (
Content-Type{mediaType}
Author{author}
Language{language}
License{license}
) } const FilePage = (props) => { const { claim, navigate, claim: { txid, nout, has_signature: hasSignature, signature_is_valid: signatureIsValid, value, value: { stream, stream: { metadata, source, metadata: { title, } = {}, source: { contentType, } = {}, } = {}, } = {}, }, uri, isDownloaded, fileInfo, costInfo, costInfo: { cost, includesData: costIncludesData, } = {}, } = props const outpoint = txid + ':' + nout; const uriLookupComplete = !!claim && Object.keys(claim).length const channelUriObj = lbryuri.parse(uri) delete channelUriObj.path; delete channelUriObj.contentName; const channelUri = signatureIsValid && hasSignature && channelUriObj.isChannel ? lbryuri.build(channelUriObj, false) : null; const uriIndicator = return (
{ contentType && contentType.startsWith('video/') ?
{isDownloaded === false ? : null}

{title}

{ channelUri ? {uriIndicator} : uriIndicator}
{metadata.description}
{ metadata ?
: '' }
) } let ShowPage = React.createClass({ _uri: null, _isMounted: false, propTypes: { uri: React.PropTypes.string, }, getInitialState: function() { return { outpoint: null, metadata: null, contentType: null, hasSignature: false, claimType: null, signatureIsValid: false, cost: null, costIncludesData: null, uriLookupComplete: null, isFailed: false, }; }, componentWillUnmount: function() { this._isMounted = false; }, componentWillReceiveProps: function(nextProps) { if (nextProps.uri != this.props.uri) { this.setState(this.getInitialState()); this.loadUri(nextProps.uri); } }, componentWillMount: function() { this._isMounted = true; this.loadUri(this.props.uri); }, loadUri: function(uri) { this._uri = lbryuri.normalize(uri); lbry.resolve({uri: this._uri}).then((resolveData) => { const isChannel = resolveData && resolveData.claims_in_channel; if (!this._isMounted) { return; } if (resolveData) { let newState = { uriLookupComplete: true } if (!isChannel) { let {claim: {txid: txid, nout: nout, has_signature: has_signature, signature_is_valid: signature_is_valid, value: {stream: {metadata: metadata, source: {contentType: contentType}}}}} = resolveData; Object.assign(newState, { claimType: "file", metadata: metadata, outpoint: txid + ':' + nout, hasSignature: has_signature, signatureIsValid: signature_is_valid, contentType: contentType }); lbry.setTitle(metadata.title ? metadata.title : this._uri) } else { let {certificate: {txid: txid, nout: nout, has_signature: has_signature}} = resolveData; Object.assign(newState, { claimType: "channel", outpoint: txid + ':' + nout, txid: txid, metadata: { title:resolveData.certificate.name } }); } this.setState(newState); } else { this.setState(Object.assign({}, this.getInitialState(), { uriLookupComplete: true, isFailed: true })); } }); }, render: function() { const metadata = this.state.metadata, title = metadata ? this.state.metadata.title : this._uri; let innerContent = ""; if (!this.state.uriLookupComplete || this.state.isFailed) { innerContent =

{title}

{ this.state.uriLookupComplete ?

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

: }
; } else { let channelUriObj = lbryuri.parse(this._uri) delete channelUriObj.path; delete channelUriObj.contentName; const channelUri = this.state.signatureIsValid && this.state.hasSignature && channelUriObj.isChannel ? lbryuri.build(channelUriObj, false) : null; innerContent = ; } return
{innerContent}
; } }); export default FilePage; // // const ShowPage = (props) => { // const { // claim, // navigate, // claim: { // txid, // nout, // has_signature: hasSignature, // signature_is_valid: signatureIsValid, // value, // value: { // stream, // stream: { // metadata, // source, // metadata: { // title, // } = {}, // source: { // contentType, // } = {}, // } = {}, // } = {}, // }, // uri, // isDownloaded, // fileInfo, // costInfo, // costInfo: { // cost, // includesData: costIncludesData, // } = {}, // } = props // // const outpoint = txid + ':' + nout; // const uriLookupComplete = !!claim && Object.keys(claim).length // // if (props.isFailed) { // return ( //
//
//
//

{uri}

//
//
//

// This location is not yet in use. // { ' ' } // navigate('publish')} label="Put something here" />. //

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

{title}

// { uriLookupComplete ? //
//
// //
//
// //
//
: '' } //
// { uriLookupComplete ? //
//
// {metadata.description} //
//
// :
} //
// { metadata ? //
// //
: '' } //
// //
//
//
// ) // }