Add current user object that holds user session values instead of standalone getters. Closes #2050
This commit is contained in:
@@ -3,23 +3,24 @@ import { ChatMessage } from '../../../../interfaces/chat-message.model';
|
||||
import { ChatContainer } from '../../../../components/chat/ChatContainer/ChatContainer';
|
||||
import {
|
||||
ClientConfigStore,
|
||||
chatDisplayNameAtom,
|
||||
chatUserIdAtom,
|
||||
currentUserAtom,
|
||||
visibleChatMessagesSelector,
|
||||
} from '../../../../components/stores/ClientConfigStore';
|
||||
|
||||
export default function ReadOnlyChatEmbed() {
|
||||
const chatDisplayName = useRecoilValue<string>(chatDisplayNameAtom);
|
||||
const chatUserId = useRecoilValue<string>(chatUserIdAtom);
|
||||
const currentUser = useRecoilValue(currentUserAtom);
|
||||
const messages = useRecoilValue<ChatMessage[]>(visibleChatMessagesSelector);
|
||||
|
||||
if (!currentUser) {
|
||||
return null;
|
||||
}
|
||||
const { id, displayName } = currentUser;
|
||||
return (
|
||||
<div>
|
||||
<ClientConfigStore />
|
||||
<ChatContainer
|
||||
messages={messages}
|
||||
usernameToHighlight={chatDisplayName}
|
||||
chatUserId={chatUserId}
|
||||
usernameToHighlight={displayName}
|
||||
chatUserId={id}
|
||||
isModerator={false}
|
||||
showInput={false}
|
||||
height="100vh"
|
||||
|
||||
@@ -3,32 +3,34 @@ import { ChatMessage } from '../../../../interfaces/chat-message.model';
|
||||
import { ChatContainer } from '../../../../components/chat/ChatContainer/ChatContainer';
|
||||
import {
|
||||
ClientConfigStore,
|
||||
chatDisplayNameAtom,
|
||||
chatUserIdAtom,
|
||||
currentUserAtom,
|
||||
visibleChatMessagesSelector,
|
||||
clientConfigStateAtom,
|
||||
isChatModeratorAtom,
|
||||
} from '../../../../components/stores/ClientConfigStore';
|
||||
import Header from '../../../../components/ui/Header/Header';
|
||||
import { ClientConfig } from '../../../../interfaces/client-config.model';
|
||||
|
||||
export default function ReadWriteChatEmbed() {
|
||||
const chatDisplayName = useRecoilValue<string>(chatDisplayNameAtom);
|
||||
const chatUserId = useRecoilValue<string>(chatUserIdAtom);
|
||||
const currentUser = useRecoilValue(currentUserAtom);
|
||||
const messages = useRecoilValue<ChatMessage[]>(visibleChatMessagesSelector);
|
||||
const clientConfig = useRecoilValue<ClientConfig>(clientConfigStateAtom);
|
||||
const isModerator = useRecoilValue<boolean>(isChatModeratorAtom);
|
||||
|
||||
const { name, chatDisabled } = clientConfig;
|
||||
|
||||
if (!currentUser) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const { id, displayName, isModerator } = currentUser;
|
||||
|
||||
return (
|
||||
<div>
|
||||
<ClientConfigStore />
|
||||
<Header name={name} chatAvailable chatDisabled={chatDisabled} />
|
||||
<ChatContainer
|
||||
messages={messages}
|
||||
usernameToHighlight={chatDisplayName}
|
||||
chatUserId={chatUserId}
|
||||
usernameToHighlight={displayName}
|
||||
chatUserId={id}
|
||||
isModerator={isModerator}
|
||||
showInput
|
||||
height="80vh"
|
||||
|
||||
Reference in New Issue
Block a user