add subscribed channels to not_channels on channel discovery page

This commit is contained in:
Sean Yesmunt 2020-02-18 12:00:47 -05:00
parent efde2a2484
commit ea8b63e96f
3 changed files with 27 additions and 14 deletions

View file

@ -16,6 +16,7 @@ type Props = {
tags: Array<string>,
hiddenUris: Array<string>,
channelIds?: Array<string>,
notChannelIds?: Array<string>,
pageSize: number,
orderBy?: Array<string>,
releaseTime?: string,
@ -33,6 +34,7 @@ function ClaimTilesDiscover(props: Props) {
// Below are options to pass that are forwarded to claim_search
tags,
channelIds,
notChannelIds,
orderBy,
pageSize = 8,
releaseTime,
@ -61,8 +63,9 @@ function ClaimTilesDiscover(props: Props) {
not_tags: !showNsfw ? MATURE_TAGS : [],
channel_ids: channelIds || [],
not_channel_ids:
notChannelIds ||
// If channelIds were passed in, we don't need not_channel_ids
!channelIds && hiddenUris && hiddenUris.length ? hiddenUris.map(hiddenUri => hiddenUri.split('#')[1]) : [],
(!channelIds && hiddenUris && hiddenUris.length ? hiddenUris.map(hiddenUri => hiddenUri.split('#')[1]) : []),
order_by: orderBy || ['trending_group', 'trending_mixed'],
};

View file

@ -1,18 +1,12 @@
import { connect } from 'react-redux';
import { selectFollowedTags } from 'lbry-redux';
import { selectSubscriptions, selectSuggestedChannels } from 'redux/selectors/subscriptions';
import { doFetchRecommendedSubscriptions } from 'redux/actions/subscriptions';
import { selectFollowedTags, selectBlockedChannels } from 'lbry-redux';
import { selectSubscriptions } from 'redux/selectors/subscriptions';
import ChannelsFollowingManagePage from './view';
const select = state => ({
followedTags: selectFollowedTags(state),
subscribedChannels: selectSubscriptions(state),
suggestedSubscriptions: selectSuggestedChannels(state),
blockedChannels: selectBlockedChannels(state),
});
export default connect(
select,
{
doFetchRecommendedSubscriptions,
}
)(ChannelsFollowingManagePage);
export default connect(select)(ChannelsFollowingManagePage);

View file

@ -9,6 +9,8 @@ import { toCapitalCase } from 'util/string';
type Props = {
followedTags: Array<Tag>,
subscribedChannels: Array<Subscription>,
blockedChannels: Array<string>,
};
type RowDataItem = {
@ -19,8 +21,12 @@ type RowDataItem = {
};
function ChannelsFollowingDiscover(props: Props) {
const { followedTags } = props;
const { followedTags, subscribedChannels, blockedChannels } = props;
let rowData: Array<RowDataItem> = [];
const notChannels = subscribedChannels
.map(({ uri }) => uri)
.concat(blockedChannels)
.map(uri => uri.split('#')[1]);
rowData.push({
title: 'Top Channels Of All Time',
@ -52,7 +58,7 @@ function ChannelsFollowingDiscover(props: Props) {
if (followedTags.length > 0 && followedTags.length < 5) {
const followedRows = followedTags.map((tag: Tag) => ({
title: `Trending for #${toCapitalCase(tag.name)}`,
title: `Trending Channels for #${toCapitalCase(tag.name)}`,
link: `/$/${PAGES.TAGS}?t=${tag.name}`,
options: {
claimType: 'channel',
@ -74,9 +80,19 @@ function ChannelsFollowingDiscover(props: Props) {
});
}
const rowDataWithGenericOptions = rowData.map(row => {
return {
...row,
options: {
...row.options,
notChannels,
},
};
});
return (
<Page>
{rowData.map(({ title, link, help, options = {} }) => (
{rowDataWithGenericOptions.map(({ title, link, help, options = {} }) => (
<div key={title} className="claim-grid__wrapper">
<h1 className="section__actions">
{link ? (