WildWest: limit livestream tiles + add ability to show more

Most likely this behavior will change in the future, so we'll leave `ClaimListDiscover` untouched and handle the logic at the page level.

This solution uses 2 `ClaimListDiscover` -- if the reduced livestream list is visible, it handles the header; else the normal list handles the header.
This commit is contained in:
infinite-persistence 2021-09-23 16:38:16 +08:00
parent 39c7159f2e
commit 111dc695ca
No known key found for this signature in database
GPG key ID: B9C3252EDC3D0AA0
2 changed files with 80 additions and 35 deletions

View file

@ -18,6 +18,8 @@ import I18nMessage from 'component/i18nMessage';
import moment from 'moment'; import moment from 'moment';
import { getLivestreamUris } from 'util/livestream'; import { getLivestreamUris } from 'util/livestream';
const INITIAL_LIVESTREAM_TILE_LIMIT = 8;
type Props = { type Props = {
location: { search: string }, location: { search: string },
followedTags: Array<Tag>, followedTags: Array<Tag>,
@ -29,7 +31,7 @@ type Props = {
dynamicRouteProps: RowDataItem, dynamicRouteProps: RowDataItem,
tileLayout: boolean, tileLayout: boolean,
activeLivestreams: ?LivestreamInfo, activeLivestreams: ?LivestreamInfo,
doFetchActiveLivestreams: () => void, doFetchActiveLivestreams: (orderBy?: Array<string>, pageSize?: number, forceFetch?: boolean) => void,
}; };
function DiscoverPage(props: Props) { function DiscoverPage(props: Props) {
@ -70,6 +72,40 @@ function DiscoverPage(props: Props) {
label = __('Unfollow'); label = __('Unfollow');
} }
const [showViewMoreLivestreams, setShowViewMoreLivestreams] = React.useState(!dynamicRouteProps);
const livestreamUris = getLivestreamUris(activeLivestreams, channelIds);
const useDualList = showViewMoreLivestreams && livestreamUris.length > INITIAL_LIVESTREAM_TILE_LIMIT;
function getElemMeta() {
return !dynamicRouteProps ? (
<a
className="help"
href="https://lbry.com/faq/trending"
title={__('Learn more about LBRY Credits on %DOMAIN%', { DOMAIN })}
>
<I18nMessage
tokens={{
lbc: <LbcSymbol />,
}}
>
Results boosted by %lbc%
</I18nMessage>
</a>
) : (
tag && !isMobile && (
<Button
ref={buttonRef}
button="alt"
icon={ICONS.SUBSCRIBE}
iconColor="red"
onClick={handleFollowClick}
requiresAuth={IS_WEB}
label={label}
/>
)
);
}
React.useEffect(() => { React.useEffect(() => {
if (repostedUri && !repostedClaimIsResolved) { if (repostedUri && !repostedClaimIsResolved) {
doResolveUri(repostedUri); doResolveUri(repostedUri);
@ -112,20 +148,52 @@ function DiscoverPage(props: Props) {
} }
React.useEffect(() => { React.useEffect(() => {
doFetchActiveLivestreams(); if (showViewMoreLivestreams) {
doFetchActiveLivestreams(CS.ORDER_BY_TRENDING_VALUE);
} else {
doFetchActiveLivestreams();
}
}, []); }, []);
return ( return (
<Page noFooter fullWidthPage={tileLayout}> <Page noFooter fullWidthPage={tileLayout}>
{useDualList && (
<>
<ClaimListDiscover
uris={livestreamUris.slice(0, INITIAL_LIVESTREAM_TILE_LIMIT)}
headerLabel={headerLabel}
header={repostedUri ? <span /> : undefined}
tileLayout={repostedUri ? false : tileLayout}
hideAdvancedFilter
hideFilters
infiniteScroll={false}
showNoSourceClaims={ENABLE_NO_SOURCE_CLAIMS}
meta={getElemMeta()}
/>
<div className="livestream-list--view-more">
<Button
label={__('Show more livestreams')}
button="link"
iconRight={ICONS.ARROW_RIGHT}
className="claim-grid__title--secondary"
onClick={() => {
doFetchActiveLivestreams();
setShowViewMoreLivestreams(false);
}}
/>
</div>
</>
)}
<ClaimListDiscover <ClaimListDiscover
prefixUris={getLivestreamUris(activeLivestreams, channelIds)} prefixUris={useDualList ? undefined : livestreamUris}
hideAdvancedFilter={SIMPLE_SITE} hideAdvancedFilter={SIMPLE_SITE}
hideFilters={SIMPLE_SITE ? !dynamicRouteProps : undefined} hideFilters={SIMPLE_SITE ? !dynamicRouteProps : undefined}
header={repostedUri ? <span /> : undefined} header={useDualList ? <span /> : repostedUri ? <span /> : undefined}
tileLayout={repostedUri ? false : tileLayout} tileLayout={repostedUri ? false : tileLayout}
defaultOrderBy={SIMPLE_SITE ? (dynamicRouteProps ? undefined : CS.ORDER_BY_TRENDING) : undefined} defaultOrderBy={SIMPLE_SITE ? (dynamicRouteProps ? undefined : CS.ORDER_BY_TRENDING) : undefined}
claimType={claimType ? [claimType] : undefined} claimType={claimType ? [claimType] : undefined}
headerLabel={headerLabel} headerLabel={!useDualList && headerLabel}
tags={tags} tags={tags}
hiddenNsfwMessage={<HiddenNsfw type="page" />} hiddenNsfwMessage={<HiddenNsfw type="page" />}
repostedClaimId={repostedClaim ? repostedClaim.claim_id : null} repostedClaimId={repostedClaim ? repostedClaim.claim_id : null}
@ -150,36 +218,7 @@ function DiscoverPage(props: Props) {
undefined undefined
: 3 : 3
} }
meta={ meta={!useDualList && getElemMeta()}
!dynamicRouteProps ? (
<a
className="help"
href="https://lbry.com/faq/trending"
title={__('Learn more about LBRY Credits on %DOMAIN%', { DOMAIN })}
>
<I18nMessage
tokens={{
lbc: <LbcSymbol />,
}}
>
Results boosted by %lbc%
</I18nMessage>
</a>
) : (
tag &&
!isMobile && (
<Button
ref={buttonRef}
button="alt"
icon={ICONS.SUBSCRIBE}
iconColor="red"
onClick={handleFollowClick}
requiresAuth={IS_WEB}
label={label}
/>
)
)
}
hasSource hasSource
showNoSourceClaims={ENABLE_NO_SOURCE_CLAIMS} showNoSourceClaims={ENABLE_NO_SOURCE_CLAIMS}
/> />

View file

@ -459,3 +459,9 @@ $recent-msg-button__height: 2rem;
} }
} }
} }
.livestream-list--view-more {
display: flex;
align-items: flex-end;
margin-bottom: var(--spacing-m);
}