// @flow import { SIMPLE_SITE } from 'config'; import * as CS from 'constants/claim_search'; import * as ICONS from 'constants/icons'; import React, { Fragment } from 'react'; import HiddenNsfwClaims from 'component/hiddenNsfwClaims'; import { useHistory } from 'react-router-dom'; import Button from 'component/button'; import ClaimListDiscover from 'component/claimListDiscover'; import Ads from 'web/component/ads'; import Icon from 'component/common/icon'; import LivestreamLink from 'component/livestreamLink'; import { Form, FormField } from 'component/common/form'; import ScheduledStreams from 'component/scheduledStreams'; import { SearchResults } from './internal/searchResults'; const TYPES_TO_ALLOW_FILTER = ['stream', 'repost']; type Props = { uri: string, totalPages: number, fetching: boolean, params: { page: number }, pageOfClaimsInChannel: Array, channelIsBlocked: boolean, channelIsMine: boolean, fetchClaims: (string, number) => void, channelIsBlackListed: boolean, defaultPageSize?: number, defaultInfiniteScroll?: Boolean, claim: Claim, isAuthenticated: boolean, showMature: boolean, tileLayout: boolean, viewHiddenChannels: boolean, doResolveUris: (Array, boolean) => void, claimType: string, empty?: string, doFetchChannelLiveStatus: (string) => void, activeLivestreamForChannel: any, activeLivestreamInitialized: boolean, }; function ChannelContent(props: Props) { const { uri, fetching, channelIsMine, channelIsBlocked, channelIsBlackListed, claim, defaultPageSize = CS.PAGE_SIZE, defaultInfiniteScroll = true, showMature, tileLayout, viewHiddenChannels, doResolveUris, claimType, empty, doFetchChannelLiveStatus, activeLivestreamForChannel, activeLivestreamInitialized, } = props; // const claimsInChannel = (claim && claim.meta.claims_in_channel) || 0; const claimsInChannel = 9999; const [searchQuery, setSearchQuery] = React.useState(''); const [isSearching, setIsSearching] = React.useState(false); const { location: { pathname, search }, } = useHistory(); const url = `${pathname}${search}`; const claimId = claim && claim.claim_id; const isChannelEmpty = !claim || !claim.meta; const showFilters = !claimType || (Array.isArray(claimType) ? claimType.every((ct) => TYPES_TO_ALLOW_FILTER.includes(ct)) : TYPES_TO_ALLOW_FILTER.includes(claimType)); function handleInputChange(e) { const { value } = e.target; setSearchQuery(value); } React.useEffect(() => { setSearchQuery(''); }, [url]); const isInitialized = Boolean(activeLivestreamForChannel) || activeLivestreamInitialized; const isChannelBroadcasting = Boolean(activeLivestreamForChannel); // Find out current channels status + active live claim. React.useEffect(() => { doFetchChannelLiveStatus(claimId); const intervalId = setInterval(() => doFetchChannelLiveStatus(claimId), 30000); return () => clearInterval(intervalId); }, [claimId, doFetchChannelLiveStatus]); const showScheduledLiveStreams = claimType !== 'collection'; // ie. not on the playlist page. return ( {!fetching && Boolean(claimsInChannel) && !channelIsBlocked && !channelIsBlackListed && ( )} {!fetching && isInitialized && isChannelBroadcasting && !isChannelEmpty && ( )} {!fetching && showScheduledLiveStreams && ( )} {!fetching && channelIsBlackListed && (

{__( 'In response to a complaint we received under the US Digital Millennium Copyright Act, we have blocked access to this channel from our applications. Content may also be blocked due to DMCA Red Flag rules which are obvious copyright violations we come across, are discussed in public channels, or reported to us.' )}

)} {!fetching && channelIsBlocked && (

{__('You have blocked this channel content.')}

)} {!channelIsMine && claimsInChannel > 0 && } {!fetching && ( }} meta={ showFilters && (
{}} className="wunderbar--inline"> ) } subSection={ setIsSearching(results !== null)} doResolveUris={doResolveUris} /> } isChannel channelIsMine={channelIsMine} empty={isSearching ? ' ' : empty} /> )}
); } export default ChannelContent;