mirror of
https://github.com/billsonnn/nitro-react.git
synced 2024-11-30 08:50:51 +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 { chat = null, makeRoom = null, onChatClicked = null } = props;
|
||||||
const [ isVisible, setIsVisible ] = useState(false);
|
const [ isVisible, setIsVisible ] = useState(false);
|
||||||
const elementRef = useRef<HTMLDivElement>();
|
const elementRef = useRef<HTMLDivElement>();
|
||||||
|
const [formatted, setFormatted] = useState(null);
|
||||||
|
|
||||||
const onMouseDown = (event: MouseEvent<HTMLDivElement>) => onChatClicked(chat);
|
const onMouseDown = (event: MouseEvent<HTMLDivElement>) => onChatClicked(chat);
|
||||||
|
|
||||||
@ -49,13 +50,13 @@ export const ChatWidgetMessageView: FC<ChatWidgetMessageViewProps> = props =>
|
|||||||
chat.visible = true;
|
chat.visible = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
chat.text = RoomChatFormatter(chat.text);
|
if(!formatted) setFormatted(RoomChatFormatter(chat.text));
|
||||||
|
|
||||||
return () =>
|
return () =>
|
||||||
{
|
{
|
||||||
chat.elementRef = null;
|
chat.elementRef = null;
|
||||||
}
|
}
|
||||||
}, [ elementRef, chat, makeRoom ]);
|
}, [ elementRef, chat, makeRoom,formatted ]);
|
||||||
|
|
||||||
useEffect(() => setIsVisible(chat.visible), [ chat.visible ]);
|
useEffect(() => setIsVisible(chat.visible), [ chat.visible ]);
|
||||||
|
|
||||||
@ -68,7 +69,7 @@ export const ChatWidgetMessageView: FC<ChatWidgetMessageViewProps> = props =>
|
|||||||
</div>
|
</div>
|
||||||
<div className="chat-content">
|
<div className="chat-content">
|
||||||
<b className="username mr-1" dangerouslySetInnerHTML={ { __html: `${ chat.username }: ` } } />
|
<b className="username mr-1" dangerouslySetInnerHTML={ { __html: `${ chat.username }: ` } } />
|
||||||
<span className="message" dangerouslySetInnerHTML={{ __html: chat.text }} />
|
<span className="message" dangerouslySetInnerHTML={{ __html: formatted }} />
|
||||||
</div>
|
</div>
|
||||||
<div className="pointer"></div>
|
<div className="pointer"></div>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user