// @flow import { SHOW_ADS, SIMPLE_SITE } from 'config'; import React from 'react'; import ClaimList from 'component/claimList'; import ClaimListDiscover from 'component/claimListDiscover'; import Ads from 'web/component/ads'; import Card from 'component/common/card'; import { useIsMobile, useIsMediumScreen } from 'effects/use-screensize'; import Button from 'component/button'; import classnames from 'classnames'; const VIEW_ALL_RELATED = 'view_all_related'; const VIEW_MORE_FROM = 'view_more_from'; type Props = { uri: string, recommendedContent: Array, nextRecommendedUri: string, isSearching: boolean, doFetchRecommendedContent: (string, boolean) => void, mature: boolean, isAuthenticated: boolean, claim: ?StreamClaim, }; export default function RecommendedContent(props: Props) { const { uri, doFetchRecommendedContent, mature, recommendedContent, nextRecommendedUri, isSearching, isAuthenticated, claim, } = props; const [viewMode, setViewMode] = React.useState(VIEW_ALL_RELATED); const signingChannel = claim && claim.signing_channel; const channelName = signingChannel ? signingChannel.name : null; const isMobile = useIsMobile(); const isMedium = useIsMediumScreen(); function reorderList(recommendedContent) { let newList = recommendedContent; if (newList) { const index = newList.indexOf(nextRecommendedUri); if (index === -1) { // This would be weird. Shouldn't happen since it is derived from the same list. } else if (index !== 0) { // Swap the "next" item to the top of the list const a = newList[0]; newList[0] = nextRecommendedUri; newList[index] = a; } } return newList; } React.useEffect(() => { doFetchRecommendedContent(uri, mature); }, [uri, mature, doFetchRecommendedContent]); return (