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,
|
2023-01-22 10:19:17 +03:00
|
|
|
appStateAtom,
|
2022-09-11 07:16:41 +03:00
|
|
|
} from '../../../../components/stores/ClientConfigStore';
|
|
|
|
import Header from '../../../../components/ui/Header/Header';
|
|
|
|
import { ClientConfig } from '../../../../interfaces/client-config.model';
|
2023-01-22 10:19:17 +03:00
|
|
|
import { AppStateOptions } from '../../../../components/stores/application-state';
|
2022-09-11 07:16:41 +03:00
|
|
|
|
|
|
|
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);
|
2023-01-22 10:19:17 +03:00
|
|
|
const appState = useRecoilValue<AppStateOptions>(appStateAtom);
|
2022-09-11 07:16:41 +03:00
|
|
|
|
|
|
|
const { name, chatDisabled } = clientConfig;
|
2023-01-22 10:19:17 +03:00
|
|
|
const { videoAvailable } = appState;
|
2022-09-11 07:16:41 +03:00
|
|
|
|
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 />
|
2023-01-22 10:19:17 +03:00
|
|
|
<Header name={name} chatAvailable chatDisabled={chatDisabled} online={videoAvailable} />
|
2022-09-11 07:16:41 +03:00
|
|
|
<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>
|
|
|
|
);
|
|
|
|
}
|