import React from 'react'; import lbry from 'lbry.js'; import lbryuri from 'lbryuri.js'; import Video from 'component/video'; import { Thumbnail } 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}
); }; class FilePage extends React.Component { componentDidMount() { this.fetchFileInfo(this.props); this.fetchCostInfo(this.props); } componentWillReceiveProps(nextProps) { this.fetchFileInfo(nextProps); } fetchFileInfo(props) { if (props.fileInfo === undefined) { props.fetchFileInfo(props.uri); } } fetchCostInfo(props) { if (props.costInfo === undefined) { props.fetchCostInfo(props.uri); } } render() { const { claim, fileInfo, metadata, contentType, uri } = this.props; if (!claim || !metadata) { return ( {__('Empty claim or metadata info.')} ); } const { txid, nout, channel_name: channelName, has_signature: hasSignature, signature_is_valid: signatureIsValid, value } = claim; const outpoint = txid + ':' + nout; const title = metadata.title; const channelClaimId = claim.value && claim.value.publisherSignature ? claim.value.publisherSignature.certificateId : null; const channelUri = signatureIsValid && hasSignature && channelName ? lbryuri.build({ channelName, claimId: channelClaimId }, false) : null; const uriIndicator = ; const mediaType = lbry.getMediaType(contentType); const player = require('render-media'); const isPlayable = Object.values(player.mime).indexOf(contentType) !== -1 || mediaType === 'audio'; return (
{isPlayable ?
{!fileInfo || fileInfo.written_bytes <= 0 ? : null}

{title}

{channelUri ? this.props.navigate('/show', { uri: channelUri })} > {uriIndicator} : uriIndicator}
{metadata && metadata.description}
{metadata ?
: ''}
); } } export default FilePage;