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.allowall
|
||||
.env
|
||||
.env.ody
|
||||
.env.desktop
|
||||
.env.lbrytv
|
||||
|
|
|
@ -6,7 +6,7 @@ import Nag from 'component/common/nag';
|
|||
import { parseURI } from 'lbry-redux';
|
||||
import Button from 'component/button';
|
||||
import Card from 'component/common/card';
|
||||
import { AUTO_FOLLOW_CHANNELS, SIMPLE_SITE } from 'config';
|
||||
import { AUTO_FOLLOW_CHANNELS, CUSTOM_HOMEPAGE } from 'config';
|
||||
|
||||
type Props = {
|
||||
subscribedChannels: Array<Subscription>,
|
||||
|
@ -23,7 +23,11 @@ const channelsToSubscribe = AUTO_FOLLOW_CHANNELS.trim()
|
|||
|
||||
function UserChannelFollowIntro(props: 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;
|
||||
|
||||
// subscribe to lbry
|
||||
|
@ -62,7 +66,7 @@ function UserChannelFollowIntro(props: Props) {
|
|||
defaultOrderBy={CS.ORDER_BY_TOP}
|
||||
defaultFreshness={CS.FRESH_ALL}
|
||||
claimType="channel"
|
||||
claimIds={SIMPLE_SITE ? undefined : PRIMARY_CONTENT_CHANNEL_IDS}
|
||||
claimIds={CUSTOM_HOMEPAGE && channelIds ? channelIds : undefined}
|
||||
defaultTags={followingCount > 3 ? CS.TAGS_FOLLOWED : undefined}
|
||||
/>
|
||||
{followingCount > 0 && (
|
||||
|
|
|
@ -20,6 +20,8 @@ import { useGetAds } from 'effects/use-get-ads';
|
|||
import Button from 'component/button';
|
||||
import I18nMessage from 'component/i18nMessage';
|
||||
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_LIMIT = 2000;
|
||||
|
@ -48,15 +50,7 @@ type Props = {
|
|||
setVideoPlaybackRate: (number) => void,
|
||||
authenticated: boolean,
|
||||
userId: number,
|
||||
homepageData: {
|
||||
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>,
|
||||
},
|
||||
homepageData?: { [string]: HomepageCat },
|
||||
};
|
||||
|
||||
/*
|
||||
|
@ -91,24 +85,8 @@ function VideoViewer(props: Props) {
|
|||
authenticated,
|
||||
userId,
|
||||
} = props;
|
||||
const {
|
||||
PRIMARY_CONTENT_CHANNEL_IDS = [],
|
||||
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 adApprovedChannelIds = homepageData ? getAllIds(homepageData) : [];
|
||||
const claimId = claim && claim.claim_id;
|
||||
const channelClaimId = claim && claim.signing_channel && claim.signing_channel.claim_id;
|
||||
const isAudio = contentType.includes('audio');
|
||||
|
|
|
@ -8,7 +8,7 @@ import ClaimTilesDiscover from 'component/claimTilesDiscover';
|
|||
import ClaimListDiscover from 'component/claimListDiscover';
|
||||
import * as CS from 'constants/claim_search';
|
||||
import { toCapitalCase } from 'util/string';
|
||||
import { SIMPLE_SITE } from 'config';
|
||||
import { CUSTOM_HOMEPAGE } from 'config';
|
||||
|
||||
const MORE_CHANNELS_ANCHOR = 'MoreChannels';
|
||||
|
||||
|
@ -28,12 +28,16 @@ type ChannelsFollowingItem = {
|
|||
|
||||
function ChannelsFollowingDiscover(props: 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> = [];
|
||||
const notChannels = subscribedChannels
|
||||
.map(({ uri }) => uri)
|
||||
.concat(blockedChannels)
|
||||
.map(uri => uri.split('#')[1]);
|
||||
.map((uri) => uri.split('#')[1]);
|
||||
|
||||
rowData.push({
|
||||
title: 'Top Channels Of All Time',
|
||||
|
@ -84,12 +88,12 @@ function ChannelsFollowingDiscover(props: Props) {
|
|||
link: `/$/${PAGES.TAGS_FOLLOWING}?claim_type=channel`,
|
||||
options: {
|
||||
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 {
|
||||
...row,
|
||||
options: {
|
||||
|
@ -124,12 +128,11 @@ function ChannelsFollowingDiscover(props: Props) {
|
|||
<h1 id={MORE_CHANNELS_ANCHOR} className="claim-grid__title">
|
||||
{__('More Channels')}
|
||||
</h1>
|
||||
{/* odysee: claimIds = PRIMARY_CONTENT_CHANNEL_IDS if simplesite CLD */}
|
||||
<ClaimListDiscover
|
||||
defaultOrderBy={CS.ORDER_BY_TRENDING}
|
||||
defaultFreshness={CS.FRESH_ALL}
|
||||
claimType={CS.CLAIM_CHANNEL}
|
||||
claimIds={SIMPLE_SITE ? PRIMARY_CONTENT_CHANNEL_IDS : undefined}
|
||||
claimIds={CUSTOM_HOMEPAGE && channelIds ? channelIds : undefined}
|
||||
scrollAnchor={MORE_CHANNELS_ANCHOR}
|
||||
/>
|
||||
</Page>
|
||||
|
|
|
@ -38,6 +38,12 @@ export type HomepageCat = {
|
|||
mixIn?: Array<string>,
|
||||
};
|
||||
|
||||
// type HomepageData = {
|
||||
// [string]: {
|
||||
// [string]: HomepageCat,
|
||||
// },
|
||||
// };
|
||||
|
||||
function getLimitPerChannel(size, isChannel) {
|
||||
if (isChannel) {
|
||||
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) => {
|
||||
let orderValue;
|
||||
switch (cat.order) {
|
||||
|
@ -106,7 +123,7 @@ export const getHomepageRowForCat = (cat: HomepageCat) => {
|
|||
};
|
||||
|
||||
export function GetLinksData(
|
||||
all: any,
|
||||
all: any, // HomepageData type?
|
||||
isHomepage?: boolean = false,
|
||||
authenticated?: boolean,
|
||||
showPersonalizedChannels?: boolean,
|
||||
|
|
Loading…
Reference in a new issue