2020-02-17 20:12:28 +01:00
|
|
|
// @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';
|
2020-02-27 18:01:57 +01:00
|
|
|
import ClaimListDiscover from 'component/claimListDiscover';
|
2020-02-10 20:43:24 +01:00
|
|
|
import * as CS from 'constants/claim_search';
|
2020-02-18 16:26:58 +01:00
|
|
|
import { toCapitalCase } from 'util/string';
|
2021-07-21 22:42:15 +02:00
|
|
|
import { CUSTOM_HOMEPAGE, SIMPLE_SITE } from 'config';
|
2020-02-17 20:12:28 +01:00
|
|
|
|
2020-11-25 18:09:58 +01:00
|
|
|
const MORE_CHANNELS_ANCHOR = 'MoreChannels';
|
|
|
|
|
2020-02-18 16:26:58 +01:00
|
|
|
type Props = {
|
|
|
|
followedTags: Array<Tag>,
|
2020-02-18 18:00:47 +01:00
|
|
|
subscribedChannels: Array<Subscription>,
|
|
|
|
blockedChannels: Array<string>,
|
2020-11-10 17:07:00 +01:00
|
|
|
homepageData: any,
|
2020-02-18 16:26:58 +01:00
|
|
|
};
|
2020-02-17 20:12:28 +01:00
|
|
|
|
2020-09-15 20:28:04 +02:00
|
|
|
type ChannelsFollowingItem = {
|
2020-02-17 20:12:28 +01:00
|
|
|
title: string,
|
|
|
|
link?: string,
|
|
|
|
help?: any,
|
|
|
|
options?: {},
|
|
|
|
};
|
|
|
|
|
|
|
|
function ChannelsFollowingDiscover(props: Props) {
|
2020-11-10 17:07:00 +01:00
|
|
|
const { followedTags, subscribedChannels, blockedChannels, homepageData } = props;
|
2021-07-17 00:20:22 +02:00
|
|
|
const { PRIMARY_CONTENT } = homepageData;
|
|
|
|
let channelIds;
|
|
|
|
if (PRIMARY_CONTENT && CUSTOM_HOMEPAGE) {
|
2021-09-13 18:48:17 +02:00
|
|
|
channelIds = PRIMARY_CONTENT.ids;
|
2021-07-17 00:20:22 +02:00
|
|
|
}
|
2020-09-15 20:28:04 +02:00
|
|
|
let rowData: Array<ChannelsFollowingItem> = [];
|
2020-02-18 18:00:47 +01:00
|
|
|
const notChannels = subscribedChannels
|
|
|
|
.map(({ uri }) => uri)
|
|
|
|
.concat(blockedChannels)
|
2021-07-17 00:20:22 +02:00
|
|
|
.map((uri) => uri.split('#')[1]);
|
2020-02-17 20:12:28 +01:00
|
|
|
|
|
|
|
rowData.push({
|
2020-02-18 16:26:58 +01:00
|
|
|
title: 'Top Channels Of All Time',
|
2020-09-18 16:13:20 +02:00
|
|
|
link: `/$/${PAGES.DISCOVER}?claim_type=channel&${CS.ORDER_BY_KEY}=${CS.ORDER_BY_TOP}&${CS.FRESH_KEY}=${CS.FRESH_ALL}`,
|
2020-02-18 16:26:58 +01:00
|
|
|
options: {
|
2020-02-26 19:39:03 +01:00
|
|
|
pageSize: 12,
|
2020-02-18 16:26:58 +01:00
|
|
|
claimType: 'channel',
|
|
|
|
orderBy: ['effective_amount'],
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
rowData.push({
|
|
|
|
title: 'Trending Channels',
|
2020-03-09 19:26:08 +01:00
|
|
|
link: `/$/${PAGES.DISCOVER}?claim_type=channel`,
|
2020-02-18 16:26:58 +01:00
|
|
|
options: {
|
2020-02-26 19:39:03 +01:00
|
|
|
pageSize: 8,
|
2020-02-17 20:12:28 +01:00
|
|
|
claimType: 'channel',
|
2020-02-18 16:26:58 +01:00
|
|
|
orderBy: ['trending_group', 'trending_mixed'],
|
2020-02-17 20:12:28 +01:00
|
|
|
},
|
|
|
|
});
|
|
|
|
|
2020-02-18 16:26:58 +01:00
|
|
|
if (followedTags.length > 0 && followedTags.length < 5) {
|
|
|
|
const followedRows = followedTags.map((tag: Tag) => ({
|
2020-02-18 18:00:47 +01:00
|
|
|
title: `Trending Channels for #${toCapitalCase(tag.name)}`,
|
2020-02-28 16:11:55 +01:00
|
|
|
link: `/$/${PAGES.DISCOVER}?t=${tag.name}&claim_type=channel`,
|
2020-02-18 16:26:58 +01:00
|
|
|
options: {
|
|
|
|
claimType: 'channel',
|
|
|
|
pageSize: 4,
|
|
|
|
tags: [tag.name],
|
|
|
|
},
|
|
|
|
}));
|
|
|
|
rowData.push(...followedRows);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (followedTags.length > 4) {
|
|
|
|
rowData.push({
|
|
|
|
title: 'Trending For Your Tags',
|
2020-02-21 17:33:14 +01:00
|
|
|
link: `/$/${PAGES.TAGS_FOLLOWING}?claim_type=channel`,
|
2020-02-18 16:26:58 +01:00
|
|
|
options: {
|
|
|
|
claimType: 'channel',
|
2021-07-17 00:20:22 +02:00
|
|
|
tags: followedTags.map((tag) => tag.name),
|
2020-02-18 16:26:58 +01:00
|
|
|
},
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2021-07-17 00:20:22 +02:00
|
|
|
const rowDataWithGenericOptions = rowData.map((row) => {
|
2020-02-18 18:00:47 +01:00
|
|
|
return {
|
|
|
|
...row,
|
|
|
|
options: {
|
|
|
|
...row.options,
|
|
|
|
notChannels,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
});
|
|
|
|
|
2020-02-17 20:12:28 +01:00
|
|
|
return (
|
|
|
|
<Page>
|
2021-07-21 22:42:15 +02:00
|
|
|
{!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>
|
2020-02-17 20:12:28 +01:00
|
|
|
|
2021-07-21 22:42:15 +02:00
|
|
|
<ClaimTilesDiscover {...options} />
|
|
|
|
</div>
|
|
|
|
))}
|
|
|
|
{!SIMPLE_SITE && (
|
|
|
|
<h1 id={MORE_CHANNELS_ANCHOR} className="claim-grid__title">
|
|
|
|
{__('More Channels')}
|
|
|
|
</h1>
|
|
|
|
)}
|
2020-11-10 17:07:00 +01:00
|
|
|
<ClaimListDiscover
|
2020-11-10 18:47:31 +01:00
|
|
|
defaultOrderBy={CS.ORDER_BY_TRENDING}
|
2020-11-10 17:07:00 +01:00
|
|
|
defaultFreshness={CS.FRESH_ALL}
|
2020-11-10 18:47:31 +01:00
|
|
|
claimType={CS.CLAIM_CHANNEL}
|
2021-07-17 00:20:22 +02:00
|
|
|
claimIds={CUSTOM_HOMEPAGE && channelIds ? channelIds : undefined}
|
2020-11-25 18:09:58 +01:00
|
|
|
scrollAnchor={MORE_CHANNELS_ANCHOR}
|
2021-07-23 05:07:32 +02:00
|
|
|
maxPages={SIMPLE_SITE ? 3 : undefined}
|
|
|
|
hideFilters={SIMPLE_SITE}
|
|
|
|
header={SIMPLE_SITE ? <h1 className="section__title">{__('Moon cheese is an acquired taste')}</h1> : undefined}
|
2020-11-10 17:07:00 +01:00
|
|
|
/>
|
2020-02-17 20:12:28 +01:00
|
|
|
</Page>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
export default ChannelsFollowingDiscover;
|