2021-03-10 13:34:21 -05:00
|
|
|
// @flow
|
2021-07-27 16:35:22 -04:00
|
|
|
import { LIVESTREAM_EMBED_URL } from 'constants/livestream';
|
2021-03-10 13:34:21 -05:00
|
|
|
import React from 'react';
|
2021-03-13 19:42:21 -08:00
|
|
|
import FileTitleSection from 'component/fileTitleSection';
|
2021-04-23 15:59:48 -04:00
|
|
|
import { useIsMobile } from 'effects/use-screensize';
|
2021-12-16 15:59:13 -06:00
|
|
|
import LivestreamScheduledInfo from 'component/livestreamScheduledInfo';
|
|
|
|
import classnames from 'classnames';
|
2021-10-18 23:54:59 +08:00
|
|
|
import { lazyImport } from 'util/lazyImport';
|
2021-12-16 15:59:13 -06:00
|
|
|
import LivestreamLink from 'component/livestreamLink';
|
2021-10-18 23:54:59 +08:00
|
|
|
|
|
|
|
const LivestreamComments = lazyImport(() => import('component/livestreamComments' /* webpackChunkName: "comments" */));
|
2021-03-10 13:34:21 -05:00
|
|
|
|
|
|
|
type Props = {
|
|
|
|
uri: string,
|
|
|
|
claim: ?StreamClaim,
|
2021-12-16 15:59:13 -06:00
|
|
|
hideComments: boolean,
|
|
|
|
release: any,
|
|
|
|
showLivestream: boolean,
|
|
|
|
showScheduledInfo: boolean,
|
|
|
|
isCurrentClaimLive: boolean,
|
|
|
|
activeStreamUri: boolean | string,
|
2021-03-10 13:34:21 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
export default function LivestreamLayout(props: Props) {
|
2021-12-16 15:59:13 -06:00
|
|
|
const {
|
|
|
|
claim,
|
|
|
|
uri,
|
|
|
|
hideComments,
|
|
|
|
release,
|
|
|
|
showLivestream,
|
|
|
|
showScheduledInfo,
|
|
|
|
isCurrentClaimLive,
|
|
|
|
activeStreamUri,
|
|
|
|
} = props;
|
|
|
|
|
2021-04-23 15:59:48 -04:00
|
|
|
const isMobile = useIsMobile();
|
2021-03-10 13:34:21 -05:00
|
|
|
|
2021-03-19 16:14:31 -04:00
|
|
|
if (!claim || !claim.signing_channel) {
|
2021-03-10 13:34:21 -05:00
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2021-03-19 16:14:31 -04:00
|
|
|
const channelName = claim.signing_channel.name;
|
|
|
|
const channelClaimId = claim.signing_channel.claim_id;
|
2021-03-18 13:21:49 -04:00
|
|
|
|
2021-03-10 13:34:21 -05:00
|
|
|
return (
|
|
|
|
<>
|
|
|
|
<div className="section card-stack">
|
2021-12-16 15:59:13 -06:00
|
|
|
<div
|
|
|
|
className={classnames('file-render file-render--video livestream', {
|
|
|
|
'file-render--scheduledLivestream': !showLivestream,
|
|
|
|
})}
|
|
|
|
>
|
2021-03-10 13:34:21 -05:00
|
|
|
<div className="file-viewer">
|
2021-12-16 15:59:13 -06:00
|
|
|
{showLivestream && (
|
|
|
|
<iframe
|
|
|
|
src={`${LIVESTREAM_EMBED_URL}/${channelClaimId}?skin=odysee&autoplay=1`}
|
|
|
|
scrolling="no"
|
|
|
|
allowFullScreen
|
|
|
|
/>
|
|
|
|
)}
|
|
|
|
{showScheduledInfo && <LivestreamScheduledInfo release={release} />}
|
2021-03-10 13:34:21 -05:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
2021-12-16 15:59:13 -06:00
|
|
|
{hideComments && !showScheduledInfo && (
|
2021-06-03 11:55:16 -04:00
|
|
|
<div className="help--notice">
|
2021-07-26 22:27:39 +08:00
|
|
|
{channelName
|
2021-09-15 10:08:41 +08:00
|
|
|
? __('%channel% has disabled chat for this stream. Enjoy the stream!', { channel: channelName })
|
2021-07-26 22:27:39 +08:00
|
|
|
: __('This channel has disabled chat for this stream. Enjoy the stream!')}
|
2021-06-03 11:55:16 -04:00
|
|
|
</div>
|
|
|
|
)}
|
|
|
|
|
2021-12-16 15:59:13 -06:00
|
|
|
{!activeStreamUri && !showScheduledInfo && !isCurrentClaimLive && (
|
2021-03-18 13:21:49 -04:00
|
|
|
<div className="help--notice">
|
2021-07-26 22:27:39 +08: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 13:21:49 -04:00
|
|
|
</div>
|
|
|
|
)}
|
2021-04-23 15:59:48 -04:00
|
|
|
|
2021-12-16 15:59:13 -06:00
|
|
|
{activeStreamUri && <LivestreamLink claimUri={activeStreamUri} />}
|
|
|
|
|
|
|
|
<React.Suspense fallback={null}>{isMobile && !hideComments && <LivestreamComments uri={uri} />}</React.Suspense>
|
2021-04-23 15:59:48 -04:00
|
|
|
|
2021-12-16 15:59:13 -06:00
|
|
|
<FileTitleSection uri={uri} livestream isLive={showLivestream} />
|
2021-03-10 13:34:21 -05:00
|
|
|
</div>
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
}
|