// @flow import React from 'react'; import * as CS from 'constants/claim_search'; import moment from 'moment'; import * as ICONS from 'constants/icons'; import { useIsMediumScreen, useIsLargeScreen } from 'effects/use-screensize'; import ClaimListDiscover from 'component/claimListDiscover'; import Button from 'component/button'; import { LIVESTREAM_UPCOMING_BUFFER } from 'constants/livestream'; import { SCHEDULED_LIVESTREAM_TAG } from 'constants/tags'; import * as SETTINGS from 'constants/settings'; type Props = { channelIds: Array, tileLayout: boolean, liveUris: Array, limitClaimsPerChannel?: number, onLoad: (number) => void, showHideSetting: boolean, // --- perform --- setClientSetting: (string, boolean | string | number, boolean) => void, doShowSnackBar: (string) => void, }; const ScheduledStreams = (props: Props) => { const { channelIds, tileLayout, liveUris = [], limitClaimsPerChannel, setClientSetting, doShowSnackBar, onLoad, showHideSetting = true, } = props; const isMediumScreen = useIsMediumScreen(); const isLargeScreen = useIsLargeScreen(); const [totalUpcomingLivestreams, setTotalUpcomingLivestreams] = React.useState(0); const [showAllUpcoming, setShowAllUpcoming] = React.useState(false); const showUpcomingLivestreams = totalUpcomingLivestreams > 0; const useSwipeLayout = totalUpcomingLivestreams > 1 && isMediumScreen; const upcomingMax = React.useMemo(() => { if (showAllUpcoming || useSwipeLayout) return 50; if (isLargeScreen) return 6; if (isMediumScreen) return 3; return 4; }, [showAllUpcoming, isMediumScreen, isLargeScreen, useSwipeLayout]); const loadedCallback = (total) => { setTotalUpcomingLivestreams(total); if (typeof onLoad === 'function') onLoad(total); }; const hideScheduledStreams = () => { setClientSetting(SETTINGS.HIDE_SCHEDULED_LIVESTREAMS, true, true); doShowSnackBar(__('Scheduled streams hidden, you can re-enable them in settings.')); }; const Header = () => { return (
{__('Upcoming Livestreams')} {showHideSetting && (
); }; return (
${moment().subtract(LIVESTREAM_UPCOMING_BUFFER, 'minutes').startOf('minute').unix()}`} hideAdvancedFilter hideFilters infiniteScroll={false} showNoSourceClaims hideLayoutButton header={
} maxClaimRender={upcomingMax} excludeUris={liveUris} loadedCallback={loadedCallback} /> {totalUpcomingLivestreams > upcomingMax && !showAllUpcoming && !useSwipeLayout && (
)} {showAllUpcoming && (
)}
); }; export default ScheduledStreams;