Skip to content

Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.

fix(ChatMessage): context menu position

Hristo Terezovfc816aa149b0
diff --git a/react/features/chat/components/web/ChatMessage.tsx b/react/features/chat/components/web/ChatMessage.tsx
index 743867f64a..410c8963cc 100644
--- a/react/features/chat/components/web/ChatMessage.tsx
+++ b/react/features/chat/components/web/ChatMessage.tsx
@@ -9,6 +9,7 @@ import { getParticipantById, getParticipantDisplayName, isPrivateChatEnabled } f
import Popover from '../../../base/popover/components/Popover.web';
import Message from '../../../base/react/components/web/Message';
import { withPixelLineHeight } from '../../../base/styles/functions.web';
+import { MESSAGE_TYPE_LOCAL } from '../../constants';
import { getFormattedTimestamp, getMessageText, getPrivateNoticeMessage } from '../../functions';
import { IChatMessageProps } from '../../types';
@@ -16,9 +17,10 @@ import MessageMenu from './MessageMenu';
import ReactButton from './ReactButton';
interface IProps extends IChatMessageProps {
- shouldDisplayChatMessageMenu: boolean;
+ className?: string;
+ enablePrivateChat?: boolean;
+ shouldDisplayMenuOnRight?: boolean;
state?: IReduxState;
- type: string;
}
const useStyles = makeStyles()((theme: Theme) => {
@@ -190,11 +192,12 @@ const useStyles = makeStyles()((theme: Theme) => {
});
const ChatMessage = ({
+ className = '',
message,
state,
showDisplayName,
- type,
- shouldDisplayChatMessageMenu,
+ shouldDisplayMenuOnRight,
+ enablePrivateChat,
knocking,
t
}: IProps) => {
@@ -331,28 +334,28 @@ const ChatMessage = ({
return (
<div
- className = { cx(classes.chatMessageWrapper, type) }
+ className = { cx(classes.chatMessageWrapper, className) }
id = { message.messageId }
onMouseEnter = { handleMouseEnter }
onMouseLeave = { handleMouseLeave }
tabIndex = { -1 }>
<div className = { classes.sideBySideContainer }>
- {!shouldDisplayChatMessageMenu && (
+ {!shouldDisplayMenuOnRight && (
<div className = { classes.optionsButtonContainer }>
{isHovered && <MessageMenu
displayName = { message.displayName }
+ enablePrivateChat = { Boolean(enablePrivateChat) }
isFromVisitor = { message.isFromVisitor }
isLobbyMessage = { message.lobbyChat }
message = { message.message }
- participantId = { message.participantId }
- shouldDisplayChatMessageMenu = { shouldDisplayChatMessageMenu } />}
+ participantId = { message.participantId } />}
</div>
)}
<div
className = { cx(
'chatmessage',
classes.chatMessage,
- type,
+ className,
message.privateMessage && 'privatemessage',
message.lobbyChat && !knocking && 'lobbymessage'
) }>
@@ -383,7 +386,7 @@ const ChatMessage = ({
</div>
</div>
</div>
- {shouldDisplayChatMessageMenu && (
+ {shouldDisplayMenuOnRight && (
<div className = { classes.sideBySideContainer }>
{!message.privateMessage && !message.lobbyChat && <div>
<div className = { classes.optionsButtonContainer }>
@@ -396,11 +399,11 @@ const ChatMessage = ({
<div className = { classes.optionsButtonContainer }>
{isHovered && <MessageMenu
displayName = { message.displayName }
+ enablePrivateChat = { Boolean(enablePrivateChat) }
isFromVisitor = { message.isFromVisitor }
isLobbyMessage = { message.lobbyChat }
message = { message.message }
- participantId = { message.participantId }
- shouldDisplayChatMessageMenu = { shouldDisplayChatMessageMenu } />}
+ participantId = { message.participantId } />}
</div>
</div>
</div>
@@ -430,8 +433,13 @@ function _mapStateToProps(state: IReduxState, { message }: IProps) {
const enablePrivateChat = (!message.isFromVisitor || message.privateMessage)
&& isPrivateChatEnabled(participantForCheck, state);
+ // Only the local messages appear on the right side of the chat therefore only for them the menu has to be on the
+ // left side.
+ const shouldDisplayMenuOnRight = message.messageType !== MESSAGE_TYPE_LOCAL;
+
return {
- shouldDisplayChatMessageMenu: enablePrivateChat,
+ shouldDisplayMenuOnRight,
+ enablePrivateChat,
knocking,
state
};
diff --git a/react/features/chat/components/web/ChatMessageGroup.tsx b/react/features/chat/components/web/ChatMessageGroup.tsx
index f89452fc22..93eefd217e 100644
--- a/react/features/chat/components/web/ChatMessageGroup.tsx
+++ b/react/features/chat/components/web/ChatMessageGroup.tsx
@@ -71,12 +71,11 @@ const ChatMessageGroup = ({ className = '', messages }: IProps) => {
<div className = { `${classes.messageGroup} chat-message-group ${className}` }>
{messages.map((message, i) => (
<ChatMessage
+ className = { className }
key = { i }
message = { message }
- shouldDisplayChatMessageMenu = { false }
showDisplayName = { i === 0 }
- showTimestamp = { i === messages.length - 1 }
- type = { className } />
+ showTimestamp = { i === messages.length - 1 } />
))}
</div>
</div>
diff --git a/react/features/chat/components/web/MessageMenu.tsx b/react/features/chat/components/web/MessageMenu.tsx
index 11e9cae322..9e35492fd5 100644
--- a/react/features/chat/components/web/MessageMenu.tsx
+++ b/react/features/chat/components/web/MessageMenu.tsx
@@ -16,11 +16,11 @@ import { handleLobbyChatInitialized, openChat } from '../../actions.web';
export interface IProps {
className?: string;
displayName?: string;
+ enablePrivateChat: boolean;
isFromVisitor?: boolean;
isLobbyMessage: boolean;
message: string;
participantId: string;
- shouldDisplayChatMessageMenu: boolean;
}
const useStyles = makeStyles()(theme => {
@@ -60,7 +60,7 @@ const useStyles = makeStyles()(theme => {
};
});
-const MessageMenu = ({ message, participantId, isFromVisitor, isLobbyMessage, shouldDisplayChatMessageMenu, displayName }: IProps) => {
+const MessageMenu = ({ message, participantId, isFromVisitor, isLobbyMessage, enablePrivateChat, displayName }: IProps) => {
const dispatch = useDispatch();
const { classes, cx } = useStyles();
const { t } = useTranslation();
@@ -130,7 +130,7 @@ const MessageMenu = ({ message, participantId, isFromVisitor, isLobbyMessage, sh
const popoverContent = (
<div className = { classes.menuPanel }>
- {shouldDisplayChatMessageMenu && (
+ {enablePrivateChat && (
<div
className = { classes.menuItem }
onClick = { handlePrivateClick }>
diff --git a/react/features/chat/types.ts b/react/features/chat/types.ts
index 33b9c4892f..340c7016a1 100644
--- a/react/features/chat/types.ts
+++ b/react/features/chat/types.ts
@@ -62,11 +62,6 @@ export interface IChatMessageProps extends WithTranslation {
*/
message: IMessage;
- /**
- * Whether the chat message menu is visible or not.
- */
- shouldDisplayChatMessageMenu?: boolean;
-
/**
* Whether or not the avatar image of the participant which sent the message
* should be displayed.