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,
|
2023-02-23 05:39:37 +03:00
|
|
|
serverStatusState,
|
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';
|
2023-02-23 05:39:37 +03:00
|
|
|
import { ServerStatus } from '../../../../interfaces/server-status.model';
|
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-02-23 05:39:37 +03:00
|
|
|
const clientStatus = useRecoilValue<ServerStatus>(serverStatusState);
|
|
|
|
|
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;
|
2023-02-23 05:39:37 +03:00
|
|
|
const { streamTitle, online } = clientStatus;
|
2022-09-11 07:16:41 +03:00
|
|
|
|
2023-02-23 05:39:37 +03:00
|
|
|
const headerText = online ? streamTitle || name : name;
|
2022-10-11 02:26:09 +03:00
|
|
|
|
2022-09-11 07:16:41 +03:00
|
|
|
return (
|
|
|
|
<div>
|
|
|
|
<ClientConfigStore />
|
2023-02-23 05:39:37 +03:00
|
|
|
<Header name={headerText} chatAvailable chatDisabled={chatDisabled} online={videoAvailable} />
|
2023-02-27 05:48:41 +03:00
|
|
|
{currentUser && (
|
|
|
|
<ChatContainer
|
|
|
|
messages={messages}
|
|
|
|
usernameToHighlight={currentUser.displayName}
|
|
|
|
chatUserId={currentUser.id}
|
|
|
|
isModerator={currentUser.isModerator}
|
|
|
|
showInput
|
|
|
|
height="80vh"
|
|
|
|
/>
|
|
|
|
)}
|
2022-09-11 07:16:41 +03:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|