// @flow import React from 'react'; import FileTile from 'component/fileTile'; import { FormRow, FormField } from 'component/common/form'; import ToolTip from 'component/common/tooltip'; import type { Claim } from 'types/claim'; import { buildURI, parseURI } from 'lbry-redux'; type Props = { uri: string, channelUri: ?string, claimsInChannel: ?Array, autoplay: boolean, setAutoplay: boolean => void, fetchClaims: (string, number) => void, }; export default class RecommendedContent extends React.PureComponent { componentDidMount() { const { channelUri, fetchClaims, claimsInChannel } = this.props; if (channelUri && !claimsInChannel) { fetchClaims(channelUri, 1); } } render() { const { claimsInChannel, autoplay, uri, setAutoplay } = this.props; let recommendedContent; if (claimsInChannel) { recommendedContent = claimsInChannel.filter(claim => { const { name, claim_id: claimId, channel_name: channelName, value } = claim; const { isChannel } = parseURI(uri); // The uri may include the channel name const recommendedUri = isChannel && value && value.publisherSignature ? buildURI({ contentName: name, claimName: channelName, claimId: value.publisherSignature.certificateId, }) : buildURI({ claimName: name, claimId }); return recommendedUri !== uri; }); } return (
setAutoplay(e.target.checked)} /> {recommendedContent && recommendedContent.map(({ permanent_url: permanentUrl }) => ( ))}
); } }