More chat updates

This commit is contained in:
Bill 2021-07-02 13:36:34 -04:00
parent fc3ff514ec
commit 44631c2690
2 changed files with 14 additions and 12 deletions

View File

@ -1,6 +1,6 @@
import { FC, useCallback, useEffect, useMemo, useRef, useState } from 'react'; import { FC, useCallback, useEffect, useMemo, useRef, useState } from 'react';
import { createPortal } from 'react-dom'; import { createPortal } from 'react-dom';
import { GetConfiguration } from '../../../../api'; import { GetConfiguration, GetSessionDataManager } from '../../../../api';
import { CreateEventDispatcherHook } from '../../../../hooks/events'; import { CreateEventDispatcherHook } from '../../../../hooks/events';
import { LocalizeText } from '../../../../utils/LocalizeText'; import { LocalizeText } from '../../../../utils/LocalizeText';
import { useRoomContext } from '../../context/RoomContext'; import { useRoomContext } from '../../context/RoomContext';
@ -19,6 +19,8 @@ export const ChatInputView: FC<ChatInputViewProps> = props =>
const [ isTyping, setIsTyping ] = useState(false); const [ isTyping, setIsTyping ] = useState(false);
const [ typingStartedSent, setTypingStartedSent ] = useState(false); const [ typingStartedSent, setTypingStartedSent ] = useState(false);
const [ isIdle, setIsIdle ] = useState(false); const [ isIdle, setIsIdle ] = useState(false);
const [ chatStyleId, setChatStyleId ] = useState(GetSessionDataManager().chatStyle);
const [ needsChatStyleUpdate, setNeedsChatStyleUpdate ] = useState(false);
const inputRef = useRef<HTMLInputElement>(); const inputRef = useRef<HTMLInputElement>();
const chatModeIdWhisper = useMemo(() => const chatModeIdWhisper = useMemo(() =>
@ -119,20 +121,18 @@ export const ChatInputView: FC<ChatInputViewProps> = props =>
if(text.length <= maxChatLength) if(text.length <= maxChatLength)
{ {
// if(this.needsStyleUpdate) if(needsChatStyleUpdate)
// { {
// Nitro.instance.sessionDataManager.sendChatStyleUpdate(this.currentStyle); GetSessionDataManager().sendChatStyleUpdate(chatStyleId);
// this.needsStyleUpdate = false; setNeedsChatStyleUpdate(false);
// } }
let currentStyle = 1; sendChat(text, chatType, recipientName, chatStyleId);
sendChat(text, chatType, recipientName, currentStyle);
} }
setChatValue(append); setChatValue(append);
}, [ chatModeIdWhisper, chatModeIdShout, chatModeIdSpeak, maxChatLength, sendChat ]); }, [ chatModeIdWhisper, chatModeIdShout, chatModeIdSpeak, maxChatLength, chatStyleId, needsChatStyleUpdate, sendChat ]);
const updateChatInput = useCallback((value: string) => const updateChatInput = useCallback((value: string) =>
{ {
@ -162,6 +162,7 @@ export const ChatInputView: FC<ChatInputViewProps> = props =>
case 'Space': case 'Space':
checkSpecialKeywordForInput(); checkSpecialKeywordForInput();
return; return;
case 'NumpadEnter':
case 'Enter': case 'Enter':
sendChatValue(value, event.shiftKey); sendChatValue(value, event.shiftKey);
return; return;
@ -182,7 +183,8 @@ export const ChatInputView: FC<ChatInputViewProps> = props =>
const onStyleSelected = useCallback((styleId: number) => const onStyleSelected = useCallback((styleId: number) =>
{ {
setChatStyleId(styleId);
setNeedsChatStyleUpdate(true);
}, []); }, []);
const onRoomWidgetRoomObjectUpdateEvent = useCallback((event: RoomWidgetRoomObjectUpdateEvent) => const onRoomWidgetRoomObjectUpdateEvent = useCallback((event: RoomWidgetRoomObjectUpdateEvent) =>

View File

@ -96,7 +96,7 @@ export const ChatWidgetMessageView: FC<ChatWidgetMessageViewProps> = props =>
{ (chat.imageUrl && (chat.imageUrl !== '')) && <div className="user-image" style={ { backgroundImage: 'url(' + chat.imageUrl + ')' } } /> } { (chat.imageUrl && (chat.imageUrl !== '')) && <div className="user-image" style={ { backgroundImage: 'url(' + chat.imageUrl + ')' } } /> }
</div> </div>
<div className="chat-content"> <div className="chat-content">
<b className="username mr-1">{ chat.username }</b> <b className="username mr-1" dangerouslySetInnerHTML={ {__html: `${ chat.username }: ` } } />
{ chat.text } { chat.text }
<span className="message"> { <span className="message"> {
messageParts && messageParts.map((part, index) => messageParts && messageParts.map((part, index) =>