Add support for clickable link

This commit is contained in:
Chakrit Likitkhajorn 2018-10-10 21:13:43 +07:00
parent 445bf77e36
commit 2646ce4481

View file

@ -31,6 +31,16 @@ class DiscoverPage extends React.PureComponent<Props> {
this.clearContinuousFetch();
}
getCategoryLinkPartByCategory(category: string) {
const channelName = category.substr(category.indexOf('@'));
if (!channelName.includes('#')) {
return null;
}
return channelName;
}
continousFetch: ?IntervalID;
clearContinuousFetch() {
if (this.continousFetch) {
clearInterval(this.continousFetch);
@ -38,20 +48,22 @@ class DiscoverPage extends React.PureComponent<Props> {
}
}
continousFetch: ?number;
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}
names={featuredUris[category]}
categoryLink={this.getCategoryLinkPartByCategory(category)}
/>
) : (
<CategoryList
key={category}