// @flow import * as ICONS from 'constants/icons'; import * as PAGES from 'constants/pages'; import { SITE_NAME, SIMPLE_SITE, ENABLE_NO_SOURCE_CLAIMS } from 'config'; import React, { useState } from 'react'; import Page from 'component/page'; import Button from 'component/button'; import ClaimTilesDiscover from 'component/claimTilesDiscover'; import ClaimPreviewTile from 'component/claimPreviewTile'; import Icon from 'component/common/icon'; import WaitUntilOnPage from 'component/common/wait-until-on-page'; import RecommendedPersonal from 'component/recommendedPersonal'; import { useIsLargeScreen } from 'effects/use-screensize'; import { GetLinksData } from 'util/buildHomepage'; import { getLivestreamUris } from 'util/livestream'; import ScheduledStreams from 'component/scheduledStreams'; import { splitBySeparator } from 'util/lbryURI'; import classnames from 'classnames'; import Ads from 'web/component/ads'; // @if TARGET='web' import Meme from 'web/component/meme'; // @endif type Props = { authenticated: boolean, followedTags: Array, subscribedChannels: Array, showNsfw: boolean, homepageData: any, activeLivestreams: any, doFetchActiveLivestreams: () => void, fetchingActiveLivestreams: boolean, hideScheduledLivestreams: boolean, }; function HomePage(props: Props) { const { followedTags, subscribedChannels, authenticated, showNsfw, homepageData, activeLivestreams, doFetchActiveLivestreams, fetchingActiveLivestreams, hideScheduledLivestreams, } = props; const showPersonalizedChannels = (authenticated || !IS_WEB) && subscribedChannels && subscribedChannels.length > 0; const showPersonalizedTags = (authenticated || !IS_WEB) && followedTags && followedTags.length > 0; const showIndividualTags = showPersonalizedTags && followedTags.length < 5; const isLargeScreen = useIsLargeScreen(); const channelIds = subscribedChannels.map((sub) => splitBySeparator(sub.uri)[1]); const rowData: Array = GetLinksData( homepageData, isLargeScreen, true, authenticated, showPersonalizedChannels, showPersonalizedTags, subscribedChannels, followedTags, showIndividualTags, showNsfw ); type SectionHeaderProps = { title: string, navigate?: string, icon?: string, help?: string, }; const SectionHeader = ({ title, navigate = '/', icon = '', help }: SectionHeaderProps) => { return (

); }; function getRowElements(title, route, link, icon, help, options, index, pinUrls) { const tilePlaceholder = (
    {new Array(options.pageSize || 8).fill(1).map((x, i) => ( ))}
); const claimTiles = ( , replace: window.odysee_ad_blocker_detected === false, } } /> ); return (
{/* category header */} {index !== 0 && title && typeof title === 'string' && ( )} {index === 0 && <>{claimTiles}} {index !== 0 && ( {claimTiles} )} {/* view more button */} {(route || link) && (
); } React.useEffect(() => { doFetchActiveLivestreams(); }, []); const [hasPersonalRecommendations, setHasPersonalRecommendations] = useState(false); const [hasScheduledStreams, setHasScheduledStreams] = useState(false); const scheduledStreamsLoaded = (total) => setHasScheduledStreams(total > 0); return ( {!SIMPLE_SITE && (authenticated || !IS_WEB) && !subscribedChannels.length && (

{__("%SITE_NAME% is more fun if you're following channels", { SITE_NAME })}

)} {/* @if TARGET='web' */} {SIMPLE_SITE && } {/* @endif */} setHasPersonalRecommendations(displayed)} /> {!fetchingActiveLivestreams && ( <> {authenticated && channelIds.length > 0 && !hideScheduledLivestreams && ( )} {authenticated && ((hasScheduledStreams && !hideScheduledLivestreams) || hasPersonalRecommendations) && ( )} )} {rowData.map(({ title, route, link, icon, help, pinnedUrls: pinUrls, options = {} }, index) => { // add pins here return getRowElements(title, route, link, icon, help, options, index, pinUrls); })}
); } export default HomePage;