|
@@ -11,7 +11,7 @@ import CommentIcon from '@mui/icons-material/Comment';
|
|
|
import Avatar from '@mui/material/Avatar';
|
|
|
import Webcam from "react-webcam";
|
|
|
import CameraIcon from '@mui/icons-material/Camera';
|
|
|
-import TextField from '@mui/material/TextField';
|
|
|
+import TextField from '@material-ui/core/TextField';
|
|
|
import Picker from 'emoji-picker-react';
|
|
|
import InputAdornment from '@mui/material/InputAdornment';
|
|
|
|
|
@@ -114,7 +114,9 @@ const useStyles = makeStyles({
|
|
|
visibility: 'visible',
|
|
|
width: '35vw',
|
|
|
backgroundColor: '#ffffff',
|
|
|
- borderRadius:4,
|
|
|
+ borderRadius: 4,
|
|
|
+ height: '6vh',
|
|
|
+ overflowY: 'auto',
|
|
|
},
|
|
|
iconCancel: {
|
|
|
position: 'absolute',
|
|
@@ -337,15 +339,19 @@ const SendMessage = ({isArrow,silentMode,isReply,setIsReply,isForward,setIsForwa
|
|
|
}
|
|
|
|
|
|
const sentMessage = async () => {
|
|
|
- if (value && !isReply && !isForward) sentMessageById(companionId, value, caption.trim())
|
|
|
- if (value && isReply && !isForward) {
|
|
|
+ if (value && !isReply && !isForward && !isEdit) sentMessageById(companionId, value, caption.trim())
|
|
|
+ if (value && isReply && !isForward && !isEdit) {
|
|
|
sentMessageReplyById(isReply._id, value, caption.trim())
|
|
|
setIsReply(undefined)
|
|
|
}
|
|
|
- if (value&&!isReply && isForward) {
|
|
|
+ if (value&&isForward && !isEdit && !isReply) {
|
|
|
sentMessageForwardById(isForward._id,isForward.companionIdForwardToAndFrom,value,caption.trim())
|
|
|
setIsForward(undefined)
|
|
|
- }
|
|
|
+ }
|
|
|
+ if (value&&isEdit && !isForward && !isReply) {
|
|
|
+ //sent edited messages
|
|
|
+ setIsEdit(undefined)
|
|
|
+ }
|
|
|
if (mediaBlobUrl && type === 'recording') {
|
|
|
const audio = new XMLHttpRequest();
|
|
|
audio.open('GET', mediaBlobUrl, true);
|
|
@@ -508,6 +514,13 @@ const SendMessage = ({isArrow,silentMode,isReply,setIsReply,isForward,setIsForwa
|
|
|
setIsReply(undefined)
|
|
|
setIsEdit(undefined)
|
|
|
}, [companionId, setIsReply,setIsEdit])
|
|
|
+
|
|
|
+ useEffect(() => {
|
|
|
+ if (isEdit) {
|
|
|
+ isEdit.type ==='text'&&setValue(isEdit.message?isEdit.message:'')
|
|
|
+ setCaption(isEdit.caption?isEdit.caption:'')
|
|
|
+ }
|
|
|
+ }, [isEdit, companionId])
|
|
|
|
|
|
useEffect(() => {
|
|
|
const companionIdForwardToAndFrom = isForward?.companionIdForwardToAndFrom
|
|
@@ -515,7 +528,7 @@ const SendMessage = ({isArrow,silentMode,isReply,setIsReply,isForward,setIsForwa
|
|
|
},[companionId])
|
|
|
|
|
|
return (
|
|
|
- <div className={value || file || status === 'stopped' || _status === 'stopped' ?classes.containerActive:classes.container}>
|
|
|
+ <div className={(isEdit&&value&&(isEdit.message !== value)) || (isEdit&&caption&&(isEdit.caption !== caption)) || (value&&!isEdit) || file || status === 'stopped' || _status === 'stopped' ?classes.containerActive:classes.container}>
|
|
|
{isArrow && <div className={classes.borderTop}></div>}
|
|
|
{isReply && <ReplyBar isReply={isReply} handleCloseReply={handleCloseReply}
|
|
|
handleScrollToTheMessage={handleScrollToTheMessage} />}
|
|
@@ -553,24 +566,24 @@ const SendMessage = ({isArrow,silentMode,isReply,setIsReply,isForward,setIsForwa
|
|
|
</div>
|
|
|
</>}
|
|
|
<CloseIcon onClick={clearMessage} fontSize="small" className={classes.iconCancel}
|
|
|
- sx={{width: 56, height: 56, display: file || value || (status === 'stopped'&&type)
|
|
|
+ sx={{width: 56, height: 56, display: file || (value&&!isReply&&!isForward&&!isEdit) || (status === 'stopped'&&type)
|
|
|
|| (_status === 'stopped'&&type) ? 'inline-block' : 'none'}} />
|
|
|
<VideocamIcon onClick={handleFilming} className={classes.avatarCamera}
|
|
|
sx={{backgroundColor: '#ffffff', color: '#6b6b6b', width: 56, height: 56}}
|
|
|
- style={{ display: status !== null || _status === 'stopped' || file || value || isFilming || isReply || isForward? 'none' : 'block' }} />
|
|
|
+ style={{ display: status !== null || _status === 'stopped' || file || value || isFilming || isReply || isForward || isEdit? 'none' : 'block' }} />
|
|
|
<SendIcon onClick={sentMessage} className={classes.avatarRight}
|
|
|
sx={{backgroundColor: '#ffffff',color: 'rgb(41, 139, 231)', width: 56, height: 56}}
|
|
|
- style={{display: value || file || status === 'stopped' || _status === 'stopped'? 'block':'none' }}/>
|
|
|
+ style={{display: (isEdit&&value&&(isEdit.message !== value)) || (isEdit&&caption&&(isEdit.caption !== caption)) || (value&&!isEdit) || file || status === 'stopped' || _status === 'stopped'? 'block':'none' }}/>
|
|
|
<MicNoneIcon onClick={handleRecording} className={classes.avatarRight}
|
|
|
sx={{backgroundColor:'#ffffff',color: '#6b6b6b', width: 56, height: 56}}
|
|
|
- style={{display: !value && !file && status !== 'stopped' && _status === null&&!isRecording && !isReply && !isForward ? 'block' : 'none'}}/>
|
|
|
+ style={{display: !value && !file && status !== 'stopped' && _status === null&&!isRecording && !isReply && !isForward && !isEdit ? 'block' : 'none'}}/>
|
|
|
<SentimentSatisfiedAltIcon onClick={handleOpenEmoji}
|
|
|
fontSize='medium' sx={{color: isOpenEmoji ? 'rgb(41, 139, 231)' : '#6b6b6b', cursor: 'pointer',
|
|
|
- pointerEvents: file || status || _status ? 'none' : "auto",
|
|
|
+ pointerEvents: file || status || _status || (isEdit&&isEdit.type !== 'text') ? 'none' : "auto",
|
|
|
'&:hover': { color: 'rgb(41, 139, 231)' }, marginRight:1}}/>
|
|
|
<CommentIcon onClick={handleOpenCaption}
|
|
|
fontSize='medium' sx={{color: isOpenCaption || caption ? 'rgb(41, 139, 231)' : '#6b6b6b', cursor: 'pointer',
|
|
|
- pointerEvents: value || file || status === 'stopped' || _status === 'stopped'? 'auto' : "none",
|
|
|
+ pointerEvents: value || file || status === 'stopped' || _status === 'stopped' || (isEdit&&isEdit.type !== 'text')? 'auto' : "none",
|
|
|
'&:hover': { color: 'rgb(41, 139, 231)'}}} />
|
|
|
<div onClick={handleCloseEmoji} className={classes.overlay} id='overlay'
|
|
|
style={{ display: isOpenEmoji ? 'block':'none'}}>
|
|
@@ -581,21 +594,21 @@ const SendMessage = ({isArrow,silentMode,isReply,setIsReply,isForward,setIsForwa
|
|
|
<div onClick={handleCloseCaption} className={classes.overlay} id='overlay'
|
|
|
style={{ display: isOpenCaption ? 'block' : 'none' }}>
|
|
|
{isOpenCaptionEmoji && <div className={classes.emoji}
|
|
|
- style={{ left: rightIsOpen ? '32.5vw' : '45vw',bottom:isReply || isForward?'23vh':'16vh' }}>
|
|
|
+ style={{ left: rightIsOpen ? '32.5vw' : '45vw',bottom:isReply || isForward || isEdit?'23vh':'16vh' }}>
|
|
|
<Picker onEmojiClick={(e,obj) => onEmojiClick(e,obj,'caption')} />
|
|
|
</div>}
|
|
|
- <TextField className={classes.captionTextField} onChange={handleTextareaCaption}
|
|
|
- style={{ left: rightIsOpen ? '32.5vw' : '45vw', top: isReply || isForward?'78.5vh':'85vh' }}
|
|
|
+ <TextField multiline className={classes.captionTextField} onChange={handleTextareaCaption}
|
|
|
+ style={{left: rightIsOpen ? '32.5vw' : '45vw', top: isReply || isForward || isEdit?'78.5vh':'85vh' }}
|
|
|
placeholder='Caption' value={caption} id="caption" name='caption' variant='outlined'
|
|
|
InputProps={{
|
|
|
- startAdornment: (<InputAdornment position="start">
|
|
|
+ startAdornment: (<InputAdornment position="start" sx={{marginRight:4}}>
|
|
|
<SentimentSatisfiedAltIcon onClick={handleOpenCaptionEmoji}
|
|
|
sx={{color: isOpenCaptionEmoji ? 'rgb(41, 139, 231)' : '#6b6b6b', cursor: 'pointer',
|
|
|
- '&:hover': { color: 'rgb(41, 139, 231)' }}} />
|
|
|
+ '&:hover': { color: 'rgb(41, 139, 231)' },position:'fixed',top: isReply || isForward || isEdit?'80vh':'86.5vh'}} />
|
|
|
</InputAdornment>
|
|
|
),}}/>
|
|
|
</div>
|
|
|
- <textarea disabled={file || type === 'recording' || type === 'filming'? true : false} value={value} onBlur={handleBlurTextarea}
|
|
|
+ <textarea disabled={file || type === 'recording' || type === 'filming' || (isEdit&&isEdit.type !== 'text')? true : false} value={value} onBlur={handleBlurTextarea}
|
|
|
onFocus={handleFocusTextarea} onChange={handleTextarea} className={classes.textarea}
|
|
|
placeholder={file ? 'The File is ready to send' : status === null && _status === null ? 'Message' :
|
|
|
`${status === 'stopped' || _status === 'stopped' ? type === 'recording' || type === 'filming'?'Recorded':'Message':'Recording in progress...'}`} rows={1}
|
|
@@ -604,11 +617,11 @@ const SendMessage = ({isArrow,silentMode,isReply,setIsReply,isForward,setIsForwa
|
|
|
<PhotoCameraFrontIcon onClick={handleOpenCamera} fontSize='medium'
|
|
|
sx={{color: isOpenCamera || type === 'base64' ? 'rgb(62, 149, 231)' : '#6b6b6b', marginRight: 1, cursor: 'pointer',
|
|
|
pointerEvents: type === 'content' || type === 'application' || value || status !== null
|
|
|
- || _status !== null || isReply || isForward ? 'none' : "auto",
|
|
|
+ || _status !== null || isReply || isForward || isEdit ? 'none' : "auto",
|
|
|
'&:hover': { color: 'rgb(41, 139, 231)'}}}/>
|
|
|
<AttachFileIcon onClick={handleOpenFileMenu} className={classes.attachIcon}
|
|
|
fontSize='medium' sx={{color: isOpenMenu || type === 'content' || type === 'application' ? 'rgb(41, 139, 231)' : '#6b6b6b', cursor: 'pointer',
|
|
|
- pointerEvents: type === 'base64' || value || status !== null || _status !== null || isReply || isForward? 'none' : "auto", '&:hover':
|
|
|
+ pointerEvents: type === 'base64' || value || status !== null || _status !== null || isReply || isForward || isEdit? 'none' : "auto", '&:hover':
|
|
|
{ color: 'rgb(41, 139, 231)'}}}/>
|
|
|
<div onClick={handleCloseFileMenu} className={classes.overlay} id='overlay'
|
|
|
style={{ display: isOpenMenu ? 'block':'none'}}>
|