filter out uri from content I am currently viewing
This commit is contained in:
parent
01dc3661c8
commit
bdca9f9b04
3 changed files with 28 additions and 6 deletions
|
@ -4,8 +4,10 @@ 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<Claim>,
|
||||
autoplay: boolean,
|
||||
|
@ -13,7 +15,7 @@ type Props = {
|
|||
fetchClaims: (string, number) => void,
|
||||
};
|
||||
|
||||
export default class RecommendedVideos extends React.PureComponent<Props> {
|
||||
export default class RecommendedContent extends React.PureComponent<Props> {
|
||||
componentDidMount() {
|
||||
const { channelUri, fetchClaims, claimsInChannel } = this.props;
|
||||
if (channelUri && !claimsInChannel) {
|
||||
|
@ -22,7 +24,27 @@ export default class RecommendedVideos extends React.PureComponent<Props> {
|
|||
}
|
||||
|
||||
render() {
|
||||
const { claimsInChannel, autoplay, setAutoplay } = this.props;
|
||||
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 (
|
||||
<div className="card__list--recommended">
|
||||
|
@ -39,8 +61,8 @@ export default class RecommendedVideos extends React.PureComponent<Props> {
|
|||
/>
|
||||
</ToolTip>
|
||||
</FormRow>
|
||||
{claimsInChannel &&
|
||||
claimsInChannel.map(({ permanent_url: permanentUrl }) => (
|
||||
{recommendedContent &&
|
||||
recommendedContent.map(({ permanent_url: permanentUrl }) => (
|
||||
<FileTile
|
||||
small
|
||||
displayDescription={false}
|
|
@ -19,7 +19,7 @@ import type { Subscription } from 'types/subscription';
|
|||
import FileDownloadLink from 'component/fileDownloadLink';
|
||||
import classnames from 'classnames';
|
||||
import getMediaType from 'util/getMediaType';
|
||||
import RecommendedVideos from 'component/recommendedVideos';
|
||||
import RecommendedContent from 'component/recommendedContent';
|
||||
|
||||
type Props = {
|
||||
claim: Claim,
|
||||
|
@ -218,7 +218,7 @@ class FilePage extends React.Component<Props> {
|
|||
</div>
|
||||
</section>
|
||||
<section>
|
||||
<RecommendedVideos uri={uri} channelUri={`lbry://${subscriptionUri}`} />
|
||||
<RecommendedContent uri={uri} channelUri={`lbry://${subscriptionUri}`} />
|
||||
</section>
|
||||
</Page>
|
||||
);
|
||||
|
|
Loading…
Reference in a new issue