mirror of
https://github.com/billsonnn/nitro-react.git
synced 2024-11-26 23:50:52 +01:00
fix chat colour formatter
This commit is contained in:
parent
b897aa1461
commit
2f5171b194
@ -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>
|
||||
|
Loading…
Reference in New Issue
Block a user