discover channelIds from homepages
This commit is contained in:
parent
9cdfb239c0
commit
70af46149d
5 changed files with 43 additions and 38 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -33,3 +33,6 @@ package-lock.json
|
||||||
!/custom/robots.disallowall
|
!/custom/robots.disallowall
|
||||||
!/custom/robots.allowall
|
!/custom/robots.allowall
|
||||||
.env
|
.env
|
||||||
|
.env.ody
|
||||||
|
.env.desktop
|
||||||
|
.env.lbrytv
|
||||||
|
|
|
@ -6,7 +6,7 @@ import Nag from 'component/common/nag';
|
||||||
import { parseURI } from 'lbry-redux';
|
import { parseURI } from 'lbry-redux';
|
||||||
import Button from 'component/button';
|
import Button from 'component/button';
|
||||||
import Card from 'component/common/card';
|
import Card from 'component/common/card';
|
||||||
import { AUTO_FOLLOW_CHANNELS, SIMPLE_SITE } from 'config';
|
import { AUTO_FOLLOW_CHANNELS, CUSTOM_HOMEPAGE } from 'config';
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
subscribedChannels: Array<Subscription>,
|
subscribedChannels: Array<Subscription>,
|
||||||
|
@ -23,7 +23,11 @@ const channelsToSubscribe = AUTO_FOLLOW_CHANNELS.trim()
|
||||||
|
|
||||||
function UserChannelFollowIntro(props: Props) {
|
function UserChannelFollowIntro(props: Props) {
|
||||||
const { subscribedChannels, channelSubscribe, onContinue, onBack, homepageData, prefsReady } = props;
|
const { subscribedChannels, channelSubscribe, onContinue, onBack, homepageData, prefsReady } = props;
|
||||||
const { PRIMARY_CONTENT_CHANNEL_IDS } = homepageData;
|
const { PRIMARY_CONTENT } = homepageData;
|
||||||
|
let channelIds;
|
||||||
|
if (PRIMARY_CONTENT && CUSTOM_HOMEPAGE) {
|
||||||
|
channelIds = PRIMARY_CONTENT.channelIds;
|
||||||
|
}
|
||||||
const followingCount = (subscribedChannels && subscribedChannels.length) || 0;
|
const followingCount = (subscribedChannels && subscribedChannels.length) || 0;
|
||||||
|
|
||||||
// subscribe to lbry
|
// subscribe to lbry
|
||||||
|
@ -62,7 +66,7 @@ function UserChannelFollowIntro(props: Props) {
|
||||||
defaultOrderBy={CS.ORDER_BY_TOP}
|
defaultOrderBy={CS.ORDER_BY_TOP}
|
||||||
defaultFreshness={CS.FRESH_ALL}
|
defaultFreshness={CS.FRESH_ALL}
|
||||||
claimType="channel"
|
claimType="channel"
|
||||||
claimIds={SIMPLE_SITE ? undefined : PRIMARY_CONTENT_CHANNEL_IDS}
|
claimIds={CUSTOM_HOMEPAGE && channelIds ? channelIds : undefined}
|
||||||
defaultTags={followingCount > 3 ? CS.TAGS_FOLLOWED : undefined}
|
defaultTags={followingCount > 3 ? CS.TAGS_FOLLOWED : undefined}
|
||||||
/>
|
/>
|
||||||
{followingCount > 0 && (
|
{followingCount > 0 && (
|
||||||
|
|
|
@ -20,6 +20,8 @@ import { useGetAds } from 'effects/use-get-ads';
|
||||||
import Button from 'component/button';
|
import Button from 'component/button';
|
||||||
import I18nMessage from 'component/i18nMessage';
|
import I18nMessage from 'component/i18nMessage';
|
||||||
import { useHistory } from 'react-router';
|
import { useHistory } from 'react-router';
|
||||||
|
import { getAllIds } from 'util/buildHomepage';
|
||||||
|
import type { HomepageCat } from 'util/buildHomepage';
|
||||||
|
|
||||||
const PLAY_TIMEOUT_ERROR = 'play_timeout_error';
|
const PLAY_TIMEOUT_ERROR = 'play_timeout_error';
|
||||||
const PLAY_TIMEOUT_LIMIT = 2000;
|
const PLAY_TIMEOUT_LIMIT = 2000;
|
||||||
|
@ -48,15 +50,7 @@ type Props = {
|
||||||
setVideoPlaybackRate: (number) => void,
|
setVideoPlaybackRate: (number) => void,
|
||||||
authenticated: boolean,
|
authenticated: boolean,
|
||||||
userId: number,
|
userId: number,
|
||||||
homepageData: {
|
homepageData?: { [string]: HomepageCat },
|
||||||
PRIMARY_CONTENT_CHANNEL_IDS?: Array<string>,
|
|
||||||
ENLIGHTENMENT_CHANNEL_IDS?: Array<string>,
|
|
||||||
GAMING_CHANNEL_IDS?: Array<string>,
|
|
||||||
SCIENCE_CHANNEL_IDS?: Array<string>,
|
|
||||||
TECHNOLOGY_CHANNEL_IDS?: Array<string>,
|
|
||||||
COMMUNITY_CHANNEL_IDS?: Array<string>,
|
|
||||||
FINCANCE_CHANNEL_IDS?: Array<string>,
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -91,24 +85,8 @@ function VideoViewer(props: Props) {
|
||||||
authenticated,
|
authenticated,
|
||||||
userId,
|
userId,
|
||||||
} = props;
|
} = props;
|
||||||
const {
|
|
||||||
PRIMARY_CONTENT_CHANNEL_IDS = [],
|
const adApprovedChannelIds = homepageData ? getAllIds(homepageData) : [];
|
||||||
ENLIGHTENMENT_CHANNEL_IDS = [],
|
|
||||||
GAMING_CHANNEL_IDS = [],
|
|
||||||
SCIENCE_CHANNEL_IDS = [],
|
|
||||||
TECHNOLOGY_CHANNEL_IDS = [],
|
|
||||||
COMMUNITY_CHANNEL_IDS = [],
|
|
||||||
FINCANCE_CHANNEL_IDS = [],
|
|
||||||
} = homepageData;
|
|
||||||
const adApprovedChannelIds = [
|
|
||||||
...PRIMARY_CONTENT_CHANNEL_IDS,
|
|
||||||
...ENLIGHTENMENT_CHANNEL_IDS,
|
|
||||||
...GAMING_CHANNEL_IDS,
|
|
||||||
...SCIENCE_CHANNEL_IDS,
|
|
||||||
...TECHNOLOGY_CHANNEL_IDS,
|
|
||||||
...COMMUNITY_CHANNEL_IDS,
|
|
||||||
...FINCANCE_CHANNEL_IDS,
|
|
||||||
];
|
|
||||||
const claimId = claim && claim.claim_id;
|
const claimId = claim && claim.claim_id;
|
||||||
const channelClaimId = claim && claim.signing_channel && claim.signing_channel.claim_id;
|
const channelClaimId = claim && claim.signing_channel && claim.signing_channel.claim_id;
|
||||||
const isAudio = contentType.includes('audio');
|
const isAudio = contentType.includes('audio');
|
||||||
|
|
|
@ -8,7 +8,7 @@ import ClaimTilesDiscover from 'component/claimTilesDiscover';
|
||||||
import ClaimListDiscover from 'component/claimListDiscover';
|
import ClaimListDiscover from 'component/claimListDiscover';
|
||||||
import * as CS from 'constants/claim_search';
|
import * as CS from 'constants/claim_search';
|
||||||
import { toCapitalCase } from 'util/string';
|
import { toCapitalCase } from 'util/string';
|
||||||
import { SIMPLE_SITE } from 'config';
|
import { CUSTOM_HOMEPAGE } from 'config';
|
||||||
|
|
||||||
const MORE_CHANNELS_ANCHOR = 'MoreChannels';
|
const MORE_CHANNELS_ANCHOR = 'MoreChannels';
|
||||||
|
|
||||||
|
@ -28,12 +28,16 @@ type ChannelsFollowingItem = {
|
||||||
|
|
||||||
function ChannelsFollowingDiscover(props: Props) {
|
function ChannelsFollowingDiscover(props: Props) {
|
||||||
const { followedTags, subscribedChannels, blockedChannels, homepageData } = props;
|
const { followedTags, subscribedChannels, blockedChannels, homepageData } = props;
|
||||||
const { PRIMARY_CONTENT_CHANNEL_IDS } = homepageData;
|
const { PRIMARY_CONTENT } = homepageData;
|
||||||
|
let channelIds;
|
||||||
|
if (PRIMARY_CONTENT && CUSTOM_HOMEPAGE) {
|
||||||
|
channelIds = PRIMARY_CONTENT.channelIds;
|
||||||
|
}
|
||||||
let rowData: Array<ChannelsFollowingItem> = [];
|
let rowData: Array<ChannelsFollowingItem> = [];
|
||||||
const notChannels = subscribedChannels
|
const notChannels = subscribedChannels
|
||||||
.map(({ uri }) => uri)
|
.map(({ uri }) => uri)
|
||||||
.concat(blockedChannels)
|
.concat(blockedChannels)
|
||||||
.map(uri => uri.split('#')[1]);
|
.map((uri) => uri.split('#')[1]);
|
||||||
|
|
||||||
rowData.push({
|
rowData.push({
|
||||||
title: 'Top Channels Of All Time',
|
title: 'Top Channels Of All Time',
|
||||||
|
@ -84,12 +88,12 @@ function ChannelsFollowingDiscover(props: Props) {
|
||||||
link: `/$/${PAGES.TAGS_FOLLOWING}?claim_type=channel`,
|
link: `/$/${PAGES.TAGS_FOLLOWING}?claim_type=channel`,
|
||||||
options: {
|
options: {
|
||||||
claimType: 'channel',
|
claimType: 'channel',
|
||||||
tags: followedTags.map(tag => tag.name),
|
tags: followedTags.map((tag) => tag.name),
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const rowDataWithGenericOptions = rowData.map(row => {
|
const rowDataWithGenericOptions = rowData.map((row) => {
|
||||||
return {
|
return {
|
||||||
...row,
|
...row,
|
||||||
options: {
|
options: {
|
||||||
|
@ -124,12 +128,11 @@ function ChannelsFollowingDiscover(props: Props) {
|
||||||
<h1 id={MORE_CHANNELS_ANCHOR} className="claim-grid__title">
|
<h1 id={MORE_CHANNELS_ANCHOR} className="claim-grid__title">
|
||||||
{__('More Channels')}
|
{__('More Channels')}
|
||||||
</h1>
|
</h1>
|
||||||
{/* odysee: claimIds = PRIMARY_CONTENT_CHANNEL_IDS if simplesite CLD */}
|
|
||||||
<ClaimListDiscover
|
<ClaimListDiscover
|
||||||
defaultOrderBy={CS.ORDER_BY_TRENDING}
|
defaultOrderBy={CS.ORDER_BY_TRENDING}
|
||||||
defaultFreshness={CS.FRESH_ALL}
|
defaultFreshness={CS.FRESH_ALL}
|
||||||
claimType={CS.CLAIM_CHANNEL}
|
claimType={CS.CLAIM_CHANNEL}
|
||||||
claimIds={SIMPLE_SITE ? PRIMARY_CONTENT_CHANNEL_IDS : undefined}
|
claimIds={CUSTOM_HOMEPAGE && channelIds ? channelIds : undefined}
|
||||||
scrollAnchor={MORE_CHANNELS_ANCHOR}
|
scrollAnchor={MORE_CHANNELS_ANCHOR}
|
||||||
/>
|
/>
|
||||||
</Page>
|
</Page>
|
||||||
|
|
|
@ -38,6 +38,12 @@ export type HomepageCat = {
|
||||||
mixIn?: Array<string>,
|
mixIn?: Array<string>,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// type HomepageData = {
|
||||||
|
// [string]: {
|
||||||
|
// [string]: HomepageCat,
|
||||||
|
// },
|
||||||
|
// };
|
||||||
|
|
||||||
function getLimitPerChannel(size, isChannel) {
|
function getLimitPerChannel(size, isChannel) {
|
||||||
if (isChannel) {
|
if (isChannel) {
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -46,6 +52,17 @@ function getLimitPerChannel(size, isChannel) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getAllIds(all: any) {
|
||||||
|
const idsSet: Set<string> = new Set();
|
||||||
|
(Object.values(all): any).forEach((cat) => {
|
||||||
|
if (cat.channelIds) {
|
||||||
|
cat.channelIds.forEach((id) => idsSet.add(id));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
// $FlowFixMe
|
||||||
|
return Array.from(idsSet);
|
||||||
|
}
|
||||||
|
|
||||||
export const getHomepageRowForCat = (cat: HomepageCat) => {
|
export const getHomepageRowForCat = (cat: HomepageCat) => {
|
||||||
let orderValue;
|
let orderValue;
|
||||||
switch (cat.order) {
|
switch (cat.order) {
|
||||||
|
@ -106,7 +123,7 @@ export const getHomepageRowForCat = (cat: HomepageCat) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
export function GetLinksData(
|
export function GetLinksData(
|
||||||
all: any,
|
all: any, // HomepageData type?
|
||||||
isHomepage?: boolean = false,
|
isHomepage?: boolean = false,
|
||||||
authenticated?: boolean,
|
authenticated?: boolean,
|
||||||
showPersonalizedChannels?: boolean,
|
showPersonalizedChannels?: boolean,
|
||||||
|
|
Loading…
Reference in a new issue