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
No known key found for this signature in database
GPG Key ID: 9A56337728BC81EA
5 changed files with 74 additions and 6 deletions

View File

@ -6,6 +6,7 @@ module.exports = {
'../.storybook/stories-category-doc-pages/**/*.stories.mdx',
'../stories/**/*.stories.@(js|jsx|ts|tsx)',
'../components/**/*.stories.@(js|jsx|ts|tsx)',
'../pages/**/*.stories.@(js|jsx|ts|tsx)',
],
addons: [
'@storybook/addon-links',

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)',
};

View File

@ -1,3 +0,0 @@
export default function ReadOnlyChatEmbed() {
return <div className="chat-embed">chat container goes here</div>;
}

View File

@ -0,0 +1,29 @@
import { useRecoilValue } from 'recoil';
import { ChatMessage } from '../../../../interfaces/chat-message.model';
import ChatContainer from '../../../../components/chat/ChatContainer/ChatContainer';
import {
ClientConfigStore,
chatDisplayNameAtom,
chatUserIdAtom,
visibleChatMessagesSelector,
} from '../../../../components/stores/ClientConfigStore';
export default function ReadOnlyChatEmbed() {
const chatDisplayName = useRecoilValue<string>(chatDisplayNameAtom);
const chatUserId = useRecoilValue<string>(chatUserIdAtom);
const messages = useRecoilValue<ChatMessage[]>(visibleChatMessagesSelector);
return (
<div>
<ClientConfigStore />
<ChatContainer
messages={messages}
usernameToHighlight={chatDisplayName}
chatUserId={chatUserId}
isModerator={false}
showInput={false}
height="100vh"
/>
</div>
);
}

File diff suppressed because one or more lines are too long