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 { 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 { publishedDate, contentType, metadata: { language, license } } = props;
const mediaType = lbry.getMediaType(contentType);
return (
{__("Published on")} | {publishedDate} |
{__("Content-Type")} | {mediaType} |
{__("Language")} | {language} |
{__("License")} | {license} |
);
};
class FilePage extends React.PureComponent {
componentDidMount() {
this.fetchFileInfo(this.props);
this.fetchCostInfo(this.props);
this.fetchPublishedDate(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);
}
}
fetchPublishedDate(props) {
const { claim } = props;
if(claim) props.fetchPublishedDate(claim.height)
}
render() {
const {
claim,
fileInfo,
metadata,
contentType,
uri,
rewardedContentClaimIds,
publishedDate,
} = 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 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
?
: metadata && metadata.thumbnail
?
: }
{!fileInfo || fileInfo.written_bytes <= 0
?
{isRewardContent && {" "}}
: null}
{title}
{channelUri
?
this.props.navigate("/show", { uri: channelUri })}
>
{uriIndicator}
: uriIndicator}
{metadata
?
: ""}
);
}
}
export default FilePage;