2018-03-26 23:32:43 +02:00
|
|
|
// @flow
|
2017-12-21 22:08:54 +01:00
|
|
|
import React from 'react';
|
2018-03-26 23:32:43 +02:00
|
|
|
import BusyIndicator from 'component/common/busy-indicator';
|
2017-12-21 22:08:54 +01:00
|
|
|
import ChannelPage from 'page/channel';
|
|
|
|
import FilePage from 'page/file';
|
2018-03-26 23:32:43 +02:00
|
|
|
import Page from 'component/page';
|
2018-04-24 20:17:11 +02:00
|
|
|
import Button from 'component/button';
|
2018-05-07 06:50:55 +02:00
|
|
|
import type { Claim } from 'types/claim';
|
2017-05-05 08:13:06 +02:00
|
|
|
|
2018-03-26 23:32:43 +02:00
|
|
|
type Props = {
|
|
|
|
isResolvingUri: boolean,
|
|
|
|
resolveUri: string => void,
|
|
|
|
uri: string,
|
2018-05-07 06:50:55 +02:00
|
|
|
claim: Claim,
|
2019-02-18 18:33:02 +01:00
|
|
|
totalPages: number,
|
2018-04-24 20:17:11 +02:00
|
|
|
blackListedOutpoints: Array<{
|
|
|
|
txid: string,
|
|
|
|
nout: number,
|
|
|
|
}>,
|
2018-03-26 23:32:43 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
class ShowPage extends React.PureComponent<Props> {
|
|
|
|
componentDidMount() {
|
2017-10-12 16:05:18 +02:00
|
|
|
const { isResolvingUri, resolveUri, uri } = this.props;
|
2017-05-12 01:28:43 +02:00
|
|
|
|
2017-10-12 16:05:18 +02:00
|
|
|
if (!isResolvingUri) resolveUri(uri);
|
2017-05-12 01:28:43 +02:00
|
|
|
}
|
|
|
|
|
2018-03-26 23:32:43 +02:00
|
|
|
componentWillReceiveProps(nextProps: Props) {
|
2019-02-18 18:33:02 +01:00
|
|
|
const { isResolvingUri, resolveUri, claim, uri, totalPages } = nextProps;
|
|
|
|
if (
|
|
|
|
!isResolvingUri &&
|
|
|
|
uri &&
|
2019-02-21 23:45:17 +01:00
|
|
|
(claim === undefined || (claim && claim.name[0] === '@' && totalPages === undefined))
|
2019-02-18 18:33:02 +01:00
|
|
|
) {
|
2017-10-12 16:05:18 +02:00
|
|
|
resolveUri(uri);
|
|
|
|
}
|
2017-05-10 05:06:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
2018-04-24 20:17:11 +02:00
|
|
|
const { claim, isResolvingUri, uri, blackListedOutpoints } = this.props;
|
2017-05-05 08:13:06 +02:00
|
|
|
|
2017-12-21 22:08:54 +01:00
|
|
|
let innerContent = '';
|
2017-05-05 08:13:06 +02:00
|
|
|
|
2019-03-13 06:59:07 +01:00
|
|
|
if (!claim || (claim && !claim.name)) {
|
2019-03-04 17:57:07 +01:00
|
|
|
if (claim && !claim.name) {
|
|
|
|
// While testing the normalization changes, Brannon found that `name` was missing sometimes
|
|
|
|
// This shouldn't happen, so hopefully this helps track it down
|
|
|
|
console.error('No name for associated claim: ', claim.claim_id);
|
|
|
|
}
|
|
|
|
|
2017-06-06 23:19:12 +02:00
|
|
|
innerContent = (
|
2018-10-04 06:39:49 +02:00
|
|
|
<Page notContained>
|
2018-12-19 06:44:53 +01:00
|
|
|
{isResolvingUri && <BusyIndicator message={__('Loading decentralized data...')} />}
|
2019-03-04 17:57:07 +01:00
|
|
|
{!isResolvingUri && (
|
|
|
|
<span className="empty">{__("There's nothing available at this location.")}</span>
|
|
|
|
)}
|
2018-03-26 23:32:43 +02:00
|
|
|
</Page>
|
2017-06-06 23:19:12 +02:00
|
|
|
);
|
2019-03-04 17:57:07 +01:00
|
|
|
} else if (claim.name.length && claim.name[0] === '@') {
|
2017-06-06 23:19:12 +02:00
|
|
|
innerContent = <ChannelPage uri={uri} />;
|
2019-02-15 02:52:10 +01:00
|
|
|
} else if (claim && blackListedOutpoints) {
|
2018-04-24 20:17:11 +02:00
|
|
|
let isClaimBlackListed = false;
|
|
|
|
|
|
|
|
for (let i = 0; i < blackListedOutpoints.length; i += 1) {
|
|
|
|
const outpoint = blackListedOutpoints[i];
|
|
|
|
if (outpoint.txid === claim.txid && outpoint.nout === claim.nout) {
|
|
|
|
isClaimBlackListed = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isClaimBlackListed) {
|
|
|
|
innerContent = (
|
|
|
|
<Page>
|
|
|
|
<section className="card card--section">
|
|
|
|
<div className="card__title">{uri}</div>
|
|
|
|
<div className="card__content">
|
|
|
|
<p>
|
|
|
|
{__(
|
|
|
|
'In response to a complaint we received under the US Digital Millennium Copyright Act, we have blocked access to this content from our applications.'
|
|
|
|
)}
|
|
|
|
</p>
|
|
|
|
</div>
|
|
|
|
<div className="card__actions">
|
2019-03-20 22:43:00 +01:00
|
|
|
<Button button="link" href="https://lbry.com/faq/dmca" label={__('Read More')} />
|
2018-04-24 20:17:11 +02:00
|
|
|
</div>
|
|
|
|
</section>
|
|
|
|
</Page>
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
innerContent = <FilePage uri={uri} />;
|
|
|
|
}
|
2017-05-05 08:13:06 +02:00
|
|
|
}
|
|
|
|
|
2018-03-26 23:32:43 +02:00
|
|
|
return innerContent;
|
2017-05-10 05:06:48 +02:00
|
|
|
}
|
2017-05-05 08:13:06 +02:00
|
|
|
}
|
|
|
|
|
2017-06-06 06:21:55 +02:00
|
|
|
export default ShowPage;
|