mirror of
https://github.com/billsonnn/nitro-react.git
synced 2024-11-23 14:40:50 +01:00
Fix chat bubble overlap
This commit is contained in:
parent
98a2827a4a
commit
06a2fe059e
@ -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<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);
|
||||
|
||||
@ -50,13 +48,11 @@ export const ChatWidgetMessageView: FC<ChatWidgetMessageViewProps> = 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<ChatWidgetMessageViewProps> = props =>
|
||||
{ (chat.imageUrl && (chat.imageUrl !== '')) && <div className="user-image" style={ { backgroundImage: 'url(' + chat.imageUrl + ')' } } /> }
|
||||
</div>
|
||||
<div className="chat-content">
|
||||
<b className="username mr-1" dangerouslySetInnerHTML={ { __html: `${ chat.username }: ` } } />
|
||||
<span className="message" dangerouslySetInnerHTML={{ __html: formatted }} />
|
||||
<b className="username mr-1" dangerouslySetInnerHTML={ { __html: chat.username } } />
|
||||
<span className="message" dangerouslySetInnerHTML={{ __html: chat.formattedText }} />
|
||||
</div>
|
||||
<div className="pointer"></div>
|
||||
</div>
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user