2017-06-06 23:19:12 +02:00
|
|
|
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";
|
2017-09-17 22:33:52 +02:00
|
|
|
import FileDetails from "component/fileDetails";
|
2017-06-06 23:19:12 +02:00
|
|
|
import UriIndicator from "component/uriIndicator";
|
2017-09-12 06:24:04 +02:00
|
|
|
import Icon from "component/icon";
|
2017-09-17 22:33:52 +02:00
|
|
|
import WalletSendTip from "component/walletSendTip";
|
2017-09-12 06:24:04 +02:00
|
|
|
import DateTime from "component/dateTime";
|
|
|
|
import * as icons from "constants/icons";
|
|
|
|
|
2017-06-08 06:42:19 +02:00
|
|
|
class FilePage extends React.PureComponent {
|
2017-05-13 00:50:51 +02:00
|
|
|
componentDidMount() {
|
2017-06-06 23:19:12 +02:00
|
|
|
this.fetchFileInfo(this.props);
|
|
|
|
this.fetchCostInfo(this.props);
|
2017-05-12 19:14:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
componentWillReceiveProps(nextProps) {
|
2017-06-06 23:19:12 +02:00
|
|
|
this.fetchFileInfo(nextProps);
|
2017-05-12 19:14:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
fetchFileInfo(props) {
|
2017-05-13 00:50:51 +02:00
|
|
|
if (props.fileInfo === undefined) {
|
2017-06-06 23:19:12 +02:00
|
|
|
props.fetchFileInfo(props.uri);
|
2017-05-12 19:14:06 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-05-26 20:17:01 +02:00
|
|
|
fetchCostInfo(props) {
|
|
|
|
if (props.costInfo === undefined) {
|
2017-06-06 23:19:12 +02:00
|
|
|
props.fetchCostInfo(props.uri);
|
2017-05-26 20:17:01 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-05-12 19:14:06 +02:00
|
|
|
render() {
|
2017-07-25 09:07:54 +02:00
|
|
|
const {
|
|
|
|
claim,
|
|
|
|
fileInfo,
|
|
|
|
metadata,
|
|
|
|
contentType,
|
2017-09-17 20:26:55 +02:00
|
|
|
tab,
|
2017-07-25 09:07:54 +02:00
|
|
|
uri,
|
2017-07-30 00:56:08 +02:00
|
|
|
rewardedContentClaimIds,
|
2017-07-25 09:07:54 +02:00
|
|
|
} = this.props;
|
2017-05-01 22:50:07 +02:00
|
|
|
|
2017-09-17 20:26:55 +02:00
|
|
|
const showTipBox = tab == "tip";
|
|
|
|
|
2017-05-15 05:50:59 +02:00
|
|
|
if (!claim || !metadata) {
|
2017-06-06 23:19:12 +02:00
|
|
|
return (
|
|
|
|
<span className="empty">{__("Empty claim or metadata info.")}</span>
|
|
|
|
);
|
2017-05-15 05:50:59 +02:00
|
|
|
}
|
|
|
|
|
2017-06-06 23:19:12 +02:00
|
|
|
const title = metadata.title;
|
2017-07-30 00:56:08 +02:00
|
|
|
const isRewardContent = rewardedContentClaimIds.includes(claim.claim_id);
|
2017-06-06 23:19:12 +02:00
|
|
|
const mediaType = lbry.getMediaType(contentType);
|
|
|
|
const player = require("render-media");
|
2017-06-26 16:00:24 +02:00
|
|
|
const obscureNsfw = this.props.obscureNsfw && metadata && metadata.nsfw;
|
2017-06-06 23:19:12 +02:00
|
|
|
const isPlayable =
|
|
|
|
Object.values(player.mime).indexOf(contentType) !== -1 ||
|
|
|
|
mediaType === "audio";
|
2017-05-01 22:50:07 +02:00
|
|
|
|
2017-05-12 19:14:06 +02:00
|
|
|
return (
|
2017-09-17 22:33:52 +02:00
|
|
|
<div>
|
2017-05-12 19:14:06 +02:00
|
|
|
<section className="show-page-media">
|
2017-06-06 23:19:12 +02:00
|
|
|
{isPlayable
|
|
|
|
? <Video className="video-embedded" uri={uri} />
|
|
|
|
: metadata && metadata.thumbnail
|
|
|
|
? <Thumbnail src={metadata.thumbnail} />
|
|
|
|
: <Thumbnail />}
|
2017-05-12 19:14:06 +02:00
|
|
|
</section>
|
2017-06-26 16:00:24 +02:00
|
|
|
<section className={"card " + (obscureNsfw ? "card--obscured " : "")}>
|
2017-05-12 19:14:06 +02:00
|
|
|
<div className="card__inner">
|
2017-09-17 22:33:52 +02:00
|
|
|
{(!tab || tab === "details") &&
|
|
|
|
<div>
|
|
|
|
{" "} {" "}
|
|
|
|
<div className="card__title-identity">
|
|
|
|
{!fileInfo || fileInfo.written_bytes <= 0
|
|
|
|
? <span style={{ float: "right" }}>
|
|
|
|
<FilePrice uri={lbryuri.normalize(uri)} />
|
2017-09-23 06:22:55 +02:00
|
|
|
{isRewardContent &&
|
|
|
|
<span>{" "}<Icon icon={icons.FEATURED} /></span>}
|
2017-09-17 22:33:52 +02:00
|
|
|
</span>
|
|
|
|
: null}
|
|
|
|
<h1>{title}</h1>
|
|
|
|
<div className="card__subtitle">
|
|
|
|
<UriIndicator uri={uri} link={true} />
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<FileDetails uri={uri} />
|
2017-09-04 19:35:41 +02:00
|
|
|
</div>}
|
2017-09-17 22:33:52 +02:00
|
|
|
{tab === "tip" &&
|
|
|
|
<WalletSendTip claim_id={claim.claim_id} uri={uri} />}
|
2017-05-01 22:50:07 +02:00
|
|
|
</div>
|
2017-05-12 19:14:06 +02:00
|
|
|
</section>
|
2017-09-17 22:33:52 +02:00
|
|
|
</div>
|
2017-06-06 23:19:12 +02:00
|
|
|
);
|
2017-05-12 19:14:06 +02:00
|
|
|
}
|
2017-05-05 07:10:37 +02:00
|
|
|
}
|
2017-05-01 21:59:40 +02:00
|
|
|
|
2017-05-26 02:16:25 +02:00
|
|
|
export default FilePage;
|