0

Add action message type to chat. Closes #2226

This commit is contained in:
Gabe Kangas 2022-10-18 19:44:42 -07:00
parent a58d4d6997
commit 91c7bed0e8
No known key found for this signature in database
GPG Key ID: 9A56337728BC81EA
2 changed files with 10 additions and 0 deletions

View File

@ -15,6 +15,7 @@ import { ChatModeratorNotification } from '../ChatModeratorNotification/ChatMode
import { ChatSystemMessage } from '../ChatSystemMessage/ChatSystemMessage';
import { ChatJoinMessage } from '../ChatJoinMessage/ChatJoinMessage';
import { ScrollToBotBtn } from './ScrollToBotBtn';
import { ChatActionMessage } from '../ChatActionMessage/ChatActionMessage';
export type ChatContainerProps = {
messages: ChatMessage[];
@ -111,6 +112,10 @@ export const ChatContainer: FC<ChatContainerProps> = ({
);
};
const getActionMessage = (message: ChatMessage) => {
const { body } = message;
return <ChatActionMessage body={body} />;
};
const getConnectedInfoMessage = (message: ConnectedClientInfoEvent) => {
const modStatusUpdate = checkIsModerator(message);
if (!modStatusUpdate) {
@ -148,6 +153,8 @@ export const ChatContainer: FC<ChatContainerProps> = ({
return getConnectedInfoMessage(message);
case MessageType.USER_JOINED:
return getUserJoinedMessage(message as ChatMessage);
case MessageType.CHAT_ACTION:
return getActionMessage(message as ChatMessage);
case MessageType.SYSTEM:
return (
<ChatSystemMessage

View File

@ -302,6 +302,9 @@ export const ClientConfigStore: FC = () => {
case MessageType.SYSTEM:
setChatMessages(currentState => [...currentState, message as ChatEvent]);
break;
case MessageType.CHAT_ACTION:
setChatMessages(currentState => [...currentState, message as ChatEvent]);
break;
case MessageType.VISIBILITY_UPDATE:
handleMessageVisibilityChange(message as MessageVisibilityEvent);
break;