// @flow import 'scss/component/_swipeable-drawer.scss'; import { lazyImport } from 'util/lazyImport'; import { useIsMobile, useIsMobileLandscape } from 'effects/use-screensize'; import { Menu, MenuList, MenuButton, MenuItem } from '@reach/menu-button'; import FileTitleSection from 'component/fileTitleSection'; import LivestreamLink from 'component/livestreamLink'; import React from 'react'; import { PRIMARY_PLAYER_WRAPPER_CLASS } from 'page/file/view'; import FileRenderInitiator from 'component/fileRenderInitiator'; import LivestreamScheduledInfo from 'component/livestreamScheduledInfo'; import * as ICONS from 'constants/icons'; import SwipeableDrawer from 'component/swipeableDrawer'; import DrawerExpandButton from 'component/swipeableDrawerExpand'; import LivestreamMenu from 'component/livestreamChatLayout/livestream-menu'; import Icon from 'component/common/icon'; import CreditAmount from 'component/common/credit-amount'; import { getTipValues } from 'util/livestream'; const LivestreamChatLayout = lazyImport(() => import('component/livestreamChatLayout' /* webpackChunkName: "chat" */)); const VIEW_MODES = { CHAT: 'chat', SUPERCHAT: 'sc', }; type Props = { activeStreamUri: boolean | string, claim: ?StreamClaim, hideComments: boolean, isCurrentClaimLive: boolean, releaseTimeMs: number, showLivestream: boolean, showScheduledInfo: boolean, uri: string, superChats: Array, activeViewers?: number, }; export default function LivestreamLayout(props: Props) { const { activeStreamUri, claim, hideComments, isCurrentClaimLive, releaseTimeMs, showLivestream, showScheduledInfo, uri, superChats, activeViewers, } = props; const isMobile = useIsMobile(); const isLandscapeRotated = useIsMobileLandscape(); const [superchatsHidden, setSuperchatsHidden] = React.useState(false); const [chatViewMode, setChatViewMode] = React.useState(VIEW_MODES.CHAT); if (!claim || !claim.signing_channel) return null; const { name: channelName } = claim.signing_channel; // TODO: use this to show the 'user is not live functionality' // console.log('show livestream, currentclaimlive, activestreamurl'); // console.log(showLivestream, isCurrentClaimLive, activeStreamUri); return ( <>
} />
{hideComments && !showScheduledInfo && (
{channelName ? __('%channel% has disabled chat for this stream. Enjoy the stream!', { channel: channelName }) : __('This channel has disabled chat for this stream. Enjoy the stream!')}
)} {!activeStreamUri && !showScheduledInfo && !isCurrentClaimLive && (
{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.")}
)} {activeStreamUri !== uri && ( )} {isMobile && !isLandscapeRotated && !hideComments && ( setChatViewMode(mode)} activeViewers={activeViewers} /> } hasSubtitle={activeViewers} actions={ setSuperchatsHidden(!superchatsHidden)} isMobile /> } > setChatViewMode(mode)} /> )}
); } const ChatModeSelector = (chatSelectorProps: any) => { const { superChats, chatViewMode, setChatViewMode, activeViewers } = chatSelectorProps; const { superChatsFiatAmount, superChatsLBCAmount } = getTipValues(superChats); const titleProps = { chatViewMode, activeViewers }; if (!superChats) { return ; } return (
setChatViewMode(VIEW_MODES.CHAT)}> {__('Live Chat')} setChatViewMode(VIEW_MODES.SUPERCHAT)}>
/ {__('Tipped')}
); }; const ChatDrawerTitle = (titleProps: any) => { const { chatViewMode, activeViewers } = titleProps; return (
{chatViewMode === VIEW_MODES.CHAT ? __('Live Chat') : __('HyperChats')} {activeViewers && ( {__('%view_count% viewers', { view_count: activeViewers })} )}
); };