remove stream_types from live
and fix homepage too
This commit is contained in:
parent
b9a7f9673d
commit
09ee081218
2 changed files with 42 additions and 20 deletions
|
@ -23,11 +23,11 @@ type Props = {
|
||||||
doClaimSearch: ({}) => void,
|
doClaimSearch: ({}) => void,
|
||||||
loading: boolean,
|
loading: boolean,
|
||||||
personalView: boolean,
|
personalView: boolean,
|
||||||
doToggleTagFollowDesktop: (string) => void,
|
doToggleTagFollowDesktop: string => void,
|
||||||
meta?: Node,
|
meta?: Node,
|
||||||
showNsfw: boolean,
|
showNsfw: boolean,
|
||||||
hideReposts: boolean,
|
hideReposts: boolean,
|
||||||
history: { action: string, push: (string) => void, replace: (string) => void },
|
history: { action: string, push: string => void, replace: string => void },
|
||||||
location: { search: string, pathname: string },
|
location: { search: string, pathname: string },
|
||||||
claimSearchByQuery: {
|
claimSearchByQuery: {
|
||||||
[string]: Array<string>,
|
[string]: Array<string>,
|
||||||
|
@ -52,7 +52,7 @@ type Props = {
|
||||||
defaultClaimType?: Array<string>,
|
defaultClaimType?: Array<string>,
|
||||||
streamType?: string | Array<string>,
|
streamType?: string | Array<string>,
|
||||||
defaultStreamType?: string | Array<string>,
|
defaultStreamType?: string | Array<string>,
|
||||||
renderProperties?: (Claim) => Node,
|
renderProperties?: Claim => Node,
|
||||||
includeSupportAction?: boolean,
|
includeSupportAction?: boolean,
|
||||||
repostedClaimId?: string,
|
repostedClaimId?: string,
|
||||||
pageSize?: number,
|
pageSize?: number,
|
||||||
|
@ -133,14 +133,14 @@ function ClaimListDiscover(props: Props) {
|
||||||
const isLargeScreen = useIsLargeScreen();
|
const isLargeScreen = useIsLargeScreen();
|
||||||
const [orderParamEntry, setOrderParamEntry] = usePersistedState(`entry-${location.pathname}`, CS.ORDER_BY_TRENDING);
|
const [orderParamEntry, setOrderParamEntry] = usePersistedState(`entry-${location.pathname}`, CS.ORDER_BY_TRENDING);
|
||||||
const [orderParamUser, setOrderParamUser] = usePersistedState(`orderUser-${location.pathname}`, CS.ORDER_BY_TRENDING);
|
const [orderParamUser, setOrderParamUser] = usePersistedState(`orderUser-${location.pathname}`, CS.ORDER_BY_TRENDING);
|
||||||
const followed = (followedTags && followedTags.map((t) => t.name)) || [];
|
const followed = (followedTags && followedTags.map(t => t.name)) || [];
|
||||||
const urlParams = new URLSearchParams(search);
|
const urlParams = new URLSearchParams(search);
|
||||||
const tagsParam = // can be 'x,y,z' or 'x' or ['x','y'] or CS.CONSTANT
|
const tagsParam = // can be 'x,y,z' or 'x' or ['x','y'] or CS.CONSTANT
|
||||||
(tags && getParamFromTags(tags)) ||
|
(tags && getParamFromTags(tags)) ||
|
||||||
(urlParams.get(CS.TAGS_KEY) !== null && urlParams.get(CS.TAGS_KEY)) ||
|
(urlParams.get(CS.TAGS_KEY) !== null && urlParams.get(CS.TAGS_KEY)) ||
|
||||||
(defaultTags && getParamFromTags(defaultTags));
|
(defaultTags && getParamFromTags(defaultTags));
|
||||||
const freshnessParam = freshness || urlParams.get(CS.FRESH_KEY) || defaultFreshness;
|
const freshnessParam = freshness || urlParams.get(CS.FRESH_KEY) || defaultFreshness;
|
||||||
const mutedAndBlockedChannelIds = Array.from(new Set(mutedUris.concat(blockedUris).map((uri) => uri.split('#')[1])));
|
const mutedAndBlockedChannelIds = Array.from(new Set(mutedUris.concat(blockedUris).map(uri => uri.split('#')[1])));
|
||||||
|
|
||||||
const langParam = urlParams.get(CS.LANGUAGE_KEY) || null;
|
const langParam = urlParams.get(CS.LANGUAGE_KEY) || null;
|
||||||
const languageParams = searchInLanguage
|
const languageParams = searchInLanguage
|
||||||
|
@ -265,7 +265,12 @@ function ClaimListDiscover(props: Props) {
|
||||||
|
|
||||||
if (claimType !== CS.CLAIM_CHANNEL) {
|
if (claimType !== CS.CLAIM_CHANNEL) {
|
||||||
if (orderParam === CS.ORDER_BY_TOP && freshnessParam !== CS.FRESH_ALL) {
|
if (orderParam === CS.ORDER_BY_TOP && freshnessParam !== CS.FRESH_ALL) {
|
||||||
options.release_time = `>${Math.floor(moment().subtract(1, freshnessParam).startOf('hour').unix())}`;
|
options.release_time = `>${Math.floor(
|
||||||
|
moment()
|
||||||
|
.subtract(1, freshnessParam)
|
||||||
|
.startOf('hour')
|
||||||
|
.unix()
|
||||||
|
)}`;
|
||||||
} else if (orderParam === CS.ORDER_BY_NEW || orderParam === CS.ORDER_BY_TRENDING) {
|
} else if (orderParam === CS.ORDER_BY_NEW || orderParam === CS.ORDER_BY_TRENDING) {
|
||||||
// Warning - hack below
|
// Warning - hack below
|
||||||
// If users are following more than 10 channels or tags, limit results to stuff less than a year old
|
// If users are following more than 10 channels or tags, limit results to stuff less than a year old
|
||||||
|
@ -276,15 +281,29 @@ function ClaimListDiscover(props: Props) {
|
||||||
(options.channel_ids && options.channel_ids.length > 20) ||
|
(options.channel_ids && options.channel_ids.length > 20) ||
|
||||||
(options.any_tags && options.any_tags.length > 20)
|
(options.any_tags && options.any_tags.length > 20)
|
||||||
) {
|
) {
|
||||||
options.release_time = `>${Math.floor(moment().subtract(3, CS.FRESH_MONTH).startOf('week').unix())}`;
|
options.release_time = `>${Math.floor(
|
||||||
|
moment()
|
||||||
|
.subtract(3, CS.FRESH_MONTH)
|
||||||
|
.startOf('week')
|
||||||
|
.unix()
|
||||||
|
)}`;
|
||||||
} else if (
|
} else if (
|
||||||
(options.channel_ids && options.channel_ids.length > 10) ||
|
(options.channel_ids && options.channel_ids.length > 10) ||
|
||||||
(options.any_tags && options.any_tags.length > 10)
|
(options.any_tags && options.any_tags.length > 10)
|
||||||
) {
|
) {
|
||||||
options.release_time = `>${Math.floor(moment().subtract(1, CS.FRESH_YEAR).startOf('week').unix())}`;
|
options.release_time = `>${Math.floor(
|
||||||
|
moment()
|
||||||
|
.subtract(1, CS.FRESH_YEAR)
|
||||||
|
.startOf('week')
|
||||||
|
.unix()
|
||||||
|
)}`;
|
||||||
} else {
|
} else {
|
||||||
// Hack for at least the New page until https://github.com/lbryio/lbry-sdk/issues/2591 is fixed
|
// Hack for at least the New page until https://github.com/lbryio/lbry-sdk/issues/2591 is fixed
|
||||||
options.release_time = `<${Math.floor(moment().startOf('minute').unix())}`;
|
options.release_time = `<${Math.floor(
|
||||||
|
moment()
|
||||||
|
.startOf('minute')
|
||||||
|
.unix()
|
||||||
|
)}`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -332,14 +351,14 @@ function ClaimListDiscover(props: Props) {
|
||||||
if (hideReposts && !options.reposted_claim_id && !forceShowReposts) {
|
if (hideReposts && !options.reposted_claim_id && !forceShowReposts) {
|
||||||
if (Array.isArray(options.claim_type)) {
|
if (Array.isArray(options.claim_type)) {
|
||||||
if (options.claim_type.length > 1) {
|
if (options.claim_type.length > 1) {
|
||||||
options.claim_type = options.claim_type.filter((claimType) => claimType !== 'repost');
|
options.claim_type = options.claim_type.filter(claimType => claimType !== 'repost');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
options.claim_type = ['stream', 'channel'];
|
options.claim_type = ['stream', 'channel'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const hasMatureTags = tagsParam && tagsParam.split(',').some((t) => MATURE_TAGS.includes(t));
|
const hasMatureTags = tagsParam && tagsParam.split(',').some(t => MATURE_TAGS.includes(t));
|
||||||
const claimSearchCacheQuery = createNormalizedClaimSearchKey(options);
|
const claimSearchCacheQuery = createNormalizedClaimSearchKey(options);
|
||||||
const claimSearchResult = claimSearchByQuery[claimSearchCacheQuery];
|
const claimSearchResult = claimSearchByQuery[claimSearchCacheQuery];
|
||||||
const claimSearchResultLastPageReached = claimSearchByQueryLastPageReached[claimSearchCacheQuery];
|
const claimSearchResultLastPageReached = claimSearchByQueryLastPageReached[claimSearchCacheQuery];
|
||||||
|
@ -453,6 +472,7 @@ function ClaimListDiscover(props: Props) {
|
||||||
|
|
||||||
if (liveLivestreamsFirst && options.page === 1) {
|
if (liveLivestreamsFirst && options.page === 1) {
|
||||||
delete searchOptions.has_source;
|
delete searchOptions.has_source;
|
||||||
|
delete searchOptions.stream_types;
|
||||||
doClaimSearch({ ...searchOptions, has_no_source: true });
|
doClaimSearch({ ...searchOptions, has_no_source: true });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,7 +49,7 @@ export function prioritizeActiveLivestreams(
|
||||||
let liveChannelIds = Object.keys(livestreamMap);
|
let liveChannelIds = Object.keys(livestreamMap);
|
||||||
|
|
||||||
// 1. Collect active livestreams from the primary search to put in front.
|
// 1. Collect active livestreams from the primary search to put in front.
|
||||||
uris.forEach((uri) => {
|
uris.forEach(uri => {
|
||||||
const claim = claimsByUri[uri];
|
const claim = claimsByUri[uri];
|
||||||
if (claimIsLive(claim, liveChannelIds)) {
|
if (claimIsLive(claim, liveChannelIds)) {
|
||||||
liveUris.push(uri);
|
liveUris.push(uri);
|
||||||
|
@ -66,7 +66,7 @@ export function prioritizeActiveLivestreams(
|
||||||
});
|
});
|
||||||
const livestreamsOnlyUris = claimSearchByQuery[livestreamsOnlySearchCacheQuery];
|
const livestreamsOnlyUris = claimSearchByQuery[livestreamsOnlySearchCacheQuery];
|
||||||
if (livestreamsOnlyUris) {
|
if (livestreamsOnlyUris) {
|
||||||
livestreamsOnlyUris.forEach((uri) => {
|
livestreamsOnlyUris.forEach(uri => {
|
||||||
const claim = claimsByUri[uri];
|
const claim = claimsByUri[uri];
|
||||||
if (!uris.includes(uri) && claimIsLive(claim, liveChannelIds)) {
|
if (!uris.includes(uri) && claimIsLive(claim, liveChannelIds)) {
|
||||||
liveUris.push(uri);
|
liveUris.push(uri);
|
||||||
|
@ -78,7 +78,7 @@ export function prioritizeActiveLivestreams(
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3. Finalize uris by putting live livestreams in front.
|
// 3. Finalize uris by putting live livestreams in front.
|
||||||
const newUris = liveUris.concat(uris.filter((uri) => !liveUris.includes(uri)));
|
const newUris = liveUris.concat(uris.filter(uri => !liveUris.includes(uri)));
|
||||||
uris.splice(0, uris.length, ...newUris);
|
uris.splice(0, uris.length, ...newUris);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -92,7 +92,7 @@ type Props = {
|
||||||
doClaimSearch: ({}) => void,
|
doClaimSearch: ({}) => void,
|
||||||
showNsfw: boolean,
|
showNsfw: boolean,
|
||||||
hideReposts: boolean,
|
hideReposts: boolean,
|
||||||
history: { action: string, push: (string) => void, replace: (string) => void },
|
history: { action: string, push: string => void, replace: string => void },
|
||||||
claimSearchByQuery: { [string]: Array<string> },
|
claimSearchByQuery: { [string]: Array<string> },
|
||||||
fetchingClaimSearchByQuery: { [string]: boolean },
|
fetchingClaimSearchByQuery: { [string]: boolean },
|
||||||
claimsByUri: { [string]: any },
|
claimsByUri: { [string]: any },
|
||||||
|
@ -113,7 +113,7 @@ type Props = {
|
||||||
limitClaimsPerChannel?: number,
|
limitClaimsPerChannel?: number,
|
||||||
hasSource?: boolean,
|
hasSource?: boolean,
|
||||||
hasNoSource?: boolean,
|
hasNoSource?: boolean,
|
||||||
renderProperties?: (Claim) => ?Node,
|
renderProperties?: Claim => ?Node,
|
||||||
liveLivestreamsFirst?: boolean,
|
liveLivestreamsFirst?: boolean,
|
||||||
livestreamMap?: { [string]: any },
|
livestreamMap?: { [string]: any },
|
||||||
};
|
};
|
||||||
|
@ -153,7 +153,7 @@ function ClaimTilesDiscover(props: Props) {
|
||||||
const urlParams = new URLSearchParams(location.search);
|
const urlParams = new URLSearchParams(location.search);
|
||||||
const feeAmountInUrl = urlParams.get('fee_amount');
|
const feeAmountInUrl = urlParams.get('fee_amount');
|
||||||
const feeAmountParam = feeAmountInUrl || feeAmount;
|
const feeAmountParam = feeAmountInUrl || feeAmount;
|
||||||
const mutedAndBlockedChannelIds = Array.from(new Set(mutedUris.concat(blockedUris).map((uri) => uri.split('#')[1])));
|
const mutedAndBlockedChannelIds = Array.from(new Set(mutedUris.concat(blockedUris).map(uri => uri.split('#')[1])));
|
||||||
const liveUris = [];
|
const liveUris = [];
|
||||||
|
|
||||||
const options: {
|
const options: {
|
||||||
|
@ -186,7 +186,8 @@ function ClaimTilesDiscover(props: Props) {
|
||||||
channel_ids: channelIds || [],
|
channel_ids: channelIds || [],
|
||||||
not_channel_ids: mutedAndBlockedChannelIds,
|
not_channel_ids: mutedAndBlockedChannelIds,
|
||||||
order_by: orderBy || ['trending_group', 'trending_mixed'],
|
order_by: orderBy || ['trending_group', 'trending_mixed'],
|
||||||
stream_types: streamTypes === null ? undefined : SIMPLE_SITE ? [CS.FILE_VIDEO, CS.FILE_AUDIO] : undefined,
|
stream_types:
|
||||||
|
streamTypes === null ? undefined : SIMPLE_SITE && !hasNoSource ? [CS.FILE_VIDEO, CS.FILE_AUDIO] : undefined,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (ENABLE_NO_SOURCE_CLAIMS && hasNoSource) {
|
if (ENABLE_NO_SOURCE_CLAIMS && hasNoSource) {
|
||||||
|
@ -210,7 +211,7 @@ function ClaimTilesDiscover(props: Props) {
|
||||||
// https://github.com/lbryio/lbry-desktop/issues/3774
|
// https://github.com/lbryio/lbry-desktop/issues/3774
|
||||||
if (hideReposts) {
|
if (hideReposts) {
|
||||||
if (Array.isArray(options.claim_type)) {
|
if (Array.isArray(options.claim_type)) {
|
||||||
options.claim_type = options.claim_type.filter((claimType) => claimType !== 'repost');
|
options.claim_type = options.claim_type.filter(claimType => claimType !== 'repost');
|
||||||
} else {
|
} else {
|
||||||
options.claim_type = ['stream', 'channel'];
|
options.claim_type = ['stream', 'channel'];
|
||||||
}
|
}
|
||||||
|
@ -247,12 +248,13 @@ function ClaimTilesDiscover(props: Props) {
|
||||||
|
|
||||||
if (liveLivestreamsFirst) {
|
if (liveLivestreamsFirst) {
|
||||||
delete searchOptions.has_source;
|
delete searchOptions.has_source;
|
||||||
|
delete searchOptions.stream_types;
|
||||||
doClaimSearch({ ...searchOptions, has_no_source: true });
|
doClaimSearch({ ...searchOptions, has_no_source: true });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, [doClaimSearch, shouldPerformSearch, optionsStringForEffect, liveLivestreamsFirst]);
|
}, [doClaimSearch, shouldPerformSearch, optionsStringForEffect, liveLivestreamsFirst]);
|
||||||
|
|
||||||
const resolveLive = (index) => {
|
const resolveLive = index => {
|
||||||
if (liveLivestreamsFirst && livestreamMap && index < liveUris.length) {
|
if (liveLivestreamsFirst && livestreamMap && index < liveUris.length) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue