Merge pull request #1908 from lbryio/related-fix

add message for 0 returned results in related content
This commit is contained in:
Sean Yesmunt 2018-08-27 18:58:22 -04:00 committed by GitHub
commit 9de8451e21
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 11 deletions

View file

@ -1,10 +1,16 @@
import { connect } from 'react-redux';
import { makeSelectClaimForUri, doSearch, makeSelectRecommendedContentForUri } from 'lbry-redux';
import {
makeSelectClaimForUri,
doSearch,
makeSelectRecommendedContentForUri,
selectIsSearching,
} from 'lbry-redux';
import RecommendedVideos from './view';
const select = (state, props) => ({
claim: makeSelectClaimForUri(props.uri)(state),
recommendedContent: makeSelectRecommendedContentForUri(props.uri)(state),
isSearching: selectIsSearching(state),
});
const perform = dispatch => ({

View file

@ -7,6 +7,7 @@ type Props = {
uri: string,
claim: ?Claim,
recommendedContent: Array<string>,
isSearching: boolean,
search: string => void,
};
@ -46,13 +47,12 @@ export default class RecommendedContent extends React.PureComponent<Props> {
didSearch: ?boolean;
render() {
const { recommendedContent } = this.props;
const { recommendedContent, isSearching } = this.props;
return (
<section className="card__list--recommended">
<span>Related</span>
{recommendedContent &&
recommendedContent.length &&
recommendedContent.map(recommendedUri => (
<FileTile
size="small"
@ -62,6 +62,9 @@ export default class RecommendedContent extends React.PureComponent<Props> {
uri={recommendedUri}
/>
))}
{recommendedContent &&
!recommendedContent.length &&
!isSearching && <div className="card__subtitle">No related content found</div>}
</section>
);
}

View file

@ -160,13 +160,6 @@ class FilePage extends React.Component<Props> {
editUri = buildURI(uriObject);
}
let recommendedUri = uri;
if (!recommendedUri.includes('#')) {
// at a vanity url
// append the claim ID so we can properly strip it out of reccomended videos
recommendedUri = `${recommendedUri}#${claim.claim_id}`;
}
return (
<Page forContent>
<section className="content__wrapper">
@ -251,7 +244,7 @@ class FilePage extends React.Component<Props> {
</div>
</div>
</section>
<RecommendedContent uri={recommendedUri} />
<RecommendedContent uri={uri} />
</Page>
);
}