// @flow import * as ICONS from 'constants/icons'; import React, { useEffect } from 'react'; import { Lbryio } from 'lbryinc'; 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'; import Yrbl from 'component/yrbl'; import LbcSymbol from 'component/common/lbc-symbol'; import * as PAGES from 'constants/pages'; import HelpLink from 'component/common/help-link'; import { useHistory } from 'react-router'; type Props = { channels: Array, channelUrls: Array, fetchChannelListMine: () => void, fetchingChannels: boolean, youtubeChannels: ?Array, doSetActiveChannel: (string) => void, }; export default function ChannelsPage(props: Props) { const { channels, channelUrls, fetchChannelListMine, fetchingChannels, youtubeChannels, doSetActiveChannel } = props; const [rewardData, setRewardData] = React.useState(); const hasYoutubeChannels = youtubeChannels && Boolean(youtubeChannels.length); const hasPendingChannels = channels && channels.some((channel) => channel.confirmations < 0); const { push } = useHistory(); useEffect(() => { fetchChannelListMine(); }, [fetchChannelListMine, hasPendingChannels]); useEffect(() => { Lbryio.call('user_rewards', 'view_rate').then((data) => setRewardData(data)); }, [setRewardData]); return (
{hasYoutubeChannels && } {channelUrls && Boolean(channelUrls.length) && ( {__('Your channels')}} headerAltControls={
); }} renderProperties={(claim) => { const claimsInChannel = claim.meta.claims_in_channel; if (!claim || claimsInChannel === 0) { return null; } const channelRewardData = rewardData && rewardData.rates && rewardData.rates.find((data) => { return data.channel_claim_id === claim.claim_id; }); if (channelRewardData) { return ( {__('Earnings per view')} ); } else { return null; } }} /> )} {!(channelUrls && channelUrls.length) && ( {!fetchingChannels ? (
) : (
)}
)}
); }