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';
|
|
|
|
|
|
|
|
type Props = {
|
|
|
|
uri: string,
|
|
|
|
totalPages: number,
|
|
|
|
fetching: boolean,
|
|
|
|
params: { page: number },
|
|
|
|
claimsInChannel: Array<StreamClaim>,
|
|
|
|
channelIsMine: boolean,
|
|
|
|
fetchClaims: (string, number) => void,
|
|
|
|
};
|
|
|
|
|
|
|
|
function ChannelContent(props: Props) {
|
|
|
|
const { uri, fetching, claimsInChannel, totalPages, channelIsMine, fetchClaims } = props;
|
|
|
|
const hasContent = Boolean(claimsInChannel && claimsInChannel.length);
|
|
|
|
return (
|
|
|
|
<Fragment>
|
|
|
|
{fetching && !hasContent && (
|
|
|
|
<section className="main--empty">
|
|
|
|
<Spinner delayed />
|
|
|
|
</section>
|
|
|
|
)}
|
|
|
|
|
2019-06-11 20:10:58 +02:00
|
|
|
{!fetching && !hasContent && (
|
|
|
|
<div className="card--section">
|
|
|
|
<h2 className="card__content help">{__("This channel hasn't uploaded anything.")}</h2>
|
|
|
|
</div>
|
|
|
|
)}
|
2019-05-07 04:35:04 +02:00
|
|
|
|
|
|
|
{!channelIsMine && <HiddenNsfwClaims className="card__content help" uri={uri} />}
|
|
|
|
|
2019-06-19 07:05:43 +02:00
|
|
|
{hasContent && <ClaimList header={false} uris={claimsInChannel.map(claim => claim.permanent_url)} />}
|
2019-05-07 04:35:04 +02:00
|
|
|
|
|
|
|
<Paginate
|
2019-07-18 02:04:17 +02:00
|
|
|
onPageChange={page => fetchClaims(uri, page)}
|
2019-05-07 04:35:04 +02:00
|
|
|
totalPages={totalPages}
|
|
|
|
loading={fetching && !hasContent}
|
|
|
|
/>
|
|
|
|
</Fragment>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
export default withRouter(ChannelContent);
|