|
@@ -7,25 +7,23 @@ import MessageDropZone from "../DropZone/MessageDropZone/MessageDropZone";
|
|
|
import { actionAddDraftMessage, actionDeleteDraftMessageId, actionDeleteReplyMessageId, actionSetInputMessageValue } from "../../reducers/chatReducer";
|
|
|
|
|
|
import SendRoundedIcon from '@mui/icons-material/SendRounded';
|
|
|
-import ReplyMessage from "../MessageDraft/ReplyMessageDraft";
|
|
|
-import { MessageDraftBox } from "../MessageDraft/MessageDraftBox";
|
|
|
import InputAreaMessageEditor from "./InputAreaMessageEditor";
|
|
|
+import MessageReplyForwarded from "../MessageDraft/MessageReplyForwarded";
|
|
|
|
|
|
|
|
|
const InputArea = ({sendMessage, deleteDraftMessage, chatId, chats, setInputValue, modal: {content, isOpen}}) => {
|
|
|
const message = chats[chatId]?.draft?.mainInputValue?.message;
|
|
|
const inputValue = chats[chatId]?.draft?.mainInputValue?.value || '';
|
|
|
- let replyMessageId = (message && typeof message !== 'object') ? message : null;
|
|
|
- let forwardedMessageId = (message && typeof message === 'object') ? message._id : null;
|
|
|
- console.log(forwardedMessageId)
|
|
|
+ const replyMessageId = message && message.hasOwnProperty('reply') ? message.reply?._id : null;
|
|
|
+ const forwardedMessageId = message && message.hasOwnProperty('forwarded') ? message.forwarded?._id : null;
|
|
|
|
|
|
return (chats[chatId]?.draft?.messageEditor && !chats[chatId]?.draft?.messageEditor?.message?.media) ?
|
|
|
<InputAreaMessageEditor chatId={chatId}/>
|
|
|
:
|
|
|
<InputAreaWrapper>
|
|
|
- <MessageDraftBox chat={chats[chatId]}>
|
|
|
+ <MessageReplyForwarded chat={chats[chatId]}>
|
|
|
|
|
|
- </MessageDraftBox>
|
|
|
+ </MessageReplyForwarded>
|
|
|
|
|
|
<div style={{display: 'flex', alignItems: 'center', padding: '10px 0'}}>
|
|
|
<MessageDropZone chatId={chatId}/>
|
|
@@ -33,18 +31,18 @@ const InputArea = ({sendMessage, deleteDraftMessage, chatId, chats, setInputValu
|
|
|
value={content === 'messageMediaModal' && isOpen ? '' : inputValue}
|
|
|
onChange={e=>{setInputValue(chatId, e.target.value, 'mainInputValue')}}
|
|
|
maxRows={8}
|
|
|
+ disabled={forwardedMessageId ? true : false}
|
|
|
placeholder="Write a message..."
|
|
|
/>
|
|
|
- {inputValue ?
|
|
|
+ {inputValue || forwardedMessageId ?
|
|
|
<SendRoundedIcon
|
|
|
style={{margin: '0 16px', cursor: "pointer"}}
|
|
|
color="primary"
|
|
|
- // src={Plane}
|
|
|
onClick={
|
|
|
async() => {
|
|
|
- let val = await sendMessage(null, chatId, inputValue.replace(/^\s+|\s+$/g, ''), null, replyMessageId, forwardedMessageId);
|
|
|
+ let val = await sendMessage(null, chatId, forwardedMessageId ? 'forwarded message' : inputValue?.replace(/^\s+|\s+$/g, ''), null, replyMessageId, forwardedMessageId);
|
|
|
(val?.replyTo?._id || val?.forwarded?._id) && deleteDraftMessage(chatId, null)
|
|
|
- val && setInputValue(chatId, "", 'mainInputValue')
|
|
|
+ val && !val?.forwarded?._id && setInputValue(chatId, "", 'mainInputValue')
|
|
|
}
|
|
|
}
|
|
|
/> : <div></div>}
|