mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-04 14:38:45 +00:00
working multi-chat between groups
This commit is contained in:
1 parent
8191a9431c
commit
8009c073db
4 files changed
+52
-22
No files matched your search
@@ -1,25 +1,20 @@
|
||||
import React from "react";
|
||||
import { Paper, Typography } from "@material-ui/core";
|
||||
|
||||
import { Message } from "../../../../common/interfaces/messages";
|
||||
import { Message, MessageGroup } from "../../../../common/interfaces/messages";
|
||||
import MessageInput from "../form/MessageInput";
|
||||
import useStyles from "./modal.styles";
|
||||
|
||||
interface IProps {
|
||||
activeMessageGroupId: string | undefined;
|
||||
activeMessageGroup: MessageGroup;
|
||||
messages: Message[];
|
||||
}
|
||||
|
||||
export const CONVERSATION_ELEMENT_ID = "message-modal-conversation";
|
||||
|
||||
const Conversation = ({ activeMessageGroupId, messages }: IProps) => {
|
||||
const Conversation = ({ activeMessageGroup, messages }: IProps) => {
|
||||
const classes = useStyles();
|
||||
|
||||
const uniqueAuthors = Array.from(
|
||||
new Set(messages.map((message) => message.display))
|
||||
);
|
||||
const isGroupChat = uniqueAuthors.length > 2;
|
||||
|
||||
return (
|
||||
<>
|
||||
<div id={CONVERSATION_ELEMENT_ID} className={classes.messageList}>
|
||||
@@ -31,7 +26,7 @@ const Conversation = ({ activeMessageGroupId, messages }: IProps) => {
|
||||
>
|
||||
<div>{message.message}</div>
|
||||
<Typography variant="subtitle1" color="secondary">
|
||||
{isGroupChat && !message.isMine
|
||||
{activeMessageGroup.isGroupChat && !message.isMine
|
||||
? message.display || message.phone_number
|
||||
: null}
|
||||
</Typography>
|
||||
@@ -39,7 +34,7 @@ const Conversation = ({ activeMessageGroupId, messages }: IProps) => {
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
<MessageInput messageGroupId={activeMessageGroupId} />
|
||||
<MessageInput messageGroupId={activeMessageGroup.groupId} />
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -90,7 +90,7 @@ export const MessageModal = () => {
|
||||
{messages && hasLoaded ? (
|
||||
<Conversation
|
||||
messages={messages}
|
||||
activeMessageGroupId={activeMessageGroup?.groupId}
|
||||
activeMessageGroup={activeMessageGroup}
|
||||
/>
|
||||
) : (
|
||||
<MessageSkeletonList />
|
||||
|
||||
Reference in new issue
Block a user