Livestream category improvements #7115

Merged
infinite-persistence merged 15 commits from ip/category.livestream into master 2021-09-24 16:26:22 +02:00
2 changed files with 80 additions and 35 deletions
Showing only changes of commit 111dc695ca - Show all commits

View file

@ -18,6 +18,8 @@ import I18nMessage from 'component/i18nMessage';
import moment from 'moment';
import { getLivestreamUris } from 'util/livestream';
const INITIAL_LIVESTREAM_TILE_LIMIT = 8;
type Props = {
location: { search: string },
followedTags: Array<Tag>,
@ -29,7 +31,7 @@ type Props = {
dynamicRouteProps: RowDataItem,
tileLayout: boolean,
activeLivestreams: ?LivestreamInfo,
doFetchActiveLivestreams: () => void,
doFetchActiveLivestreams: (orderBy?: Array<string>, pageSize?: number, forceFetch?: boolean) => void,
};
function DiscoverPage(props: Props) {
@ -70,6 +72,40 @@ function DiscoverPage(props: Props) {
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(() => {
if (repostedUri && !repostedClaimIsResolved) {
doResolveUri(repostedUri);
@ -112,20 +148,52 @@ function DiscoverPage(props: Props) {
}
React.useEffect(() => {
if (showViewMoreLivestreams) {
doFetchActiveLivestreams(CS.ORDER_BY_TRENDING_VALUE);
} else {
doFetchActiveLivestreams();
}
}, []);
return (
<Page noFooter fullWidthPage={tileLayout}>
{useDualList && (
<>
<ClaimListDiscover
prefixUris={getLivestreamUris(activeLivestreams, channelIds)}
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
prefixUris={useDualList ? undefined : livestreamUris}
hideAdvancedFilter={SIMPLE_SITE}
hideFilters={SIMPLE_SITE ? !dynamicRouteProps : undefined}
header={repostedUri ? <span /> : undefined}
header={useDualList ? <span /> : repostedUri ? <span /> : undefined}
tileLayout={repostedUri ? false : tileLayout}
defaultOrderBy={SIMPLE_SITE ? (dynamicRouteProps ? undefined : CS.ORDER_BY_TRENDING) : undefined}
claimType={claimType ? [claimType] : undefined}
headerLabel={headerLabel}
headerLabel={!useDualList && headerLabel}
tags={tags}
hiddenNsfwMessage={<HiddenNsfw type="page" />}
repostedClaimId={repostedClaim ? repostedClaim.claim_id : null}
@ -150,36 +218,7 @@ function DiscoverPage(props: Props) {
undefined
: 3
}
meta={
!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}
/>
)
)
}
meta={!useDualList && getElemMeta()}
hasSource
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);
}