Support not_channel_ids
through Category definition
Mainly only useful for Wild West, which doesn't use `channel_ids` (otherwise, the homepage maintainer could just exclude the id from `channel_ids` directly).
This commit is contained in:
parent
9ad73c9878
commit
e64d661dcd
6 changed files with 28 additions and 4 deletions
1
flow-typed/homepage.js
vendored
1
flow-typed/homepage.js
vendored
|
@ -22,6 +22,7 @@ declare type RowDataItem = {
|
||||||
pinnedClaimIds?: Array<string>, // takes precedence over pinnedUrls
|
pinnedClaimIds?: Array<string>, // takes precedence over pinnedUrls
|
||||||
options?: {
|
options?: {
|
||||||
channelIds?: Array<string>,
|
channelIds?: Array<string>,
|
||||||
|
excludedChannelIds?: Array<string>,
|
||||||
limitClaimsPerChannel?: number,
|
limitClaimsPerChannel?: number,
|
||||||
pageSize?: number,
|
pageSize?: number,
|
||||||
releaseTime?: string,
|
releaseTime?: string,
|
||||||
|
|
|
@ -71,6 +71,7 @@ type Props = {
|
||||||
limitClaimsPerChannel?: number,
|
limitClaimsPerChannel?: number,
|
||||||
|
|
||||||
channelIds?: Array<string>,
|
channelIds?: Array<string>,
|
||||||
|
excludedChannelIds?: Array<string>,
|
||||||
claimIds?: Array<string>,
|
claimIds?: Array<string>,
|
||||||
subscribedChannels: Array<Subscription>,
|
subscribedChannels: Array<Subscription>,
|
||||||
|
|
||||||
|
@ -128,6 +129,7 @@ function ClaimListDiscover(props: Props) {
|
||||||
meta,
|
meta,
|
||||||
subSection,
|
subSection,
|
||||||
channelIds,
|
channelIds,
|
||||||
|
excludedChannelIds,
|
||||||
showNsfw,
|
showNsfw,
|
||||||
hideReposts,
|
hideReposts,
|
||||||
fetchViewCount,
|
fetchViewCount,
|
||||||
|
@ -265,6 +267,7 @@ function ClaimListDiscover(props: Props) {
|
||||||
const durationParam = urlParams.get(CS.DURATION_KEY) || null;
|
const durationParam = urlParams.get(CS.DURATION_KEY) || null;
|
||||||
const channelIdsInUrl = urlParams.get(CS.CHANNEL_IDS_KEY);
|
const channelIdsInUrl = urlParams.get(CS.CHANNEL_IDS_KEY);
|
||||||
const channelIdsParam = channelIdsInUrl ? channelIdsInUrl.split(',') : channelIds;
|
const channelIdsParam = channelIdsInUrl ? channelIdsInUrl.split(',') : channelIds;
|
||||||
|
const excludedIdsParam = excludedChannelIds;
|
||||||
const feeAmountParam = urlParams.get('fee_amount') || feeAmount;
|
const feeAmountParam = urlParams.get('fee_amount') || feeAmount;
|
||||||
// const originalPageSize = pageSize || CS.PAGE_SIZE;
|
// const originalPageSize = pageSize || CS.PAGE_SIZE;
|
||||||
const originalPageSize = 12;
|
const originalPageSize = 12;
|
||||||
|
@ -354,6 +357,10 @@ function ClaimListDiscover(props: Props) {
|
||||||
options.channel_ids = channelIdsParam;
|
options.channel_ids = channelIdsParam;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (excludedIdsParam) {
|
||||||
|
options.not_channel_ids = (options.not_channel_ids || []).concat(excludedIdsParam);
|
||||||
|
}
|
||||||
|
|
||||||
if (tagsParam) {
|
if (tagsParam) {
|
||||||
if (tagsParam !== CS.TAGS_ALL && tagsParam !== '') {
|
if (tagsParam !== CS.TAGS_ALL && tagsParam !== '') {
|
||||||
if (tagsParam === CS.TAGS_FOLLOWED) {
|
if (tagsParam === CS.TAGS_FOLLOWED) {
|
||||||
|
|
|
@ -23,6 +23,7 @@ function getTileLimit(isLargeScreen, originalSize) {
|
||||||
type Props = {
|
type Props = {
|
||||||
tileLayout: boolean,
|
tileLayout: boolean,
|
||||||
channelIds?: Array<string>,
|
channelIds?: Array<string>,
|
||||||
|
excludedChannelIds?: Array<string>,
|
||||||
activeLivestreams: ?LivestreamInfo,
|
activeLivestreams: ?LivestreamInfo,
|
||||||
doFetchActiveLivestreams: (orderBy: ?Array<string>, lang: ?Array<string>) => void,
|
doFetchActiveLivestreams: (orderBy: ?Array<string>, lang: ?Array<string>) => void,
|
||||||
searchLanguages?: Array<string>,
|
searchLanguages?: Array<string>,
|
||||||
|
@ -35,6 +36,7 @@ export default function LivestreamSection(props: Props) {
|
||||||
const {
|
const {
|
||||||
tileLayout,
|
tileLayout,
|
||||||
channelIds,
|
channelIds,
|
||||||
|
excludedChannelIds,
|
||||||
activeLivestreams,
|
activeLivestreams,
|
||||||
doFetchActiveLivestreams,
|
doFetchActiveLivestreams,
|
||||||
searchLanguages,
|
searchLanguages,
|
||||||
|
@ -51,7 +53,7 @@ export default function LivestreamSection(props: Props) {
|
||||||
|
|
||||||
const initialLiveTileLimit = getTileLimit(isLargeScreen, DEFAULT_LIVESTREAM_TILE_LIMIT);
|
const initialLiveTileLimit = getTileLimit(isLargeScreen, DEFAULT_LIVESTREAM_TILE_LIMIT);
|
||||||
const [liveSection, setLiveSection] = React.useState(liveSectionStore || SECTION.COLLAPSED);
|
const [liveSection, setLiveSection] = React.useState(liveSectionStore || SECTION.COLLAPSED);
|
||||||
const livestreamUris = getLivestreamUris(activeLivestreams, channelIds);
|
const livestreamUris = getLivestreamUris(activeLivestreams, channelIds, excludedChannelIds);
|
||||||
const liveTilesOverLimit = livestreamUris && livestreamUris.length > initialLiveTileLimit;
|
const liveTilesOverLimit = livestreamUris && livestreamUris.length > initialLiveTileLimit;
|
||||||
|
|
||||||
function collapseSection() {
|
function collapseSection() {
|
||||||
|
|
|
@ -66,8 +66,8 @@ function DiscoverPage(props: Props) {
|
||||||
// Eventually allow more than one tag on this page
|
// Eventually allow more than one tag on this page
|
||||||
// Restricting to one to make follow/unfollow simpler
|
// Restricting to one to make follow/unfollow simpler
|
||||||
const tag = (tags && tags[0]) || null;
|
const tag = (tags && tags[0]) || null;
|
||||||
const channelIds =
|
const channelIds = dynamicRouteProps?.options?.channelIds || undefined;
|
||||||
(dynamicRouteProps && dynamicRouteProps.options && dynamicRouteProps.options.channelIds) || undefined;
|
const excludedChannelIds = dynamicRouteProps?.options?.excludedChannelIds || undefined;
|
||||||
|
|
||||||
const isFollowing = followedTags.map(({ name }) => name).includes(tag);
|
const isFollowing = followedTags.map(({ name }) => name).includes(tag);
|
||||||
let label = isFollowing ? __('Following --[button label indicating a channel has been followed]--') : __('Follow');
|
let label = isFollowing ? __('Following --[button label indicating a channel has been followed]--') : __('Follow');
|
||||||
|
@ -113,6 +113,7 @@ function DiscoverPage(props: Props) {
|
||||||
<LivestreamSection
|
<LivestreamSection
|
||||||
tileLayout={repostedUri ? false : tileLayout}
|
tileLayout={repostedUri ? false : tileLayout}
|
||||||
channelIds={channelIds}
|
channelIds={channelIds}
|
||||||
|
excludedChannelIds={excludedChannelIds}
|
||||||
activeLivestreams={activeLivestreams}
|
activeLivestreams={activeLivestreams}
|
||||||
doFetchActiveLivestreams={doFetchActiveLivestreams}
|
doFetchActiveLivestreams={doFetchActiveLivestreams}
|
||||||
searchLanguages={dynamicRouteProps?.options?.searchLanguages}
|
searchLanguages={dynamicRouteProps?.options?.searchLanguages}
|
||||||
|
@ -207,6 +208,7 @@ function DiscoverPage(props: Props) {
|
||||||
releaseTime={releaseTime || undefined}
|
releaseTime={releaseTime || undefined}
|
||||||
feeAmount={isWildWest || tags ? CS.FEE_AMOUNT_ANY : undefined}
|
feeAmount={isWildWest || tags ? CS.FEE_AMOUNT_ANY : undefined}
|
||||||
channelIds={channelIds}
|
channelIds={channelIds}
|
||||||
|
excludedChannelIds={excludedChannelIds}
|
||||||
limitClaimsPerChannel={
|
limitClaimsPerChannel={
|
||||||
SIMPLE_SITE
|
SIMPLE_SITE
|
||||||
? (dynamicRouteProps && dynamicRouteProps.options && dynamicRouteProps.options.limitClaimsPerChannel) || 3
|
? (dynamicRouteProps && dynamicRouteProps.options && dynamicRouteProps.options.limitClaimsPerChannel) || 3
|
||||||
|
|
|
@ -21,6 +21,7 @@ export type HomepageCat = {
|
||||||
tags?: Array<string>,
|
tags?: Array<string>,
|
||||||
pinnedUrls?: Array<string>,
|
pinnedUrls?: Array<string>,
|
||||||
pinnedClaimIds?: Array<string>, // takes precedence over pinnedUrls
|
pinnedClaimIds?: Array<string>, // takes precedence over pinnedUrls
|
||||||
|
excludedChannelIds?: Array<string>,
|
||||||
searchLanguages?: Array<string>,
|
searchLanguages?: Array<string>,
|
||||||
mixIn?: Array<string>,
|
mixIn?: Array<string>,
|
||||||
};
|
};
|
||||||
|
@ -96,6 +97,7 @@ export const getHomepageRowForCat = (key: string, cat: HomepageCat) => {
|
||||||
options: {
|
options: {
|
||||||
claimType: cat.claimType || ['stream', 'repost'],
|
claimType: cat.claimType || ['stream', 'repost'],
|
||||||
channelIds: cat.channelIds,
|
channelIds: cat.channelIds,
|
||||||
|
excludedChannelIds: cat.excludedChannelIds,
|
||||||
orderBy: orderValue,
|
orderBy: orderValue,
|
||||||
pageSize: cat.pageSize || undefined,
|
pageSize: cat.pageSize || undefined,
|
||||||
limitClaimsPerChannel: limitClaims,
|
limitClaimsPerChannel: limitClaims,
|
||||||
|
|
|
@ -34,9 +34,14 @@ type StreamData = {
|
||||||
*
|
*
|
||||||
* @param activeLivestreams Object obtained from `selectActiveLivestreams`.
|
* @param activeLivestreams Object obtained from `selectActiveLivestreams`.
|
||||||
* @param channelIds List of channel IDs to filter the results with.
|
* @param channelIds List of channel IDs to filter the results with.
|
||||||
|
* @param excludedChannelIds
|
||||||
* @returns {[]|Array<*>}
|
* @returns {[]|Array<*>}
|
||||||
*/
|
*/
|
||||||
export function getLivestreamUris(activeLivestreams: ?LivestreamInfo, channelIds: ?Array<string>) {
|
export function getLivestreamUris(
|
||||||
|
activeLivestreams: ?LivestreamInfo,
|
||||||
|
channelIds: ?Array<string>,
|
||||||
|
excludedChannelIds?: Array<string>
|
||||||
|
) {
|
||||||
let values = (activeLivestreams && Object.values(activeLivestreams)) || [];
|
let values = (activeLivestreams && Object.values(activeLivestreams)) || [];
|
||||||
|
|
||||||
if (channelIds && channelIds.length > 0) {
|
if (channelIds && channelIds.length > 0) {
|
||||||
|
@ -47,6 +52,11 @@ export function getLivestreamUris(activeLivestreams: ?LivestreamInfo, channelIds
|
||||||
values = values.filter((v) => Boolean(v.claimUri));
|
values = values.filter((v) => Boolean(v.claimUri));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (excludedChannelIds) {
|
||||||
|
// $FlowFixMe
|
||||||
|
values = values.filter((v) => !excludedChannelIds.includes(v.creatorId));
|
||||||
|
}
|
||||||
|
|
||||||
// $FlowFixMe
|
// $FlowFixMe
|
||||||
return values.map((v) => v.claimUri);
|
return values.map((v) => v.claimUri);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue