// @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'; import useGetUserMemberships from 'effects/use-get-user-memberships'; type Props = { channelUrls: Array, fetchChannelListMine: () => void, fetchingChannels: boolean, youtubeChannels: ?Array, doSetActiveChannel: (string) => void, pendingChannels: Array, claimsByUri: { [string]: any }, doFetchUserMemberships: (claimIdCsv: string) => void, }; export default function ChannelsPage(props: Props) { const { channelUrls, fetchChannelListMine, fetchingChannels, youtubeChannels, doSetActiveChannel, pendingChannels, claimsByUri, doFetchUserMemberships, } = props; const [rewardData, setRewardData] = React.useState(); const hasYoutubeChannels = youtubeChannels && Boolean(youtubeChannels.length); const shouldFetchUserMemberships = true; useGetUserMemberships(shouldFetchUserMemberships, channelUrls, claimsByUri, doFetchUserMemberships); const { push } = useHistory(); useEffect(() => { fetchChannelListMine(); }, [fetchChannelListMine]); 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 && !pendingChannels.includes(claim.permanent_url)) { return ( {__('Earnings per view')}{' '} ); } else { return null; } }} /> )} {!(channelUrls && channelUrls.length) && ( {!fetchingChannels ? (
) : (
)}
)}
); }