lbry-desktop/ui/component/channelContent/view.jsx

86 lines
2.5 KiB
React
Raw Normal View History

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';
import Button from 'component/button';
2019-05-07 04:35:04 +02:00
type Props = {
uri: string,
totalPages: number,
fetching: boolean,
params: { page: number },
pageOfClaimsInChannel: Array<StreamClaim>,
channelIsBlocked: boolean,
2019-05-07 04:35:04 +02:00
channelIsMine: boolean,
fetchClaims: (string, number) => void,
channelIsBlackListed: boolean,
2019-05-07 04:35:04 +02:00
};
function ChannelContent(props: Props) {
const {
uri,
fetching,
pageOfClaimsInChannel,
totalPages,
channelIsMine,
channelIsBlocked,
fetchClaims,
channelIsBlackListed,
} = props;
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>
)}
{!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
{!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>
)}
{!fetching && channelIsBlocked && (
<div className="card--section">
2019-08-02 17:11:31 +02:00
<h2 className="help">{__('You have blocked this channel content.')}</h2>
</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
{hasContent && !channelIsBlocked && !channelIsBlackListed && (
<ClaimList header={false} uris={pageOfClaimsInChannel.map(claim => claim && claim.canonical_url)} />
)}
2019-10-27 15:41:43 +01:00
{!channelIsBlocked && !channelIsBlackListed && (
<Paginate
key={uri}
onPageChange={page => fetchClaims(uri, page)}
totalPages={totalPages}
loading={fetching && !hasContent}
/>
)}
2019-05-07 04:35:04 +02:00
</Fragment>
);
}
export default withRouter(ChannelContent);