ChannelsFollowingDiscover: remove Desktop code

This commit is contained in:
infinite-persistence 2022-07-13 01:25:42 +08:00 committed by Thomas Zarebczan
parent c563889bf6
commit 58d9605033
2 changed files with 3 additions and 106 deletions

View file

@ -1,16 +1,12 @@
import { connect } from 'react-redux';
import { selectFollowedTags } from 'redux/selectors/tags';
import { selectMutedChannels } from 'redux/selectors/blocked';
import { selectSubscriptions } from 'redux/selectors/subscriptions';
import { selectHomepageData, selectHomepageDiscover } from 'redux/selectors/settings';
import ChannelsFollowingManagePage from './view';
import ChannelsFollowingDiscover from './view';
const select = (state) => ({
followedTags: selectFollowedTags(state),
subscribedChannels: selectSubscriptions(state),
blockedChannels: selectMutedChannels(state),
homepageData: selectHomepageData(state),
discoverData: selectHomepageDiscover(state),
});
export default connect(select)(ChannelsFollowingManagePage);
export default connect(select)(ChannelsFollowingDiscover);

View file

@ -1,34 +1,21 @@
// @flow
import * as ICONS from 'constants/icons';
import * as PAGES from 'constants/pages';
import React from 'react';
import Page from 'component/page';
import Button from 'component/button';
import ClaimTilesDiscover from 'component/claimTilesDiscover';
import ClaimListDiscover from 'component/claimListDiscover';
import * as CS from 'constants/claim_search';
import { toCapitalCase } from 'util/string';
import { CUSTOM_HOMEPAGE, SIMPLE_SITE } from 'config';
const MORE_CHANNELS_ANCHOR = 'MoreChannels';
type Props = {
followedTags: Array<Tag>,
subscribedChannels: Array<Subscription>,
blockedChannels: Array<string>,
homepageData: any,
discoverData: ?Array<string>,
};
type ChannelsFollowingItem = {
title: string,
link?: string,
help?: any,
options?: {},
};
function ChannelsFollowingDiscover(props: Props) {
const { followedTags, subscribedChannels, blockedChannels, homepageData, discoverData } = props;
const { /* subscribedChannels, */ homepageData, discoverData } = props;
const { PRIMARY_CONTENT, LATEST } = homepageData;
let channelIds;
@ -42,94 +29,8 @@ function ChannelsFollowingDiscover(props: Props) {
}
}
let rowData: Array<ChannelsFollowingItem> = [];
const notChannels = subscribedChannels
.map(({ uri }) => uri)
.concat(blockedChannels)
.map((uri) => uri.split('#')[1]);
rowData.push({
title: 'Top Channels Of All Time',
link: `/$/${PAGES.DISCOVER}?claim_type=channel&${CS.ORDER_BY_KEY}=${CS.ORDER_BY_TOP}&${CS.FRESH_KEY}=${CS.FRESH_ALL}`,
options: {
pageSize: 12,
claimType: 'channel',
orderBy: ['effective_amount'],
},
});
rowData.push({
title: 'Trending Channels',
link: `/$/${PAGES.DISCOVER}?claim_type=channel`,
options: {
pageSize: 8,
claimType: 'channel',
orderBy: ['trending_group', 'trending_mixed'],
},
});
if (followedTags.length > 0 && followedTags.length < 5) {
const followedRows = followedTags.map((tag: Tag) => ({
title: `Trending Channels for #${toCapitalCase(tag.name)}`,
link: `/$/${PAGES.DISCOVER}?t=${tag.name}&claim_type=channel`,
options: {
claimType: 'channel',
pageSize: 4,
tags: [tag.name],
},
}));
rowData.push(...followedRows);
}
if (followedTags.length > 4) {
rowData.push({
title: 'Trending For Your Tags',
link: `/$/${PAGES.TAGS_FOLLOWING}?claim_type=channel`,
options: {
claimType: 'channel',
tags: followedTags.map((tag) => tag.name),
},
});
}
const rowDataWithGenericOptions = rowData.map((row) => {
return {
...row,
options: {
...row.options,
notChannels,
},
};
});
return (
<Page className="discoverPage-wrapper">
{!SIMPLE_SITE &&
rowDataWithGenericOptions.map(({ title, link, help, options = {} }) => (
<div key={title} className="claim-grid__wrapper">
<h1 className="section__actions">
{link ? (
<Button
className="claim-grid__title"
button="link"
navigate={link}
iconRight={ICONS.ARROW_RIGHT}
label={__(title)}
/>
) : (
<span className="claim-grid__title">{__(title)}</span>
)}
{help}
</h1>
<ClaimTilesDiscover {...options} />
</div>
))}
{!SIMPLE_SITE && (
<h1 id={MORE_CHANNELS_ANCHOR} className="claim-grid__title">
{__('More Channels')}
</h1>
)}
<ClaimListDiscover
defaultOrderBy={CS.ORDER_BY_TRENDING}
defaultFreshness={CS.FRESH_ALL}