mirror of
https://gitcode.com/GitHub_Trending/ji/jitsi-meet.git
synced 2025-12-30 03:12:29 +00:00
Before the chat message context menu was appearing on the left if the private chat message was disabled. The fix makes the context menu appear on the left only for messages from the local partcipant which are the only messages rendered to the right (therefore the context menu have to appear on the left side). For all other messages the context menu should appear on the right side because the message is positioned on the left side.
86 lines
2.1 KiB
TypeScript
86 lines
2.1 KiB
TypeScript
import clsx from 'clsx';
|
|
import React from 'react';
|
|
import { makeStyles } from 'tss-react/mui';
|
|
|
|
import Avatar from '../../../base/avatar/components/Avatar';
|
|
import { IMessage } from '../../types';
|
|
|
|
import ChatMessage from './ChatMessage';
|
|
|
|
interface IProps {
|
|
|
|
/**
|
|
* Additional CSS classes to apply to the root element.
|
|
*/
|
|
className: string;
|
|
|
|
/**
|
|
* The messages to display as a group.
|
|
*/
|
|
messages: Array<IMessage>;
|
|
}
|
|
|
|
const useStyles = makeStyles()(theme => {
|
|
return {
|
|
messageGroup: {
|
|
display: 'flex',
|
|
flexDirection: 'column',
|
|
maxWidth: '100%',
|
|
|
|
'&.remote': {
|
|
maxWidth: 'calc(100% - 40px)' // 100% - avatar and margin
|
|
}
|
|
},
|
|
|
|
groupContainer: {
|
|
display: 'flex',
|
|
|
|
'&.local': {
|
|
justifyContent: 'flex-end',
|
|
|
|
'& .avatar': {
|
|
display: 'none'
|
|
}
|
|
}
|
|
},
|
|
|
|
avatar: {
|
|
margin: `${theme.spacing(1)} ${theme.spacing(2)} ${theme.spacing(3)} 0`,
|
|
position: 'sticky',
|
|
flexShrink: 0,
|
|
top: 0
|
|
}
|
|
};
|
|
});
|
|
|
|
|
|
const ChatMessageGroup = ({ className = '', messages }: IProps) => {
|
|
const { classes } = useStyles();
|
|
const messagesLength = messages.length;
|
|
|
|
if (!messagesLength) {
|
|
return null;
|
|
}
|
|
|
|
return (
|
|
<div className = { clsx(classes.groupContainer, className) }>
|
|
<Avatar
|
|
className = { clsx(classes.avatar, 'avatar') }
|
|
participantId = { messages[0].participantId }
|
|
size = { 32 } />
|
|
<div className = { `${classes.messageGroup} chat-message-group ${className}` }>
|
|
{messages.map((message, i) => (
|
|
<ChatMessage
|
|
className = { className }
|
|
key = { i }
|
|
message = { message }
|
|
showDisplayName = { i === 0 }
|
|
showTimestamp = { i === messages.length - 1 } />
|
|
))}
|
|
</div>
|
|
</div>
|
|
);
|
|
};
|
|
|
|
export default ChatMessageGroup;
|