fix: limit category list to 10 items

This commit is contained in:
Sean Yesmunt 2019-01-24 16:20:43 -05:00
parent 33ec088006
commit d43a40baf0
2 changed files with 23 additions and 20 deletions

View file

@ -272,13 +272,24 @@ class CategoryList extends PureComponent<Props, State> {
</p> </p>
) : ( ) : (
<ul className="media-scrollhouse" ref={this.scrollWrapper}> <ul className="media-scrollhouse" ref={this.scrollWrapper}>
{/*
`names` and `channelClaims` should be combined
it's set up to take a list of names (uris) to show as cards
or a channel link, which it uses for fetch a list of names
having both makes it really confusing
will come back to this once we determine how we will receive channel links
from the homepage uris api call
- sean
*/}
{names && {names &&
names.length && !!names.length &&
names.map(name => ( names.map(name => (
<FileCard showSubscribedLogo key={name} uri={normalizeURI(name)} /> <FileCard showSubscribedLogo key={name} uri={normalizeURI(name)} />
))} ))}
{channelClaims && {(!names || !names.length) &&
channelClaims &&
channelClaims.length && channelClaims.length &&
channelClaims channelClaims
// Only show the first 10 claims, regardless of the amount we have on a channel page // Only show the first 10 claims, regardless of the amount we have on a channel page

View file

@ -18,7 +18,7 @@ class DiscoverPage extends React.PureComponent<Props> {
this.continousFetch = undefined; this.continousFetch = undefined;
} }
componentWillMount() { componentDidMount() {
const { fetchFeaturedUris, fetchRewardedContent, fetchRewards } = this.props; const { fetchFeaturedUris, fetchRewardedContent, fetchRewards } = this.props;
fetchFeaturedUris(); fetchFeaturedUris();
fetchRewardedContent(); fetchRewardedContent();
@ -59,27 +59,19 @@ class DiscoverPage extends React.PureComponent<Props> {
const { featuredUris, fetchingFeaturedUris } = this.props; const { featuredUris, fetchingFeaturedUris } = this.props;
const hasContent = typeof featuredUris === 'object' && Object.keys(featuredUris).length; const hasContent = typeof featuredUris === 'object' && Object.keys(featuredUris).length;
const failedToLoad = !fetchingFeaturedUris && !hasContent; const failedToLoad = !fetchingFeaturedUris && !hasContent;
return ( return (
<Page noPadding isLoading={!hasContent && fetchingFeaturedUris}> <Page noPadding isLoading={!hasContent && fetchingFeaturedUris}>
<FirstRun /> <FirstRun />
{hasContent && {hasContent &&
Object.keys(featuredUris).map( Object.keys(featuredUris).map(category => (
category => <CategoryList
featuredUris[category].length ? ( key={category}
<CategoryList category={this.trimClaimIdFromCategory(category)}
key={category} names={featuredUris[category]}
category={this.trimClaimIdFromCategory(category)} categoryLink={this.getCategoryLinkPartByCategory(category)}
names={featuredUris[category]} />
categoryLink={this.getCategoryLinkPartByCategory(category)} ))}
/>
) : (
<CategoryList
key={category}
category={this.trimClaimIdFromCategory(category)}
categoryLink={category}
/>
)
)}
{failedToLoad && <div className="empty">{__('Failed to load landing content.')}</div>} {failedToLoad && <div className="empty">{__('Failed to load landing content.')}</div>}
</Page> </Page>
); );