more recon

This commit is contained in:
zeppi 2021-07-17 14:55:18 -04:00 committed by jessopb
parent 1fa7533ee3
commit dfc013d423
7 changed files with 47 additions and 18 deletions

View file

@ -17,6 +17,7 @@ declare type RowDataItem = {
help?: any, help?: any,
icon?: string, icon?: string,
extra?: any, extra?: any,
pinUrls?: Array<string>,
options?: { options?: {
channelIds?: Array<string>, channelIds?: Array<string>,
limitClaimsPerChannel?: number, limitClaimsPerChannel?: number,

View file

@ -1,5 +1,5 @@
// @flow // @flow
import { SHOW_ADS, ENABLE_NO_SOURCE_CLAIMS } from 'config'; import { SHOW_ADS, ENABLE_NO_SOURCE_CLAIMS, SIMPLE_SITE } from 'config';
import * as CS from 'constants/claim_search'; import * as CS from 'constants/claim_search';
import * as ICONS from 'constants/icons'; import * as ICONS from 'constants/icons';
import React, { Fragment } from 'react'; import React, { Fragment } from 'react';
@ -144,7 +144,8 @@ function ChannelContent(props: Props) {
hideAdvancedFilter={!showFilters} hideAdvancedFilter={!showFilters}
tileLayout={tileLayout} tileLayout={tileLayout}
uris={searchResults} uris={searchResults}
channelIds={[claim.claim_id]} streamType={SIMPLE_SITE ? CS.CONTENT_ALL : undefined}
channelIds={[claimId]}
claimType={claimType} claimType={claimType}
feeAmount={CS.FEE_AMOUNT_ANY} feeAmount={CS.FEE_AMOUNT_ANY}
defaultOrderBy={CS.ORDER_BY_NEW} defaultOrderBy={CS.ORDER_BY_NEW}

View file

@ -1,5 +1,5 @@
// @flow // @flow
import { ENABLE_NO_SOURCE_CLAIMS } from 'config'; import { ENABLE_NO_SOURCE_CLAIMS, SIMPLE_SITE } from 'config';
import type { Node } from 'react'; import type { Node } from 'react';
import * as CS from 'constants/claim_search'; import * as CS from 'constants/claim_search';
import React from 'react'; import React from 'react';
@ -72,6 +72,8 @@ type Props = {
liveLivestreamsFirst?: boolean, liveLivestreamsFirst?: boolean,
livestreamMap?: { [string]: any }, livestreamMap?: { [string]: any },
hasSource?: boolean, hasSource?: boolean,
limitClaimsPerChannel?: number,
releaseTime?: string,
showNoSourceClaims?: boolean, showNoSourceClaims?: boolean,
isChannel?: boolean, isChannel?: boolean,
empty?: string, empty?: string,
@ -104,8 +106,8 @@ function ClaimListDiscover(props: Props) {
claimType, claimType,
pageSize, pageSize,
defaultClaimType, defaultClaimType,
streamType, streamType = SIMPLE_SITE ? CS.FILE_VIDEO : undefined,
defaultStreamType, defaultStreamType = SIMPLE_SITE ? CS.FILE_VIDEO : undefined, // add param for DEFAULT_STREAM_TYPE
freshness, freshness,
defaultFreshness = CS.FRESH_WEEK, defaultFreshness = CS.FRESH_WEEK,
renderProperties, renderProperties,
@ -124,6 +126,8 @@ function ClaimListDiscover(props: Props) {
forceShowReposts = false, forceShowReposts = false,
languageSetting, languageSetting,
searchInLanguage, searchInLanguage,
limitClaimsPerChannel,
releaseTime,
scrollAnchor, scrollAnchor,
showHiddenByUser = false, showHiddenByUser = false,
liveLivestreamsFirst, liveLivestreamsFirst,
@ -172,12 +176,12 @@ 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 feeAmountParam = urlParams.get('fee_amount') || feeAmount; const feeAmountParam = urlParams.get('fee_amount') || feeAmount || SIMPLE_SITE ? CS.FEE_AMOUNT_ONLY_FREE : undefined;
const originalPageSize = pageSize || CS.PAGE_SIZE; const originalPageSize = pageSize || CS.PAGE_SIZE;
const dynamicPageSize = isLargeScreen ? Math.ceil(originalPageSize * (3 / 2)) : originalPageSize; const dynamicPageSize = isLargeScreen ? Math.ceil(originalPageSize * (3 / 2)) : originalPageSize;
const historyAction = history.action; const historyAction = history.action;
let orderParam = orderBy || urlParams.get(CS.ORDER_BY_KEY) || defaultOrderBy; let orderParam = orderBy || urlParams.get(CS.ORDER_BY_KEY) || defaultOrderBy || orderParamEntry;
if (!orderParam) { if (!orderParam) {
if (historyAction === 'POP') { if (historyAction === 'POP') {
@ -221,6 +225,7 @@ function ClaimListDiscover(props: Props) {
fee_amount?: string, fee_amount?: string,
has_source?: boolean, has_source?: boolean,
has_no_source?: boolean, has_no_source?: boolean,
limit_claims_per_channel?: number,
} = { } = {
page_size: dynamicPageSize, page_size: dynamicPageSize,
page, page,
@ -243,6 +248,10 @@ function ClaimListDiscover(props: Props) {
options.has_source = true; options.has_source = true;
} }
if (limitClaimsPerChannel) {
options.limit_claims_per_channel = limitClaimsPerChannel;
}
if (feeAmountParam && claimType !== CS.CLAIM_CHANNEL) { if (feeAmountParam && claimType !== CS.CLAIM_CHANNEL) {
options.fee_amount = feeAmountParam; options.fee_amount = feeAmountParam;
} }
@ -271,8 +280,10 @@ function ClaimListDiscover(props: Props) {
// SDK chokes on reposted_claim_id of null or false, needs to not be present if no value // SDK chokes on reposted_claim_id of null or false, needs to not be present if no value
options.reposted_claim_id = repostedClaimId; options.reposted_claim_id = repostedClaimId;
} }
// IF release time, set it, else set fallback release times using the hack below.
if (claimType !== CS.CLAIM_CHANNEL) { if (releaseTime) {
options.release_time = releaseTime;
} else 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) {
@ -476,7 +487,7 @@ function ClaimListDiscover(props: Props) {
claimType={claimType} claimType={claimType}
streamType={streamType} streamType={streamType}
defaultStreamType={defaultStreamType} defaultStreamType={defaultStreamType}
feeAmount={feeAmount} feeAmount={SIMPLE_SITE ? undefined : feeAmount} // ENABLE_PAID_CONTENT_DISCOVER or something
orderBy={orderBy} orderBy={orderBy}
defaultOrderBy={defaultOrderBy} defaultOrderBy={defaultOrderBy}
hideAdvancedFilter={hideAdvancedFilter} hideAdvancedFilter={hideAdvancedFilter}

View file

@ -109,7 +109,7 @@ function ClaimMenuList(props: Props) {
const lbryUrl: string = generateLbryContentUrl(claim.canonical_url, claim.permanent_url); const lbryUrl: string = generateLbryContentUrl(claim.canonical_url, claim.permanent_url);
const shareUrl: string = generateShareUrl(SHARE_DOMAIN, lbryUrl); const shareUrl: string = generateShareUrl(SHARE_DOMAIN, lbryUrl);
const rssUrl: string = isChannel ? generateRssUrl(URL, claim) : ''; const rssUrl: string = isChannel ? generateRssUrl(SHARE_DOMAIN, claim) : '';
const isCollectionClaim = claim && claim.value_type === 'collection'; const isCollectionClaim = claim && claim.value_type === 'collection';
// $FlowFixMe // $FlowFixMe
const isPlayable = const isPlayable =

View file

@ -233,7 +233,6 @@ function ClaimPreviewTile(props: Props) {
<UriIndicator uri={uri} /> <UriIndicator uri={uri} />
</div> </div>
)} )}
{/* CHECK CLAIM MENU LIST PARAMS (IS REPOST?) */}
<ClaimMenuList uri={uri} collectionId={listId} channelUri={channelUri} isRepost={isRepost} /> <ClaimMenuList uri={uri} collectionId={listId} channelUri={channelUri} isRepost={isRepost} />
</h2> </h2>
</NavLink> </NavLink>

View file

@ -115,6 +115,7 @@ type Props = {
liveLivestreamsFirst?: boolean, liveLivestreamsFirst?: boolean,
livestreamMap?: { [string]: any }, livestreamMap?: { [string]: any },
pin?: boolean, pin?: boolean,
pinUrls?: Array<string>,
showNoSourceClaims?: boolean, showNoSourceClaims?: boolean,
}; };
@ -146,7 +147,8 @@ function ClaimTilesDiscover(props: Props) {
mutedUris, mutedUris,
liveLivestreamsFirst, liveLivestreamsFirst,
livestreamMap, livestreamMap,
// pin, // let's pin from /web folder pin, // let's pin from /web folder
pinUrls,
prefixUris, prefixUris,
showNoSourceClaims, showNoSourceClaims,
} = props; } = props;
@ -288,10 +290,24 @@ function ClaimTilesDiscover(props: Props) {
return undefined; return undefined;
}; };
const modifiedUris = uris ? uris.slice() : [];
const fixUris = pinUrls || ['lbry://@AlisonMorrow#6/LBRY#8'];
if (pin && modifiedUris && modifiedUris.length > 2 && window.location.pathname === '/') {
fixUris.forEach((fixUri) => {
if (modifiedUris.indexOf(fixUri) !== -1) {
modifiedUris.splice(modifiedUris.indexOf(fixUri), 1);
} else {
modifiedUris.pop();
}
});
modifiedUris.splice(2, 0, ...fixUris);
}
return ( return (
<ul className="claim-grid"> <ul className="claim-grid">
{uris && uris.length {modifiedUris && modifiedUris.length
? uris.map((uri, index) => ( ? modifiedUris.map((uri, index) => (
<ClaimPreviewTile key={uri} uri={uri} properties={renderProperties} live={resolveLive(index)} /> <ClaimPreviewTile key={uri} uri={uri} properties={renderProperties} live={resolveLive(index)} />
)) ))
: new Array(pageSize) : new Array(pageSize)

View file

@ -45,7 +45,7 @@ function HomePage(props: Props) {
showNsfw showNsfw
); );
function getRowElements(title, route, link, icon, help, options, index) { function getRowElements(title, route, link, icon, help, options, index, pinUrls) {
const tilePlaceholder = ( const tilePlaceholder = (
<ul className="claim-grid"> <ul className="claim-grid">
{new Array(options.pageSize || 8).fill(1).map((x, i) => ( {new Array(options.pageSize || 8).fill(1).map((x, i) => (
@ -60,6 +60,7 @@ function HomePage(props: Props) {
livestreamMap={livestreamMap} livestreamMap={livestreamMap}
showNoSourceClaims={ENABLE_NO_SOURCE_CLAIMS} showNoSourceClaims={ENABLE_NO_SOURCE_CLAIMS}
hasSource hasSource
pinUrls={pinUrls}
pin={route === `/$/${PAGES.GENERAL}`} // use pinUrls here pin={route === `/$/${PAGES.GENERAL}`} // use pinUrls here
/> />
); );
@ -140,9 +141,9 @@ function HomePage(props: Props) {
</p> </p>
</div> </div>
)} )}
{rowData.map(({ title, route, link, icon, help, options = {} }, index) => { {rowData.map(({ title, route, link, icon, help, pinUrls, options = {} }, index) => {
// add pins here // add pins here
return getRowElements(title, route, link, icon, help, options, index); return getRowElements(title, route, link, icon, help, options, index, pinUrls);
})} })}
{/* @if TARGET='web' */} {/* @if TARGET='web' */}
<Pixel type={'retargeting'} /> <Pixel type={'retargeting'} />