lbry-desktop/ui/component/livestreamLayout/view.jsx

97 lines
3 KiB
React
Raw Normal View History

// @flow
2021-07-27 22:35:22 +02:00
import { LIVESTREAM_EMBED_URL } from 'constants/livestream';
import React from 'react';
2021-03-14 04:42:21 +01:00
import FileTitleSection from 'component/fileTitleSection';
2021-04-23 21:59:48 +02:00
import { useIsMobile } from 'effects/use-screensize';
import LivestreamScheduledInfo from 'component/livestreamScheduledInfo';
import classnames from 'classnames';
import { lazyImport } from 'util/lazyImport';
import LivestreamLink from 'component/livestreamLink';
const LivestreamComments = lazyImport(() => import('component/livestreamComments' /* webpackChunkName: "comments" */));
type Props = {
uri: string,
claim: ?StreamClaim,
hideComments: boolean,
release: any,
showLivestream: boolean,
showScheduledInfo: boolean,
isCurrentClaimLive: boolean,
activeStreamUri: boolean | string,
};
export default function LivestreamLayout(props: Props) {
const {
claim,
uri,
hideComments,
release,
showLivestream,
showScheduledInfo,
isCurrentClaimLive,
activeStreamUri,
} = props;
2021-04-23 21:59:48 +02:00
const isMobile = useIsMobile();
2021-03-19 21:14:31 +01:00
if (!claim || !claim.signing_channel) {
return null;
}
2021-03-19 21:14:31 +01:00
const channelName = claim.signing_channel.name;
const channelClaimId = claim.signing_channel.claim_id;
2021-03-18 18:21:49 +01:00
return (
<>
<div className="section card-stack">
<div
className={classnames('file-render file-render--video livestream', {
'file-render--scheduledLivestream': !showLivestream,
})}
>
<div className="file-viewer">
{showLivestream && (
<iframe
src={`${LIVESTREAM_EMBED_URL}/${channelClaimId}?skin=odysee&autoplay=1`}
scrolling="no"
allowFullScreen
/>
)}
{showScheduledInfo && <LivestreamScheduledInfo release={release} />}
</div>
</div>
{hideComments && !showScheduledInfo && (
<div className="help--notice">
2021-07-26 16:27:39 +02:00
{channelName
? __('%channel% has disabled chat for this stream. Enjoy the stream!', { channel: channelName })
2021-07-26 16:27:39 +02:00
: __('This channel has disabled chat for this stream. Enjoy the stream!')}
</div>
)}
{!activeStreamUri && !showScheduledInfo && !isCurrentClaimLive && (
2021-03-18 18:21:49 +01:00
<div className="help--notice">
2021-07-26 16:27:39 +02:00
{channelName
? __("%channelName% isn't live right now, but the chat is! Check back later to watch the stream.", {
channelName,
})
: __("This channel isn't live right now, but the chat is! Check back later to watch the stream.")}
2021-03-18 18:21:49 +01:00
</div>
)}
2021-04-23 21:59:48 +02:00
{activeStreamUri && (
<LivestreamLink
title={__("Click here to access the stream that's currently active")}
claimUri={activeStreamUri}
/>
)}
<React.Suspense fallback={null}>{isMobile && !hideComments && <LivestreamComments uri={uri} />}</React.Suspense>
2021-04-23 21:59:48 +02:00
<FileTitleSection uri={uri} livestream isLive={showLivestream} />
</div>
</>
);
}