lbry-desktop/ui/page/channels/view.jsx

76 lines
2.3 KiB
React
Raw Normal View History

// @flow
import React, { useEffect } from 'react';
import ClaimList from 'component/claimList';
import Page from 'component/page';
import Button from 'component/button';
import YoutubeTransferStatus from 'component/youtubeTransferStatus';
import Spinner from 'component/spinner';
type Props = {
channels: Array<ChannelClaim>,
fetchChannelListMine: () => void,
fetchingChannels: boolean,
youtubeChannels: ?Array<any>,
};
export default function ChannelsPage(props: Props) {
const { channels, fetchChannelListMine, fetchingChannels, youtubeChannels } = props;
const hasYoutubeChannels = youtubeChannels && Boolean(youtubeChannels.length);
2019-10-03 23:40:54 +02:00
const hasPendingChannels = channels && channels.some(channel => channel.confirmations === -1);
useEffect(() => {
fetchChannelListMine();
2019-10-03 23:40:54 +02:00
let interval;
if (hasPendingChannels) {
interval = setInterval(() => {
fetchChannelListMine();
}, 5000);
}
return () => {
clearInterval(interval);
};
}, [fetchChannelListMine, hasPendingChannels]);
return (
<Page>
2019-10-03 23:40:54 +02:00
{hasYoutubeChannels && <YoutubeTransferStatus hideChannelLink />}
{channels && Boolean(channels.length) && (
<div className="card">
<ClaimList
2019-09-30 21:52:53 +02:00
header={__('Your Channels')}
loading={fetchingChannels}
uris={channels.map(channel => channel.permanent_url)}
/>
</div>
)}
{!(channels && channels.length) && (
<React.Fragment>
{!fetchingChannels ? (
<section className="main--empty">
<div className=" section--small">
<h2 className="section__title--large">{__('No Channels Created Yet')}</h2>
<div className="section__actions">
<Button button="primary" navigate="/$/publish" label={__('Create A Channel')} />
</div>
</div>
</section>
) : (
<section className="main--empty">
<div className=" section--small">
<h2 className="section__title--small">
{__('Checking for channels')}
<Spinner type="small" />
</h2>
</div>
</section>
)}
</React.Fragment>
)}
</Page>
);
}