// @flow import * as ICONS from 'constants/icons'; import * as MODALS from 'constants/modal_types'; import * as PAGES from 'constants/pages'; import { ENABLE_NO_SOURCE_CLAIMS } from 'config'; import React 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 Yrbl from 'component/yrbl'; 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'; import Meme from 'web/component/meme'; const FYP_SECTION: RowDataItem = { id: 'FYP', title: 'Recommended', icon: ICONS.GLOBE, link: `/$/${PAGES.FYP}`, }; type HomepageOrder = { active: ?Array, hidden: ?Array }; type Props = { authenticated: boolean, followedTags: Array, subscribedChannels: Array, showNsfw: boolean, homepageData: any, homepageFetched: boolean, activeLivestreams: any, doFetchActiveLivestreams: () => void, fetchingActiveLivestreams: boolean, hideScheduledLivestreams: boolean, adBlockerFound: ?boolean, homepageOrder: HomepageOrder, doOpenModal: (id: string, ?{}) => void, hasMembership: ?boolean, }; function HomePage(props: Props) { const { followedTags, subscribedChannels, authenticated, showNsfw, homepageData, homepageFetched, activeLivestreams, doFetchActiveLivestreams, fetchingActiveLivestreams, hideScheduledLivestreams, adBlockerFound, homepageOrder, doOpenModal, hasMembership, } = 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 ); let sortedRowData: Array = []; if (homepageOrder.active && authenticated) { homepageOrder.active.forEach((key) => { const dataIndex = rowData.findIndex((data) => data.id === key); if (dataIndex !== -1) { sortedRowData.push(rowData[dataIndex]); rowData.splice(dataIndex, 1); } else if (key === 'FYP') { sortedRowData.push(FYP_SECTION); } }); if (homepageOrder.hidden) { rowData.forEach((data: RowDataItem) => { // $FlowIssue: null 'hidden' already avoided outside anonymous function. if (!homepageOrder.hidden.includes(data.id)) { sortedRowData.push(data); } }); } } else { rowData.forEach((key) => { sortedRowData.push(key); if (key.id === 'FOLLOWING' && hasMembership) { sortedRowData.push(FYP_SECTION); } }); } type SectionHeaderProps = { title: string, navigate?: string, icon?: string, help?: string, }; const SectionHeader = ({ title, navigate = '/', icon = '', help }: SectionHeaderProps) => { return (

); }; const CustomizeHomepage = () => { return (