Merge pull request #2023 from chrisza4/clickable-channel

Add support for Clickable channel names on Explore page headings (#1820)
This commit is contained in:
Sean Yesmunt 2018-10-11 16:26:53 -04:00 committed by GitHub
commit 003fb1f334
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 5 deletions

View file

@ -8,6 +8,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
### Added ### Added
* Allow typing of encryption password without clicking entry box ([#1977](https://github.com/lbryio/lbry-desktop/pull/1977)) * Allow typing of encryption password without clicking entry box ([#1977](https://github.com/lbryio/lbry-desktop/pull/1977))
* Focus on search bar with {cmd,ctrl} + "l" ([#2003](https://github.com/lbryio/lbry-desktop/pull/2003)) * Focus on search bar with {cmd,ctrl} + "l" ([#2003](https://github.com/lbryio/lbry-desktop/pull/2003))
* Add support for clickable channel names on explore page headings ([#2023](https://github.com/lbryio/lbry-desktop/pull/2023))
### Changed ### Changed
* Make tooltip smarter ([#1979](https://github.com/lbryio/lbry-desktop/pull/1979)) * Make tooltip smarter ([#1979](https://github.com/lbryio/lbry-desktop/pull/1979))
* Change channel pages to have 48 items instead of 10 ([#2002](https://github.com/lbryio/lbry-desktop/pull/2002)) * Change channel pages to have 48 items instead of 10 ([#2002](https://github.com/lbryio/lbry-desktop/pull/2002))

View file

@ -31,6 +31,20 @@ class DiscoverPage extends React.PureComponent<Props> {
this.clearContinuousFetch(); this.clearContinuousFetch();
} }
getCategoryLinkPartByCategory(category: string) {
const channelName = category.substr(category.indexOf('@'));
if (!channelName.includes('#')) {
return null;
}
return channelName;
}
trimClaimIdFromCategory(category: string) {
return category.split('#')[0];
}
continousFetch: ?IntervalID;
clearContinuousFetch() { clearContinuousFetch() {
if (this.continousFetch) { if (this.continousFetch) {
clearInterval(this.continousFetch); clearInterval(this.continousFetch);
@ -38,24 +52,26 @@ class DiscoverPage extends React.PureComponent<Props> {
} }
} }
continousFetch: ?number;
render() { render() {
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}>
{hasContent && {hasContent &&
Object.keys(featuredUris).map( Object.keys(featuredUris).map(
category => category =>
featuredUris[category].length ? ( featuredUris[category].length ? (
<CategoryList key={category} category={category} names={featuredUris[category]} /> <CategoryList
key={category}
category={this.trimClaimIdFromCategory(category)}
names={featuredUris[category]}
categoryLink={this.getCategoryLinkPartByCategory(category)}
/>
) : ( ) : (
<CategoryList <CategoryList
key={category} key={category}
category={category.split('#')[0]} category={this.trimClaimIdFromCategory(category)}
categoryLink={category} categoryLink={category}
/> />
) )