fix chat colour formatter

This commit is contained in:
Layne 2022-03-17 09:04:21 -04:00
parent b897aa1461
commit 2f5171b194

View File

@ -14,6 +14,7 @@ export const ChatWidgetMessageView: FC<ChatWidgetMessageViewProps> = props =>
const { chat = null, makeRoom = null, onChatClicked = null } = props;
const [ isVisible, setIsVisible ] = useState(false);
const elementRef = useRef<HTMLDivElement>();
const [formatted, setFormatted] = useState(null);
const onMouseDown = (event: MouseEvent<HTMLDivElement>) => onChatClicked(chat);
@ -49,13 +50,13 @@ export const ChatWidgetMessageView: FC<ChatWidgetMessageViewProps> = props =>
chat.visible = true;
}
chat.text = RoomChatFormatter(chat.text);
if(!formatted) setFormatted(RoomChatFormatter(chat.text));
return () =>
{
chat.elementRef = null;
}
}, [ elementRef, chat, makeRoom ]);
}, [ elementRef, chat, makeRoom,formatted ]);
useEffect(() => setIsVisible(chat.visible), [ chat.visible ]);
@ -68,7 +69,7 @@ export const ChatWidgetMessageView: FC<ChatWidgetMessageViewProps> = props =>
</div>
<div className="chat-content">
<b className="username mr-1" dangerouslySetInnerHTML={ { __html: `${ chat.username }: ` } } />
<span className="message" dangerouslySetInnerHTML={{ __html: chat.text }} />
<span className="message" dangerouslySetInnerHTML={{ __html: formatted }} />
</div>
<div className="pointer"></div>
</div>