2022-09-05 07:46:54 +03:00
|
|
|
import { useRecoilValue } from 'recoil';
|
2023-05-07 00:11:09 +03:00
|
|
|
import { ErrorBoundary } from 'react-error-boundary';
|
2022-09-05 07:46:54 +03:00
|
|
|
import { ChatMessage } from '../../../../interfaces/chat-message.model';
|
2022-09-07 10:00:28 +03:00
|
|
|
import { ChatContainer } from '../../../../components/chat/ChatContainer/ChatContainer';
|
2022-09-05 07:46:54 +03:00
|
|
|
import {
|
|
|
|
ClientConfigStore,
|
2022-10-11 02:26:09 +03:00
|
|
|
currentUserAtom,
|
2022-09-05 07:46:54 +03:00
|
|
|
visibleChatMessagesSelector,
|
2023-03-02 03:19:02 +03:00
|
|
|
isChatAvailableSelector,
|
2022-09-05 07:46:54 +03:00
|
|
|
} from '../../../../components/stores/ClientConfigStore';
|
2023-05-05 22:21:20 +03:00
|
|
|
import { Theme } from '../../../../components/theme/Theme';
|
2023-05-07 00:11:09 +03:00
|
|
|
import { ComponentError } from '../../../../components/ui/ComponentError/ComponentError';
|
2022-09-05 07:46:54 +03:00
|
|
|
|
|
|
|
export default function ReadOnlyChatEmbed() {
|
2022-10-11 02:26:09 +03:00
|
|
|
const currentUser = useRecoilValue(currentUserAtom);
|
2022-09-05 07:46:54 +03:00
|
|
|
const messages = useRecoilValue<ChatMessage[]>(visibleChatMessagesSelector);
|
2023-03-02 03:19:02 +03:00
|
|
|
const isChatAvailable = useRecoilValue(isChatAvailableSelector);
|
2023-02-27 05:48:41 +03:00
|
|
|
|
2022-09-05 07:46:54 +03:00
|
|
|
return (
|
|
|
|
<div>
|
2023-05-07 00:11:09 +03:00
|
|
|
<ErrorBoundary
|
|
|
|
// eslint-disable-next-line react/no-unstable-nested-components
|
|
|
|
fallbackRender={({ error }) => (
|
|
|
|
<ComponentError componentName="ReadWriteChatEmbed" message={error.message} />
|
|
|
|
)}
|
|
|
|
>
|
|
|
|
<ClientConfigStore />
|
|
|
|
<Theme />
|
|
|
|
{currentUser && (
|
|
|
|
<ChatContainer
|
|
|
|
messages={messages}
|
|
|
|
usernameToHighlight={currentUser.displayName}
|
|
|
|
chatUserId={currentUser.id}
|
|
|
|
isModerator={false}
|
|
|
|
showInput={false}
|
|
|
|
height="100vh"
|
|
|
|
chatAvailable={isChatAvailable}
|
|
|
|
/>
|
|
|
|
)}
|
|
|
|
</ErrorBoundary>
|
2022-09-05 07:46:54 +03:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|