Add read-only chat embed page. Closes #1905

This commit is contained in:
Gabe Kangas
2022-09-04 21:46:54 -07:00
parent ab4feb9bde
commit c61bea29ee
5 changed files with 74 additions and 6 deletions

View File

@ -20,10 +20,12 @@ interface Props {
usernameToHighlight: string;
chatUserId: string;
isModerator: boolean;
showInput?: boolean;
height?: string;
}
export default function ChatContainer(props: Props) {
const { messages, usernameToHighlight, chatUserId, isModerator } = props;
const { messages, usernameToHighlight, chatUserId, isModerator, showInput, height } = props;
const [atBottom, setAtBottom] = useState(false);
// const [showButton, setShowButton] = useState(false);
@ -117,7 +119,7 @@ export default function ChatContainer(props: Props) {
() => (
<>
<Virtuoso
style={{ height: 'calc(100vh - 170px)', width: 'auto' }}
style={{ height, width: 'auto' }}
ref={chatContainerRef}
initialTopMostItemIndex={messages.length - 1} // Force alignment to bottom
data={messages}
@ -156,7 +158,7 @@ export default function ChatContainer(props: Props) {
//
}
{MessagesTable}
<ChatTextField />
{showInput && <ChatTextField />}
</div>
);
}
@ -199,3 +201,8 @@ function checkIsModerator(message) {
return scopes.includes('MODERATOR');
}
ChatContainer.defaultProps = {
showInput: true,
height: 'calc(100vh - 170px)',
};