lbry-desktop/ui/page/channelsFollowing/view.jsx
infinite-persistence 3900d9a049
Following Page: fix redundant livestream data passed in
Clean up for 17a9b84d

We are now using `subSection` for livestreams, so no point passing in `prefixUris`, which causes additional processing.

(It wasn't visible because `showNoSourceClaims` was removed, but processing still happens).
2022-03-21 15:03:47 +08:00

102 lines
3.2 KiB
JavaScript

// @flow
import * as PAGES from 'constants/pages';
import * as ICONS from 'constants/icons';
import * as CS from 'constants/claim_search';
import { SIMPLE_SITE } from 'config';
import React from 'react';
import ChannelsFollowingDiscoverPage from 'page/channelsFollowingDiscover';
import LivestreamSection from 'page/discover/livestreamSection';
import ClaimListDiscover from 'component/claimListDiscover';
import Page from 'component/page';
import Button from 'component/button';
import Icon from 'component/common/icon';
import { splitBySeparator } from 'util/lbryURI';
import { getLivestreamUris } from 'util/livestream';
import ScheduledStreams from 'component/scheduledStreams';
type Props = {
subscribedChannels: Array<Subscription>,
tileLayout: boolean,
activeLivestreams: ?LivestreamInfo,
doFetchActiveLivestreams: () => void,
fetchingActiveLivestreams: boolean,
hideScheduledLivestreams: boolean,
};
function ChannelsFollowingPage(props: Props) {
const {
subscribedChannels,
tileLayout,
activeLivestreams,
doFetchActiveLivestreams,
fetchingActiveLivestreams,
hideScheduledLivestreams,
} = props;
const hasSubscribedChannels = subscribedChannels.length > 0;
const channelIds = subscribedChannels.map((sub) => splitBySeparator(sub.uri)[1]);
React.useEffect(() => {
doFetchActiveLivestreams();
}, []);
return !hasSubscribedChannels ? (
<ChannelsFollowingDiscoverPage />
) : (
<Page noFooter fullWidthPage={tileLayout} className="main__channelsFollowing">
{!fetchingActiveLivestreams && (
<>
{!hideScheduledLivestreams && (
<ScheduledStreams
channelIds={channelIds}
tileLayout={tileLayout}
liveUris={getLivestreamUris(activeLivestreams, channelIds)}
limitClaimsPerChannel={2}
/>
)}
<ClaimListDiscover
hideAdvancedFilter={SIMPLE_SITE}
streamType={SIMPLE_SITE ? CS.CONTENT_ALL : undefined}
tileLayout={tileLayout}
headerLabel={
<span>
<Icon icon={ICONS.SUBSCRIBE} size={10} />
{__('Following')}
</span>
}
defaultOrderBy={CS.ORDER_BY_NEW}
channelIds={channelIds}
meta={
<>
<Button
icon={ICONS.SEARCH}
button="secondary"
label={__('Discover Channels')}
navigate={`/$/${PAGES.CHANNELS_FOLLOWING_DISCOVER}`}
/>
<Button
icon={ICONS.SETTINGS}
button="secondary"
label={__('Manage')}
navigate={`/$/${PAGES.CHANNELS_FOLLOWING_MANAGE}`}
/>
</>
}
subSection={
<LivestreamSection
tileLayout={tileLayout}
channelIds={channelIds}
activeLivestreams={activeLivestreams}
doFetchActiveLivestreams={doFetchActiveLivestreams}
/>
}
hasSource
/>
</>
)}
</Page>
);
}
export default ChannelsFollowingPage;