2019-05-07 04:35:04 +02:00
|
|
|
// @flow
|
|
|
|
import React, { Fragment } from 'react';
|
2019-06-19 07:05:43 +02:00
|
|
|
import ClaimList from 'component/claimList';
|
2019-05-07 04:35:04 +02:00
|
|
|
import HiddenNsfwClaims from 'component/hiddenNsfwClaims';
|
|
|
|
import { withRouter } from 'react-router-dom';
|
|
|
|
import Paginate from 'component/common/paginate';
|
|
|
|
import Spinner from 'component/spinner';
|
2019-08-29 03:39:21 +02:00
|
|
|
import Button from 'component/button';
|
2019-05-07 04:35:04 +02:00
|
|
|
|
|
|
|
type Props = {
|
|
|
|
uri: string,
|
|
|
|
totalPages: number,
|
|
|
|
fetching: boolean,
|
|
|
|
params: { page: number },
|
2019-11-22 02:37:25 +01:00
|
|
|
pageOfClaimsInChannel: Array<StreamClaim>,
|
2019-07-08 22:54:58 +02:00
|
|
|
channelIsBlocked: boolean,
|
2019-05-07 04:35:04 +02:00
|
|
|
channelIsMine: boolean,
|
|
|
|
fetchClaims: (string, number) => void,
|
2019-08-29 03:39:21 +02:00
|
|
|
channelIsBlackListed: boolean,
|
2019-05-07 04:35:04 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
function ChannelContent(props: Props) {
|
2019-08-29 03:39:21 +02:00
|
|
|
const {
|
|
|
|
uri,
|
|
|
|
fetching,
|
2019-11-22 02:37:25 +01:00
|
|
|
pageOfClaimsInChannel,
|
2019-08-29 03:39:21 +02:00
|
|
|
totalPages,
|
|
|
|
channelIsMine,
|
|
|
|
channelIsBlocked,
|
|
|
|
fetchClaims,
|
|
|
|
channelIsBlackListed,
|
|
|
|
} = props;
|
2019-11-22 02:37:25 +01:00
|
|
|
const hasContent = Boolean(pageOfClaimsInChannel && pageOfClaimsInChannel.length);
|
2019-05-07 04:35:04 +02:00
|
|
|
return (
|
|
|
|
<Fragment>
|
|
|
|
{fetching && !hasContent && (
|
|
|
|
<section className="main--empty">
|
|
|
|
<Spinner delayed />
|
|
|
|
</section>
|
|
|
|
)}
|
|
|
|
|
2019-08-29 03:39:21 +02:00
|
|
|
{!fetching && !hasContent && !channelIsBlocked && !channelIsBlackListed && (
|
2019-06-11 20:10:58 +02:00
|
|
|
<div className="card--section">
|
2019-11-22 22:13:00 +01:00
|
|
|
<h2 className="section__subtitle">{__("This channel hasn't uploaded anything.")}</h2>
|
2019-06-11 20:10:58 +02:00
|
|
|
</div>
|
|
|
|
)}
|
2019-05-07 04:35:04 +02:00
|
|
|
|
2019-08-29 03:39:21 +02:00
|
|
|
{!fetching && channelIsBlackListed && (
|
|
|
|
<section className="card card--section">
|
|
|
|
<p>
|
|
|
|
{__(
|
|
|
|
'In response to a complaint we received under the US Digital Millennium Copyright Act, we have blocked access to this channel from our applications.'
|
|
|
|
)}
|
|
|
|
</p>
|
|
|
|
<div className="card__actions">
|
|
|
|
<Button button="link" href="https://lbry.com/faq/dmca" label={__('Read More')} />
|
|
|
|
</div>
|
|
|
|
</section>
|
|
|
|
)}
|
|
|
|
|
2019-07-08 22:54:58 +02:00
|
|
|
{!fetching && channelIsBlocked && (
|
|
|
|
<div className="card--section">
|
2019-08-02 17:11:31 +02:00
|
|
|
<h2 className="help">{__('You have blocked this channel content.')}</h2>
|
2019-07-08 22:54:58 +02:00
|
|
|
</div>
|
|
|
|
)}
|
2019-05-07 04:35:04 +02:00
|
|
|
|
2019-09-27 20:56:15 +02:00
|
|
|
{!channelIsMine && <HiddenNsfwClaims uri={uri} />}
|
2019-05-07 04:35:04 +02:00
|
|
|
|
2019-08-29 03:39:21 +02:00
|
|
|
{hasContent && !channelIsBlocked && !channelIsBlackListed && (
|
2019-11-22 02:37:25 +01:00
|
|
|
<ClaimList header={false} uris={pageOfClaimsInChannel.map(claim => claim && claim.canonical_url)} />
|
2019-07-08 22:54:58 +02:00
|
|
|
)}
|
2019-10-27 15:41:43 +01:00
|
|
|
|
2019-08-29 03:39:21 +02:00
|
|
|
{!channelIsBlocked && !channelIsBlackListed && (
|
2019-07-08 22:54:58 +02:00
|
|
|
<Paginate
|
2019-11-05 21:16:41 +01:00
|
|
|
key={uri}
|
2019-07-08 22:54:58 +02:00
|
|
|
onPageChange={page => fetchClaims(uri, page)}
|
|
|
|
totalPages={totalPages}
|
|
|
|
loading={fetching && !hasContent}
|
|
|
|
/>
|
|
|
|
)}
|
2019-05-07 04:35:04 +02:00
|
|
|
</Fragment>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
export default withRouter(ChannelContent);
|