mirror of
https://github.com/LBRYFoundation/lbry-desktop.git
synced 2025-08-31 09:21:27 +00:00
43 lines
1.2 KiB
JavaScript
43 lines
1.2 KiB
JavaScript
// @flow
|
|
import React from 'react';
|
|
import Page from 'component/page';
|
|
import CategoryList from 'component/categoryList';
|
|
|
|
type Props = {
|
|
fetchFeaturedUris: () => void,
|
|
fetchingFeaturedUris: boolean,
|
|
featuredUris: {},
|
|
};
|
|
|
|
class DiscoverPage extends React.PureComponent<Props> {
|
|
componentWillMount() {
|
|
this.props.fetchFeaturedUris();
|
|
}
|
|
|
|
render() {
|
|
const { featuredUris, fetchingFeaturedUris } = this.props;
|
|
const hasContent = typeof featuredUris === 'object' && Object.keys(featuredUris).length;
|
|
const failedToLoad = !fetchingFeaturedUris && !hasContent;
|
|
|
|
return (
|
|
<Page noPadding isLoading={!hasContent && fetchingFeaturedUris}>
|
|
{hasContent &&
|
|
Object.keys(featuredUris).map(
|
|
category =>
|
|
featuredUris[category].length ? (
|
|
<CategoryList key={category} category={category} names={featuredUris[category]} />
|
|
) : (
|
|
<CategoryList
|
|
key={category}
|
|
category={category.split('#')[0]}
|
|
categoryLink={category}
|
|
/>
|
|
)
|
|
)}
|
|
{failedToLoad && <div className="empty">{__('Failed to load landing content.')}</div>}
|
|
</Page>
|
|
);
|
|
}
|
|
}
|
|
|
|
export default DiscoverPage;
|