2022-01-14 21:24:16 +01:00
|
|
|
// @flow
|
|
|
|
import 'scss/component/_livestream-chat.scss';
|
|
|
|
|
2022-02-02 13:48:24 +01:00
|
|
|
// $FlowFixMe
|
|
|
|
import { grey } from '@mui/material/colors';
|
|
|
|
|
2022-01-14 21:24:16 +01:00
|
|
|
import { useIsMobile } from 'effects/use-screensize';
|
|
|
|
import * as ICONS from 'constants/icons';
|
|
|
|
import Button from 'component/button';
|
|
|
|
import classnames from 'classnames';
|
|
|
|
import CommentCreate from 'component/commentCreate';
|
|
|
|
import CreditAmount from 'component/common/credit-amount';
|
|
|
|
import LivestreamComment from 'component/livestreamComment';
|
|
|
|
import LivestreamComments from 'component/livestreamComments';
|
|
|
|
import LivestreamSuperchats from './livestream-superchats';
|
2022-02-02 13:45:16 +01:00
|
|
|
import LivestreamMenu from './livestream-menu';
|
2022-01-14 21:24:16 +01:00
|
|
|
import React from 'react';
|
|
|
|
import Yrbl from 'component/yrbl';
|
2022-02-02 13:45:16 +01:00
|
|
|
import { getTipValues } from 'util/livestream';
|
2022-02-02 13:48:24 +01:00
|
|
|
import Slide from '@mui/material/Slide';
|
2022-03-09 19:05:37 +01:00
|
|
|
import useGetUserMemberships from 'effects/use-get-user-memberships';
|
2022-01-14 21:24:16 +01:00
|
|
|
|
2022-02-14 20:28:25 +01:00
|
|
|
export const VIEW_MODES = {
|
2022-01-14 21:24:16 +01:00
|
|
|
CHAT: 'chat',
|
|
|
|
SUPERCHAT: 'sc',
|
|
|
|
};
|
|
|
|
const COMMENT_SCROLL_TIMEOUT = 25;
|
|
|
|
|
|
|
|
type Props = {
|
|
|
|
embed?: boolean,
|
|
|
|
isPopoutWindow?: boolean,
|
|
|
|
uri: string,
|
2022-02-02 13:44:33 +01:00
|
|
|
hideHeader?: boolean,
|
2022-02-02 13:45:16 +01:00
|
|
|
superchatsHidden?: boolean,
|
|
|
|
customViewMode?: string,
|
2022-02-04 21:59:11 +01:00
|
|
|
setCustomViewMode?: (any) => void,
|
2022-02-14 20:28:25 +01:00
|
|
|
// redux
|
|
|
|
claimId?: string,
|
|
|
|
comments: Array<Comment>,
|
|
|
|
pinnedComments: Array<Comment>,
|
|
|
|
superChats: Array<Comment>,
|
|
|
|
theme: string,
|
2022-03-03 16:16:02 +01:00
|
|
|
doCommentList: (
|
|
|
|
uri: string,
|
|
|
|
parentId: ?string,
|
|
|
|
page: number,
|
|
|
|
pageSize: number,
|
|
|
|
sortBy: ?number,
|
|
|
|
isLivestream: boolean
|
|
|
|
) => void,
|
2022-02-14 20:28:25 +01:00
|
|
|
doResolveUris: (uris: Array<string>, cache: boolean) => void,
|
|
|
|
doSuperChatList: (uri: string) => void,
|
2022-03-09 19:05:37 +01:00
|
|
|
claimsByUri: { [string]: any },
|
|
|
|
doFetchUserMemberships: (claimIdCsv: string) => void,
|
2022-03-16 22:39:09 +01:00
|
|
|
setLayountRendered: (boolean) => void,
|
2022-01-14 21:24:16 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
export default function LivestreamChatLayout(props: Props) {
|
|
|
|
const {
|
2022-02-14 20:28:25 +01:00
|
|
|
claimId,
|
2022-01-14 21:24:16 +01:00
|
|
|
comments: commentsByChronologicalOrder,
|
|
|
|
embed,
|
|
|
|
isPopoutWindow,
|
|
|
|
pinnedComments,
|
|
|
|
superChats: superChatsByAmount,
|
|
|
|
uri,
|
2022-02-02 13:44:33 +01:00
|
|
|
hideHeader,
|
2022-02-02 13:45:16 +01:00
|
|
|
superchatsHidden,
|
|
|
|
customViewMode,
|
2022-02-02 13:48:24 +01:00
|
|
|
theme,
|
2022-02-04 21:59:11 +01:00
|
|
|
setCustomViewMode,
|
2022-01-14 21:24:16 +01:00
|
|
|
doCommentList,
|
|
|
|
doResolveUris,
|
|
|
|
doSuperChatList,
|
2022-03-09 19:05:37 +01:00
|
|
|
doFetchUserMemberships,
|
|
|
|
claimsByUri,
|
2022-03-16 22:39:09 +01:00
|
|
|
setLayountRendered,
|
2022-01-14 21:24:16 +01:00
|
|
|
} = props;
|
|
|
|
|
2022-02-02 13:48:24 +01:00
|
|
|
const isMobile = useIsMobile() && !isPopoutWindow;
|
2022-01-14 21:24:16 +01:00
|
|
|
|
2022-02-04 21:59:11 +01:00
|
|
|
const webElement = document.querySelector('.livestream__comments');
|
|
|
|
const mobileElement = document.querySelector('.livestream__comments--mobile');
|
|
|
|
const discussionElement = isMobile ? mobileElement : webElement;
|
|
|
|
const allCommentsElem = document.querySelectorAll('.livestream__comment');
|
|
|
|
const lastCommentElem = allCommentsElem && allCommentsElem[allCommentsElem.length - 1];
|
2022-01-14 21:24:16 +01:00
|
|
|
|
|
|
|
const [viewMode, setViewMode] = React.useState(VIEW_MODES.CHAT);
|
|
|
|
const [scrollPos, setScrollPos] = React.useState(0);
|
|
|
|
const [showPinned, setShowPinned] = React.useState(true);
|
|
|
|
const [resolvingSuperChats, setResolvingSuperChats] = React.useState(false);
|
|
|
|
const [openedPopoutWindow, setPopoutWindow] = React.useState(undefined);
|
|
|
|
const [chatHidden, setChatHidden] = React.useState(false);
|
2022-02-04 21:59:11 +01:00
|
|
|
const [didInitialScroll, setDidInitialScroll] = React.useState(false);
|
2022-02-07 18:05:34 +01:00
|
|
|
const [minScrollHeight, setMinScrollHeight] = React.useState(0);
|
2022-02-08 17:49:46 +01:00
|
|
|
const [keyboardOpened, setKeyboardOpened] = React.useState(false);
|
2022-02-14 20:28:25 +01:00
|
|
|
const [superchatsAmount, setSuperchatsAmount] = React.useState(false);
|
|
|
|
const [chatElement, setChatElement] = React.useState();
|
2022-01-14 21:24:16 +01:00
|
|
|
|
2022-02-15 20:28:06 +01:00
|
|
|
let superChatsByChronologicalOrder = [];
|
|
|
|
if (superChatsByAmount) superChatsByAmount.forEach((chat) => superChatsByChronologicalOrder.push(chat));
|
|
|
|
if (superChatsByChronologicalOrder.length > 0) {
|
|
|
|
superChatsByChronologicalOrder.sort((a, b) => b.timestamp - a.timestamp);
|
|
|
|
}
|
|
|
|
|
2022-03-09 19:05:37 +01:00
|
|
|
// get commenter claim ids for checking premium status
|
2022-03-15 17:18:08 +01:00
|
|
|
const commenterClaimIds = commentsByChronologicalOrder.map((comment) => {
|
2022-03-09 19:05:37 +01:00
|
|
|
return comment.channel_id;
|
|
|
|
});
|
|
|
|
|
|
|
|
// update premium status
|
|
|
|
const shouldFetchUserMemberships = true;
|
|
|
|
useGetUserMemberships(
|
|
|
|
shouldFetchUserMemberships,
|
|
|
|
commenterClaimIds,
|
|
|
|
claimsByUri,
|
|
|
|
doFetchUserMemberships,
|
|
|
|
[commentsByChronologicalOrder],
|
2022-03-15 17:18:08 +01:00
|
|
|
true
|
2022-03-09 19:05:37 +01:00
|
|
|
);
|
|
|
|
|
2022-02-14 20:28:25 +01:00
|
|
|
const commentsToDisplay =
|
|
|
|
viewMode === VIEW_MODES.CHAT ? commentsByChronologicalOrder : superChatsByChronologicalOrder;
|
2022-01-14 21:24:16 +01:00
|
|
|
const commentsLength = commentsToDisplay && commentsToDisplay.length;
|
|
|
|
const pinnedComment = pinnedComments.length > 0 ? pinnedComments[0] : null;
|
2022-02-14 20:28:25 +01:00
|
|
|
const { superChatsChannelUrls, superChatsFiatAmount, superChatsLBCAmount } = getTipValues(
|
|
|
|
superChatsByChronologicalOrder
|
|
|
|
);
|
2022-02-08 14:12:03 +01:00
|
|
|
const scrolledPastRecent = Boolean(
|
2022-02-14 20:28:25 +01:00
|
|
|
(viewMode !== VIEW_MODES.SUPERCHAT || !resolvingSuperChats) &&
|
|
|
|
(!isMobile ? scrollPos < 0 : scrollPos < minScrollHeight)
|
2022-02-05 02:44:54 +01:00
|
|
|
);
|
|
|
|
|
|
|
|
const restoreScrollPos = React.useCallback(() => {
|
|
|
|
if (discussionElement) {
|
|
|
|
discussionElement.scrollTop = !isMobile ? 0 : discussionElement.scrollHeight;
|
2022-02-08 14:12:03 +01:00
|
|
|
|
|
|
|
if (isMobile) {
|
|
|
|
const pos = lastCommentElem && discussionElement.scrollTop - lastCommentElem.getBoundingClientRect().height;
|
|
|
|
|
|
|
|
if (!minScrollHeight || minScrollHeight !== pos) {
|
|
|
|
setMinScrollHeight(pos);
|
|
|
|
}
|
|
|
|
}
|
2022-02-05 02:44:54 +01:00
|
|
|
}
|
2022-02-08 14:12:03 +01:00
|
|
|
}, [discussionElement, isMobile, lastCommentElem, minScrollHeight]);
|
2022-02-05 02:44:54 +01:00
|
|
|
|
2022-02-14 20:28:25 +01:00
|
|
|
function toggleClick(toggleMode: string) {
|
|
|
|
if (toggleMode === VIEW_MODES.SUPERCHAT) {
|
|
|
|
toggleSuperChat();
|
|
|
|
} else {
|
|
|
|
setViewMode(VIEW_MODES.CHAT);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (discussionElement) {
|
|
|
|
discussionElement.scrollTop = 0;
|
|
|
|
}
|
|
|
|
}
|
2022-01-14 21:24:16 +01:00
|
|
|
|
|
|
|
function toggleSuperChat() {
|
2022-02-14 20:28:25 +01:00
|
|
|
const hasNewSuperchats = !superchatsAmount || superChatsChannelUrls.length !== superchatsAmount;
|
2022-01-14 21:24:16 +01:00
|
|
|
|
2022-02-14 20:28:25 +01:00
|
|
|
if (superChatsChannelUrls && hasNewSuperchats) {
|
|
|
|
setSuperchatsAmount(superChatsChannelUrls.length);
|
|
|
|
doResolveUris(superChatsChannelUrls, false);
|
2022-01-14 21:24:16 +01:00
|
|
|
}
|
2022-02-14 20:28:25 +01:00
|
|
|
|
2022-01-14 21:24:16 +01:00
|
|
|
setViewMode(VIEW_MODES.SUPERCHAT);
|
2022-02-04 21:59:11 +01:00
|
|
|
if (setCustomViewMode) setCustomViewMode(VIEW_MODES.SUPERCHAT);
|
2022-01-14 21:24:16 +01:00
|
|
|
}
|
|
|
|
|
2022-03-16 22:39:09 +01:00
|
|
|
React.useEffect(() => {
|
|
|
|
if (setLayountRendered) setLayountRendered(true);
|
|
|
|
}, [setLayountRendered]);
|
|
|
|
|
2022-02-02 13:45:16 +01:00
|
|
|
React.useEffect(() => {
|
|
|
|
if (customViewMode && customViewMode !== viewMode) {
|
|
|
|
setViewMode(customViewMode);
|
|
|
|
}
|
|
|
|
}, [customViewMode, viewMode]);
|
2022-01-14 21:24:16 +01:00
|
|
|
|
|
|
|
React.useEffect(() => {
|
|
|
|
if (claimId) {
|
2022-03-03 16:16:02 +01:00
|
|
|
doCommentList(uri, undefined, 1, 75, undefined, true);
|
2022-01-14 21:24:16 +01:00
|
|
|
doSuperChatList(uri);
|
|
|
|
}
|
|
|
|
}, [claimId, uri, doCommentList, doSuperChatList]);
|
|
|
|
|
2022-02-04 21:59:11 +01:00
|
|
|
React.useEffect(() => {
|
2022-02-14 20:28:25 +01:00
|
|
|
if (isMobile && !didInitialScroll) {
|
2022-02-08 14:12:03 +01:00
|
|
|
restoreScrollPos();
|
2022-02-04 21:59:11 +01:00
|
|
|
setDidInitialScroll(true);
|
|
|
|
}
|
2022-02-08 14:12:03 +01:00
|
|
|
}, [didInitialScroll, isMobile, restoreScrollPos, viewMode]);
|
2022-02-04 21:59:11 +01:00
|
|
|
|
2022-02-14 20:28:25 +01:00
|
|
|
React.useEffect(() => {
|
|
|
|
if (discussionElement && !openedPopoutWindow) setChatElement(discussionElement);
|
|
|
|
}, [discussionElement, openedPopoutWindow]);
|
|
|
|
|
2022-01-14 21:24:16 +01:00
|
|
|
// Register scroll handler (TODO: Should throttle/debounce)
|
|
|
|
React.useEffect(() => {
|
|
|
|
function handleScroll() {
|
2022-02-14 20:28:25 +01:00
|
|
|
if (chatElement) {
|
|
|
|
const scrollTop = chatElement.scrollTop;
|
2022-02-07 18:05:34 +01:00
|
|
|
|
2022-02-08 17:49:46 +01:00
|
|
|
if (scrollTop !== scrollPos) {
|
2022-01-14 21:24:16 +01:00
|
|
|
setScrollPos(scrollTop);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-02-14 20:28:25 +01:00
|
|
|
if (chatElement) {
|
|
|
|
chatElement.addEventListener('scroll', handleScroll);
|
|
|
|
|
|
|
|
return () => chatElement.removeEventListener('scroll', handleScroll);
|
2022-01-14 21:24:16 +01:00
|
|
|
}
|
2022-02-14 20:28:25 +01:00
|
|
|
}, [chatElement, scrollPos]);
|
2022-01-14 21:24:16 +01:00
|
|
|
|
|
|
|
// Retain scrollPos=0 when receiving new messages.
|
|
|
|
React.useEffect(() => {
|
|
|
|
if (discussionElement && commentsLength > 0) {
|
|
|
|
// Only update comment scroll if the user hasn't scrolled up to view old comments
|
2022-02-04 21:59:11 +01:00
|
|
|
// $FlowFixMe
|
2022-02-07 18:05:34 +01:00
|
|
|
if (scrollPos && (!isMobile || minScrollHeight) && scrollPos >= minScrollHeight) {
|
2022-01-14 21:24:16 +01:00
|
|
|
// +ve scrollPos: not scrolled (Usually, there'll be a few pixels beyond 0).
|
|
|
|
// -ve scrollPos: user scrolled.
|
|
|
|
const timer = setTimeout(() => {
|
|
|
|
// Use a timer here to ensure we reset after the new comment has been rendered.
|
2022-02-08 17:49:46 +01:00
|
|
|
if (!isMobile) {
|
|
|
|
discussionElement.scrollTop = 0;
|
|
|
|
} else {
|
|
|
|
restoreScrollPos();
|
|
|
|
}
|
2022-01-14 21:24:16 +01:00
|
|
|
}, COMMENT_SCROLL_TIMEOUT);
|
|
|
|
return () => clearTimeout(timer);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
|
|
}, [commentsLength]); // (Just respond to 'commentsLength' updates and nothing else)
|
|
|
|
|
2022-02-08 17:49:46 +01:00
|
|
|
// Restore Scroll Pos after mobile input opens keyboard and avoid scroll height conflicts
|
|
|
|
React.useEffect(() => {
|
|
|
|
if (keyboardOpened) {
|
|
|
|
const timer = setTimeout(() => {
|
|
|
|
restoreScrollPos();
|
|
|
|
setKeyboardOpened(false);
|
|
|
|
}, 300);
|
|
|
|
|
|
|
|
return () => clearTimeout(timer);
|
|
|
|
}
|
|
|
|
}, [keyboardOpened, restoreScrollPos]);
|
|
|
|
|
2022-02-14 20:28:25 +01:00
|
|
|
if (!claimId) return null;
|
2022-01-14 21:24:16 +01:00
|
|
|
|
|
|
|
if (openedPopoutWindow || chatHidden) {
|
|
|
|
return (
|
|
|
|
<div className="card livestream__chat">
|
|
|
|
<div className="card__header--between livestreamDiscussion__header">
|
|
|
|
<div className="card__title-section--small livestreamDiscussion__title">{__('Live Chat')}</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div className="livestreamComments__wrapper">
|
|
|
|
<div className="main--empty">
|
|
|
|
<Yrbl
|
|
|
|
title={__('Chat Hidden')}
|
|
|
|
actions={
|
|
|
|
<div className="section__actions">
|
|
|
|
{openedPopoutWindow && (
|
|
|
|
<Button button="secondary" label={__('Close Popout')} onClick={() => openedPopoutWindow.close()} />
|
|
|
|
)}
|
|
|
|
|
|
|
|
{chatHidden && (
|
|
|
|
<Button button="secondary" label={__('Show Chat')} onClick={() => setChatHidden(false)} />
|
|
|
|
)}
|
|
|
|
</div>
|
|
|
|
}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
|
2022-02-02 13:47:04 +01:00
|
|
|
<div className="livestream__comment-create">
|
2022-01-14 21:24:16 +01:00
|
|
|
<CommentCreate isLivestream bottom uri={uri} disableInput />
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
2022-02-07 21:37:22 +01:00
|
|
|
|
2022-02-14 20:28:25 +01:00
|
|
|
const toggleProps = { viewMode, onClick: (toggleMode) => toggleClick(toggleMode) };
|
|
|
|
|
2022-01-14 21:24:16 +01:00
|
|
|
return (
|
|
|
|
<div className={classnames('card livestream__chat', { 'livestream__chat--popout': isPopoutWindow })}>
|
2022-02-02 13:44:33 +01:00
|
|
|
{!hideHeader && (
|
|
|
|
<div className="card__header--between livestreamDiscussion__header">
|
|
|
|
<div className="card__title-section--small livestreamDiscussion__title">
|
|
|
|
{__('Live Chat')}
|
|
|
|
|
2022-02-02 13:45:16 +01:00
|
|
|
<LivestreamMenu
|
|
|
|
isPopoutWindow={isPopoutWindow}
|
|
|
|
hideChat={() => setChatHidden(true)}
|
|
|
|
setPopoutWindow={(v) => setPopoutWindow(v)}
|
2022-02-02 13:48:24 +01:00
|
|
|
isMobile={isMobile}
|
2022-02-02 13:45:16 +01:00
|
|
|
/>
|
2022-02-02 13:44:33 +01:00
|
|
|
</div>
|
|
|
|
|
2022-02-14 20:28:25 +01:00
|
|
|
{superChatsByChronologicalOrder && (
|
2022-02-02 13:44:33 +01:00
|
|
|
<div className="recommended-content__toggles">
|
|
|
|
{/* the superchats in chronological order button */}
|
2022-02-14 20:28:25 +01:00
|
|
|
<ChatContentToggle {...toggleProps} toggleMode={VIEW_MODES.CHAT} label={__('Chat')} />
|
2022-02-02 13:44:33 +01:00
|
|
|
|
|
|
|
{/* the button to show superchats listed by most to least support amount */}
|
2022-02-14 20:28:25 +01:00
|
|
|
<ChatContentToggle
|
|
|
|
{...toggleProps}
|
|
|
|
toggleMode={VIEW_MODES.SUPERCHAT}
|
|
|
|
label={
|
|
|
|
<>
|
|
|
|
<CreditAmount amount={superChatsLBCAmount || 0} size={8} /> /
|
|
|
|
<CreditAmount amount={superChatsFiatAmount || 0} size={8} isFiat /> {__('Tipped')}
|
|
|
|
</>
|
|
|
|
}
|
|
|
|
/>
|
2022-02-02 13:44:33 +01:00
|
|
|
</div>
|
|
|
|
)}
|
2022-01-14 21:24:16 +01:00
|
|
|
</div>
|
2022-02-02 13:44:33 +01:00
|
|
|
)}
|
2022-01-14 21:24:16 +01:00
|
|
|
|
2022-02-14 20:28:25 +01:00
|
|
|
<div className="livestreamComments__wrapper">
|
2022-02-02 13:48:24 +01:00
|
|
|
<div
|
|
|
|
className={classnames('livestream-comments__top-actions', {
|
|
|
|
'livestream-comments__top-actions--mobile': isMobile,
|
|
|
|
})}
|
|
|
|
>
|
2022-02-15 20:28:06 +01:00
|
|
|
{isMobile && ((pinnedComment && showPinned) || (superChatsByAmount && !superchatsHidden)) && (
|
2022-02-02 13:48:24 +01:00
|
|
|
<MobileDrawerTopGradient theme={theme} />
|
2022-02-02 13:45:16 +01:00
|
|
|
)}
|
2022-01-14 21:24:16 +01:00
|
|
|
|
2022-02-15 20:28:06 +01:00
|
|
|
{viewMode === VIEW_MODES.CHAT && superChatsByAmount && (
|
2022-02-02 13:48:24 +01:00
|
|
|
<LivestreamSuperchats
|
2022-02-15 20:28:06 +01:00
|
|
|
superChats={superChatsByAmount}
|
2022-02-02 13:48:24 +01:00
|
|
|
toggleSuperChat={toggleSuperChat}
|
|
|
|
superchatsHidden={superchatsHidden}
|
|
|
|
isMobile={isMobile}
|
|
|
|
/>
|
2022-02-02 13:45:16 +01:00
|
|
|
)}
|
2022-02-02 13:48:24 +01:00
|
|
|
|
|
|
|
{pinnedComment &&
|
|
|
|
viewMode === VIEW_MODES.CHAT &&
|
|
|
|
(isMobile ? (
|
|
|
|
<Slide direction="left" in={showPinned} mountOnEnter unmountOnExit>
|
|
|
|
<div className="livestream-pinned__wrapper--mobile">
|
|
|
|
<LivestreamComment
|
|
|
|
comment={pinnedComment}
|
|
|
|
key={pinnedComment.comment_id}
|
|
|
|
uri={uri}
|
|
|
|
handleDismissPin={() => setShowPinned(false)}
|
|
|
|
isMobile
|
2022-02-14 20:28:25 +01:00
|
|
|
setResolvingSuperChats={setResolvingSuperChats}
|
2022-02-02 13:48:24 +01:00
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</Slide>
|
|
|
|
) : (
|
|
|
|
showPinned && (
|
|
|
|
<div className="livestream-pinned__wrapper">
|
2022-02-04 21:59:11 +01:00
|
|
|
<LivestreamComment comment={pinnedComment} key={pinnedComment.comment_id} uri={uri} />
|
2022-02-02 13:48:24 +01:00
|
|
|
|
|
|
|
<Button
|
|
|
|
title={__('Dismiss pinned comment')}
|
|
|
|
button="inverse"
|
|
|
|
className="close-button"
|
|
|
|
onClick={() => setShowPinned(false)}
|
|
|
|
icon={ICONS.REMOVE}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
))}
|
2022-02-02 13:45:16 +01:00
|
|
|
</div>
|
2022-01-14 21:24:16 +01:00
|
|
|
|
2022-02-14 20:28:25 +01:00
|
|
|
<LivestreamComments
|
|
|
|
uri={uri}
|
|
|
|
viewMode={viewMode}
|
|
|
|
comments={commentsToDisplay}
|
|
|
|
isMobile={isMobile}
|
|
|
|
restoreScrollPos={!scrolledPastRecent && isMobile && restoreScrollPos}
|
|
|
|
/>
|
2022-01-14 21:24:16 +01:00
|
|
|
|
2022-02-14 20:28:25 +01:00
|
|
|
{scrolledPastRecent && (
|
2022-01-14 21:24:16 +01:00
|
|
|
<Button
|
|
|
|
button="secondary"
|
2022-02-04 21:59:11 +01:00
|
|
|
className="livestream-comments__scroll-to-recent"
|
2022-01-14 21:24:16 +01:00
|
|
|
label={viewMode === VIEW_MODES.CHAT ? __('Recent Comments') : __('Recent Tips')}
|
|
|
|
onClick={restoreScrollPos}
|
|
|
|
iconRight={ICONS.DOWN}
|
|
|
|
/>
|
2022-02-14 20:28:25 +01:00
|
|
|
)}
|
2022-01-14 21:24:16 +01:00
|
|
|
|
2022-02-02 13:47:04 +01:00
|
|
|
<div className="livestream__comment-create">
|
2022-02-08 17:49:46 +01:00
|
|
|
<CommentCreate
|
|
|
|
isLivestream
|
|
|
|
bottom
|
|
|
|
embed={embed}
|
|
|
|
uri={uri}
|
|
|
|
onDoneReplying={restoreScrollPos}
|
|
|
|
onSlimInputClose={!scrolledPastRecent && isMobile ? () => setKeyboardOpened(true) : undefined}
|
|
|
|
/>
|
2022-01-14 21:24:16 +01:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
2022-02-02 13:48:24 +01:00
|
|
|
|
2022-02-14 20:28:25 +01:00
|
|
|
type ToggleProps = {
|
|
|
|
viewMode: string,
|
|
|
|
toggleMode: string,
|
|
|
|
label: string | any,
|
|
|
|
onClick: (string) => void,
|
|
|
|
};
|
|
|
|
|
|
|
|
const ChatContentToggle = (props: ToggleProps) => {
|
|
|
|
const { viewMode, toggleMode, label, onClick } = props;
|
|
|
|
|
|
|
|
return (
|
|
|
|
<Button
|
|
|
|
className={classnames('button-toggle', { 'button-toggle--active': viewMode === toggleMode })}
|
|
|
|
label={label}
|
|
|
|
onClick={() => onClick(toggleMode)}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
2022-02-02 13:48:24 +01:00
|
|
|
type GradientProps = {
|
|
|
|
theme: string,
|
|
|
|
};
|
|
|
|
|
|
|
|
const MobileDrawerTopGradient = (gradientProps: GradientProps) => {
|
|
|
|
const { theme } = gradientProps;
|
|
|
|
|
2022-02-14 20:28:25 +01:00
|
|
|
return (
|
|
|
|
<div
|
|
|
|
style={{
|
|
|
|
background: `linear-gradient(180deg, ${theme === 'light' ? grey[300] : grey[900]} 0, transparent 65%)`,
|
2022-02-02 13:48:24 +01:00
|
|
|
}}
|
2022-02-14 20:28:25 +01:00
|
|
|
className="livestream__top-gradient"
|
2022-02-02 13:48:24 +01:00
|
|
|
/>
|
|
|
|
);
|
|
|
|
};
|