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

75 lines
2.4 KiB
React
Raw Normal View History

// @flow
2020-05-21 11:38:28 -04:00
import * as ICONS from 'constants/icons';
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';
2020-09-04 13:14:48 -04:00
import Yrbl from 'component/yrbl';
2020-06-29 15:54:07 -04:00
import * as PAGES from 'constants/pages';
type Props = {
channels: Array<ChannelClaim>,
2020-06-21 12:51:06 -04:00
channelUrls: Array<string>,
fetchChannelListMine: () => void,
fetchingChannels: boolean,
youtubeChannels: ?Array<any>,
};
export default function ChannelsPage(props: Props) {
2020-07-03 10:32:48 -04:00
const { channels, channelUrls, fetchChannelListMine, fetchingChannels, youtubeChannels } = props;
const hasYoutubeChannels = youtubeChannels && Boolean(youtubeChannels.length);
2019-12-09 10:16:49 -05:00
const hasPendingChannels = channels && channels.some(channel => channel.confirmations < 0);
useEffect(() => {
fetchChannelListMine();
2019-10-03 17:40:54 -04:00
}, [fetchChannelListMine, hasPendingChannels]);
return (
<Page>
<div className="card-stack">
{hasYoutubeChannels && <YoutubeTransferStatus hideChannelLink />}
{channelUrls && Boolean(channelUrls.length) && (
<ClaimList
header={<h1 className="section__title">{__('Your channels')}</h1>}
headerAltControls={
<Button
button="secondary"
icon={ICONS.CHANNEL}
label={__('New Channel')}
navigate={`/$/${PAGES.CHANNEL_NEW}`}
/>
}
loading={fetchingChannels}
uris={channelUrls}
/>
)}
</div>
2020-06-21 12:51:06 -04:00
{!(channelUrls && channelUrls.length) && (
<React.Fragment>
{!fetchingChannels ? (
<section className="main--empty">
2020-09-04 13:14:48 -04:00
<Yrbl
title={__('No channels')}
subtitle={__("You haven't created a channel yet. All of your beautiful channels will be listed here!")}
actions={
<div className="section__actions">
<Button button="primary" label={__('New Channel')} navigate={`/$/${PAGES.CHANNEL_NEW}`} />
</div>
}
/>
</section>
) : (
<section className="main--empty">
2020-09-04 13:14:48 -04:00
<Spinner delayed />
</section>
)}
</React.Fragment>
)}
</Page>
);
}