2021-03-10 19:34:21 +01:00
|
|
|
// @flow
|
2022-01-14 21:24:16 +01:00
|
|
|
import { lazyImport } from 'util/lazyImport';
|
2021-04-23 21:59:48 +02:00
|
|
|
import { useIsMobile } from 'effects/use-screensize';
|
2022-01-14 21:24:16 +01:00
|
|
|
import FileTitleSection from 'component/fileTitleSection';
|
2021-12-16 22:59:13 +01:00
|
|
|
import LivestreamLink from 'component/livestreamLink';
|
2022-01-14 21:24:16 +01:00
|
|
|
import React from 'react';
|
2022-02-01 21:30:57 +01:00
|
|
|
import { PRIMARY_PLAYER_WRAPPER_CLASS } from 'page/file/view';
|
|
|
|
import FileRenderInitiator from 'component/fileRenderInitiator';
|
|
|
|
import LivestreamIframeRender from './iframe-render';
|
2022-02-02 13:44:33 +01:00
|
|
|
import Button from 'component/button';
|
|
|
|
import * as ICONS from 'constants/icons';
|
|
|
|
import SwipeableDrawer from 'component/swipeableDrawer';
|
2021-10-18 17:54:59 +02:00
|
|
|
|
2022-01-14 21:24:16 +01:00
|
|
|
const LivestreamChatLayout = lazyImport(() => import('component/livestreamChatLayout' /* webpackChunkName: "chat" */));
|
2021-03-10 19:34:21 +01:00
|
|
|
|
|
|
|
type Props = {
|
2022-01-14 21:24:16 +01:00
|
|
|
activeStreamUri: boolean | string,
|
2021-03-10 19:34:21 +01:00
|
|
|
claim: ?StreamClaim,
|
2021-12-16 22:59:13 +01:00
|
|
|
hideComments: boolean,
|
2022-01-14 21:24:16 +01:00
|
|
|
isCurrentClaimLive: boolean,
|
2021-12-16 22:59:13 +01:00
|
|
|
release: any,
|
|
|
|
showLivestream: boolean,
|
|
|
|
showScheduledInfo: boolean,
|
2022-01-14 21:24:16 +01:00
|
|
|
uri: string,
|
2021-03-10 19:34:21 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
export default function LivestreamLayout(props: Props) {
|
2021-12-16 22:59:13 +01:00
|
|
|
const {
|
2022-01-14 21:24:16 +01:00
|
|
|
activeStreamUri,
|
2021-12-16 22:59:13 +01:00
|
|
|
claim,
|
|
|
|
hideComments,
|
2022-01-14 21:24:16 +01:00
|
|
|
isCurrentClaimLive,
|
2021-12-16 22:59:13 +01:00
|
|
|
release,
|
|
|
|
showLivestream,
|
|
|
|
showScheduledInfo,
|
2022-01-14 21:24:16 +01:00
|
|
|
uri,
|
2021-12-16 22:59:13 +01:00
|
|
|
} = props;
|
|
|
|
|
2021-04-23 21:59:48 +02:00
|
|
|
const isMobile = useIsMobile();
|
2021-03-10 19:34:21 +01:00
|
|
|
|
2022-02-02 13:44:33 +01:00
|
|
|
const [showChat, setShowChat] = React.useState(undefined);
|
|
|
|
const drawerWasToggled = showChat !== undefined;
|
|
|
|
|
2022-01-14 21:24:16 +01:00
|
|
|
if (!claim || !claim.signing_channel) return null;
|
2021-03-10 19:34:21 +01:00
|
|
|
|
2022-01-14 21:24:16 +01:00
|
|
|
const { name: channelName, claim_id: channelClaimId } = claim.signing_channel;
|
2021-03-18 18:21:49 +01:00
|
|
|
|
2021-03-10 19:34:21 +01:00
|
|
|
return (
|
|
|
|
<>
|
|
|
|
<div className="section card-stack">
|
2022-02-01 21:30:57 +01:00
|
|
|
<React.Suspense fallback={null}>
|
|
|
|
{isMobile && isCurrentClaimLive ? (
|
|
|
|
<div className={PRIMARY_PLAYER_WRAPPER_CLASS}>
|
|
|
|
{/* Mobile needs to handle the livestream player like any video player */}
|
|
|
|
<FileRenderInitiator uri={uri} />
|
|
|
|
</div>
|
|
|
|
) : (
|
|
|
|
<LivestreamIframeRender
|
|
|
|
channelClaimId={channelClaimId}
|
|
|
|
release={release}
|
|
|
|
showLivestream={showLivestream}
|
|
|
|
showScheduledInfo={showScheduledInfo}
|
|
|
|
/>
|
|
|
|
)}
|
|
|
|
</React.Suspense>
|
2021-03-10 19:34:21 +01:00
|
|
|
|
2021-12-16 22:59:13 +01:00
|
|
|
{hideComments && !showScheduledInfo && (
|
2021-06-03 17:55:16 +02:00
|
|
|
<div className="help--notice">
|
2021-07-26 16:27:39 +02:00
|
|
|
{channelName
|
2021-09-15 04:08:41 +02:00
|
|
|
? __('%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!')}
|
2021-06-03 17:55:16 +02:00
|
|
|
</div>
|
|
|
|
)}
|
|
|
|
|
2021-12-16 22:59:13 +01:00
|
|
|
{!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
|
|
|
|
2021-12-22 17:12:44 +01:00
|
|
|
{activeStreamUri && (
|
|
|
|
<LivestreamLink
|
|
|
|
title={__("Click here to access the stream that's currently active")}
|
|
|
|
claimUri={activeStreamUri}
|
|
|
|
/>
|
|
|
|
)}
|
2021-12-16 22:59:13 +01:00
|
|
|
|
2022-01-14 21:24:16 +01:00
|
|
|
{isMobile && !hideComments && (
|
|
|
|
<React.Suspense fallback={null}>
|
2022-02-02 13:44:33 +01:00
|
|
|
<SwipeableDrawer
|
|
|
|
open={Boolean(showChat)}
|
|
|
|
toggleDrawer={() => setShowChat(!showChat)}
|
|
|
|
title={__('Live Chat')}
|
|
|
|
didInitialDisplay={drawerWasToggled}
|
|
|
|
>
|
|
|
|
<LivestreamChatLayout uri={uri} hideHeader />
|
|
|
|
</SwipeableDrawer>
|
2022-01-14 21:24:16 +01:00
|
|
|
</React.Suspense>
|
|
|
|
)}
|
2021-04-23 21:59:48 +02:00
|
|
|
|
2022-02-02 13:44:33 +01:00
|
|
|
{isMobile && (
|
|
|
|
<Button
|
|
|
|
className="swipeable-drawer__expand-button"
|
|
|
|
label="Open Live Chat"
|
|
|
|
button="primary"
|
|
|
|
icon={ICONS.CHAT}
|
|
|
|
onClick={() => setShowChat(!showChat)}
|
|
|
|
/>
|
|
|
|
)}
|
|
|
|
|
2021-12-16 22:59:13 +01:00
|
|
|
<FileTitleSection uri={uri} livestream isLive={showLivestream} />
|
2021-03-10 19:34:21 +01:00
|
|
|
</div>
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
}
|