import React from "react"; import ReactMarkdown from "react-markdown"; import lbry from "lbry.js"; import lbryuri from "lbryuri.js"; import Video from "component/video"; import TipLink from "component/tipLink"; 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"; import IconFeatured from "component/iconFeatured"; const FormatItem = props => { const { contentType, metadata: { language, license } } = props; const mediaType = lbry.getMediaType(contentType); return (
{__("Content-Type")}{mediaType}
{__("Language")}{language}
{__("License")}{license}
); }; class FilePage extends React.PureComponent { constructor(props) { super(props); this.state = { showTipBox: false, }; } 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); } } handleTipShow() { this.setState({ showTipBox: true, }); } handleTipHide() { this.setState({ showTipBox: false, }); } render() { const { claim, fileInfo, metadata, contentType, uri, rewardedContentClaimIds, } = this.props; const { showTipBox } = this.state; 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 isRewardContent = rewardedContentClaimIds.includes(claim.claim_id); const mediaType = lbry.getMediaType(contentType); const player = require("render-media"); const obscureNsfw = this.props.obscureNsfw && metadata && metadata.nsfw; const isPlayable = Object.values(player.mime).indexOf(contentType) !== -1 || mediaType === "audio"; return (
{isPlayable ?
{!fileInfo || fileInfo.written_bytes <= 0 ? {isRewardContent && {" "}} : null}

{title}

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