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 { FormRow, FormField } from 'component/common/form';
|
||||||
import ToolTip from 'component/common/tooltip';
|
import ToolTip from 'component/common/tooltip';
|
||||||
import type { Claim } from 'types/claim';
|
import type { Claim } from 'types/claim';
|
||||||
|
import { buildURI, parseURI } from 'lbry-redux';
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
|
uri: string,
|
||||||
channelUri: ?string,
|
channelUri: ?string,
|
||||||
claimsInChannel: ?Array<Claim>,
|
claimsInChannel: ?Array<Claim>,
|
||||||
autoplay: boolean,
|
autoplay: boolean,
|
||||||
|
@ -13,7 +15,7 @@ type Props = {
|
||||||
fetchClaims: (string, number) => void,
|
fetchClaims: (string, number) => void,
|
||||||
};
|
};
|
||||||
|
|
||||||
export default class RecommendedVideos extends React.PureComponent<Props> {
|
export default class RecommendedContent extends React.PureComponent<Props> {
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
const { channelUri, fetchClaims, claimsInChannel } = this.props;
|
const { channelUri, fetchClaims, claimsInChannel } = this.props;
|
||||||
if (channelUri && !claimsInChannel) {
|
if (channelUri && !claimsInChannel) {
|
||||||
|
@ -22,7 +24,27 @@ export default class RecommendedVideos extends React.PureComponent<Props> {
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
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 (
|
return (
|
||||||
<div className="card__list--recommended">
|
<div className="card__list--recommended">
|
||||||
|
@ -39,8 +61,8 @@ export default class RecommendedVideos extends React.PureComponent<Props> {
|
||||||
/>
|
/>
|
||||||
</ToolTip>
|
</ToolTip>
|
||||||
</FormRow>
|
</FormRow>
|
||||||
{claimsInChannel &&
|
{recommendedContent &&
|
||||||
claimsInChannel.map(({ permanent_url: permanentUrl }) => (
|
recommendedContent.map(({ permanent_url: permanentUrl }) => (
|
||||||
<FileTile
|
<FileTile
|
||||||
small
|
small
|
||||||
displayDescription={false}
|
displayDescription={false}
|
|
@ -19,7 +19,7 @@ import type { Subscription } from 'types/subscription';
|
||||||
import FileDownloadLink from 'component/fileDownloadLink';
|
import FileDownloadLink from 'component/fileDownloadLink';
|
||||||
import classnames from 'classnames';
|
import classnames from 'classnames';
|
||||||
import getMediaType from 'util/getMediaType';
|
import getMediaType from 'util/getMediaType';
|
||||||
import RecommendedVideos from 'component/recommendedVideos';
|
import RecommendedContent from 'component/recommendedContent';
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
claim: Claim,
|
claim: Claim,
|
||||||
|
@ -218,7 +218,7 @@ class FilePage extends React.Component<Props> {
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
<section>
|
<section>
|
||||||
<RecommendedVideos uri={uri} channelUri={`lbry://${subscriptionUri}`} />
|
<RecommendedContent uri={uri} channelUri={`lbry://${subscriptionUri}`} />
|
||||||
</section>
|
</section>
|
||||||
</Page>
|
</Page>
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in a new issue