2022-09-11 07:16:41 +03:00
|
|
|
import { useRecoilValue } from 'recoil';
|
|
|
|
import { ChatMessage } from '../../../../interfaces/chat-message.model';
|
|
|
|
import { ChatContainer } from '../../../../components/chat/ChatContainer/ChatContainer';
|
|
|
|
import {
|
|
|
|
ClientConfigStore,
|
2022-10-11 02:26:09 +03:00
|
|
|
currentUserAtom,
|
2022-09-11 07:16:41 +03:00
|
|
|
visibleChatMessagesSelector,
|
|
|
|
clientConfigStateAtom,
|
|
|
|
} from '../../../../components/stores/ClientConfigStore';
|
|
|
|
import Header from '../../../../components/ui/Header/Header';
|
|
|
|
import { ClientConfig } from '../../../../interfaces/client-config.model';
|
|
|
|
|
|
|
|
export default function ReadWriteChatEmbed() {
|
2022-10-11 02:26:09 +03:00
|
|
|
const currentUser = useRecoilValue(currentUserAtom);
|
2022-09-11 07:16:41 +03:00
|
|
|
const messages = useRecoilValue<ChatMessage[]>(visibleChatMessagesSelector);
|
|
|
|
const clientConfig = useRecoilValue<ClientConfig>(clientConfigStateAtom);
|
|
|
|
|
|
|
|
const { name, chatDisabled } = clientConfig;
|
|
|
|
|
2022-10-11 02:26:09 +03:00
|
|
|
if (!currentUser) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
const { id, displayName, isModerator } = currentUser;
|
|
|
|
|
2022-09-11 07:16:41 +03:00
|
|
|
return (
|
|
|
|
<div>
|
|
|
|
<ClientConfigStore />
|
|
|
|
<Header name={name} chatAvailable chatDisabled={chatDisabled} />
|
|
|
|
<ChatContainer
|
|
|
|
messages={messages}
|
2022-10-11 02:26:09 +03:00
|
|
|
usernameToHighlight={displayName}
|
|
|
|
chatUserId={id}
|
2022-09-11 07:16:41 +03:00
|
|
|
isModerator={isModerator}
|
|
|
|
showInput
|
|
|
|
height="80vh"
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|