diff --git a/src/components/room/widgets/chat/ChatWidgetMessageView.tsx b/src/components/room/widgets/chat/ChatWidgetMessageView.tsx index 4385b3b6..ffd7c496 100644 --- a/src/components/room/widgets/chat/ChatWidgetMessageView.tsx +++ b/src/components/room/widgets/chat/ChatWidgetMessageView.tsx @@ -1,5 +1,4 @@ import { FC, MouseEvent, useEffect, useRef, useState } from 'react'; -import { RoomChatFormatter } from '../../../../api'; import { ChatBubbleMessage } from './common/ChatBubbleMessage'; interface ChatWidgetMessageViewProps @@ -14,7 +13,6 @@ export const ChatWidgetMessageView: FC = props => const { chat = null, makeRoom = null, onChatClicked = null } = props; const [ isVisible, setIsVisible ] = useState(false); const elementRef = useRef(); - const [formatted, setFormatted] = useState(null); const onMouseDown = (event: MouseEvent) => onChatClicked(chat); @@ -50,13 +48,11 @@ export const ChatWidgetMessageView: FC = props => chat.visible = true; } - if(!formatted) setFormatted(RoomChatFormatter(chat.text)); - return () => { chat.elementRef = null; } - }, [ elementRef, chat, makeRoom,formatted ]); + }, [ elementRef, chat, makeRoom ]); useEffect(() => setIsVisible(chat.visible), [ chat.visible ]); @@ -68,8 +64,8 @@ export const ChatWidgetMessageView: FC = props => { (chat.imageUrl && (chat.imageUrl !== '')) &&
}
- - + +
diff --git a/src/components/room/widgets/chat/ChatWidgetView.tsx b/src/components/room/widgets/chat/ChatWidgetView.tsx index e36923ff..400ddcbe 100644 --- a/src/components/room/widgets/chat/ChatWidgetView.tsx +++ b/src/components/room/widgets/chat/ChatWidgetView.tsx @@ -1,6 +1,6 @@ import { NitroPoint, RoomDragEvent } from '@nitrots/nitro-renderer'; import { FC, useCallback, useEffect, useRef, useState } from 'react'; -import { RoomWidgetChatSelectAvatarMessage, RoomWidgetRoomObjectMessage, RoomWidgetUpdateChatEvent } from '../../../../api'; +import { RoomChatFormatter, RoomWidgetChatSelectAvatarMessage, RoomWidgetRoomObjectMessage, RoomWidgetUpdateChatEvent } from '../../../../api'; import { UseEventDispatcherHook, UseRoomEngineEvent } from '../../../../hooks'; import { useRoomContext } from '../../RoomContext'; import { ChatWidgetMessageView } from './ChatWidgetMessageView'; @@ -63,6 +63,7 @@ export const ChatWidgetView: FC<{}> = props => event.userCategory, event.roomId, event.text, + RoomChatFormatter(event.text), event.userName, new NitroPoint(event.userX, event.userY), event.chatType, diff --git a/src/components/room/widgets/chat/common/ChatBubbleMessage.ts b/src/components/room/widgets/chat/common/ChatBubbleMessage.ts index 24e9735d..8846d3ca 100644 --- a/src/components/room/widgets/chat/common/ChatBubbleMessage.ts +++ b/src/components/room/widgets/chat/common/ChatBubbleMessage.ts @@ -18,6 +18,7 @@ export class ChatBubbleMessage public senderCategory: number = -1, public roomId: number = -1, public text: string = '', + public formattedText: string = '', public username: string = '', public location: INitroPoint = null, public type: number = 0,