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