|
|
|
@ -1,33 +1,33 @@ |
|
|
|
|
import React, { Component } from 'react'; |
|
|
|
|
import ReactAudioPlayer from 'react-audio-player'; |
|
|
|
|
import ReactPlayer from 'react-player'; |
|
|
|
|
import CloudDownloadIcon from '@material-ui/icons/CloudDownload'; |
|
|
|
|
import Avatar from '@material-ui/core/Avatar'; |
|
|
|
|
import moment from 'jalali-moment'; |
|
|
|
|
import DoneIcon from '@material-ui/icons/Done'; |
|
|
|
|
import DoneAllIcon from '@material-ui/icons/DoneAll'; |
|
|
|
|
import EditIcon from '@material-ui/icons/Edit'; |
|
|
|
|
import ExpandMoreIcon from '@material-ui/icons/ExpandMore'; |
|
|
|
|
import './index.scss'; |
|
|
|
|
import Menu from '@material-ui/core/Menu'; |
|
|
|
|
import MenuItem from '@material-ui/core/MenuItem'; |
|
|
|
|
import ReplyIcon from '@material-ui/icons/Reply'; |
|
|
|
|
import ForwardIcon from '@material-ui/icons/Forward'; |
|
|
|
|
import DeleteIcon from '@material-ui/icons/Delete'; |
|
|
|
|
import FavoriteIcon from '@material-ui/icons/Favorite'; |
|
|
|
|
import TextsmsIcon from '@material-ui/icons/Textsms'; |
|
|
|
|
import ScheduleIcon from '@material-ui/icons/Schedule'; |
|
|
|
|
import React, { Component } from "react"; |
|
|
|
|
import ReactAudioPlayer from "react-audio-player"; |
|
|
|
|
import ReactPlayer from "react-player"; |
|
|
|
|
import CloudDownloadIcon from "@material-ui/icons/CloudDownload"; |
|
|
|
|
import Avatar from "@material-ui/core/Avatar"; |
|
|
|
|
import moment from "jalali-moment"; |
|
|
|
|
import DoneIcon from "@material-ui/icons/Done"; |
|
|
|
|
import DoneAllIcon from "@material-ui/icons/DoneAll"; |
|
|
|
|
import EditIcon from "@material-ui/icons/Edit"; |
|
|
|
|
import ExpandMoreIcon from "@material-ui/icons/ExpandMore"; |
|
|
|
|
import "./index.scss"; |
|
|
|
|
import Menu from "@material-ui/core/Menu"; |
|
|
|
|
import MenuItem from "@material-ui/core/MenuItem"; |
|
|
|
|
import ReplyIcon from "@material-ui/icons/Reply"; |
|
|
|
|
import ForwardIcon from "@material-ui/icons/Forward"; |
|
|
|
|
import DeleteIcon from "@material-ui/icons/Delete"; |
|
|
|
|
import FavoriteIcon from "@material-ui/icons/Favorite"; |
|
|
|
|
import TextsmsIcon from "@material-ui/icons/Textsms"; |
|
|
|
|
import ScheduleIcon from "@material-ui/icons/Schedule"; |
|
|
|
|
const file = (fileId) => `${window.baseURL}/file/download/${fileId}`; |
|
|
|
|
const menu = [ |
|
|
|
|
{ text: 'پسند', icon: FavoriteIcon, onClick: () => {} }, |
|
|
|
|
{ text: 'تبادل نظر', icon: TextsmsIcon, onClick: () => {} }, |
|
|
|
|
{ text: 'پاسخ', icon: ReplyIcon, onClick: () => {} }, |
|
|
|
|
{ text: 'باز ارسال', icon: ForwardIcon, onClick: () => {} }, |
|
|
|
|
{ text: "پسند", icon: FavoriteIcon, onClick: () => {} }, |
|
|
|
|
{ text: "تبادل نظر", icon: TextsmsIcon, onClick: () => {} }, |
|
|
|
|
{ text: "پاسخ", icon: ReplyIcon, onClick: () => {} }, |
|
|
|
|
{ text: "باز ارسال", icon: ForwardIcon, onClick: () => {} }, |
|
|
|
|
]; |
|
|
|
|
const selfMenu = [ |
|
|
|
|
{ text: 'باز ارسال', icon: ForwardIcon, onClick: () => {} }, |
|
|
|
|
{ text: 'ویرایش', icon: EditIcon, onClick: () => {} }, |
|
|
|
|
{ text: 'حذف', icon: DeleteIcon, onClick: () => {} }, |
|
|
|
|
{ text: "باز ارسال", icon: ForwardIcon, onClick: () => {} }, |
|
|
|
|
{ text: "ویرایش", icon: EditIcon, onClick: () => {} }, |
|
|
|
|
{ text: "حذف", icon: DeleteIcon, onClick: () => {} }, |
|
|
|
|
]; |
|
|
|
|
export default class NormalMessage extends Component { |
|
|
|
|
state = { messageMenu: null }; |
|
|
|
@ -42,7 +42,15 @@ export default class NormalMessage extends Component { |
|
|
|
|
}); |
|
|
|
|
}; |
|
|
|
|
render() { |
|
|
|
|
const { message, user, document, isSelf, prevUserId, children,addcounter } = this.props; |
|
|
|
|
const { |
|
|
|
|
message, |
|
|
|
|
user, |
|
|
|
|
document, |
|
|
|
|
isSelf, |
|
|
|
|
prevUserId, |
|
|
|
|
children, |
|
|
|
|
addcounter, |
|
|
|
|
} = this.props; |
|
|
|
|
const { messageMenu } = this.state; |
|
|
|
|
const hasavatar = prevUserId != message.userId; |
|
|
|
|
|
|
|
|
@ -50,41 +58,44 @@ export default class NormalMessage extends Component { |
|
|
|
|
<div |
|
|
|
|
className="normal-message d-flex flex-column d-flex" |
|
|
|
|
style={{ |
|
|
|
|
filter: document !== null ? 'blur(16px)' : 'blur(0px)', |
|
|
|
|
filter: document !== null ? "blur(4px)" : "blur(0px)", |
|
|
|
|
}} |
|
|
|
|
> |
|
|
|
|
{hasavatar && false && ( |
|
|
|
|
<Avatar |
|
|
|
|
alt={user.name} |
|
|
|
|
src={window.baseURL + '/file/download/' + user.fileId} |
|
|
|
|
src={window.baseURL + "/file/download/" + user.fileId} |
|
|
|
|
className="" |
|
|
|
|
style={{ |
|
|
|
|
marginTop: -5, |
|
|
|
|
backgroundColor: user.color, |
|
|
|
|
alignSelf: isSelf ? 'flex-end' : 'flex-start', |
|
|
|
|
alignSelf: isSelf ? "flex-end" : "flex-start", |
|
|
|
|
}} |
|
|
|
|
> |
|
|
|
|
{user.name |
|
|
|
|
.split(' ') |
|
|
|
|
.split(" ") |
|
|
|
|
.map((e) => e.slice(0, 1)) |
|
|
|
|
.join(' ')} |
|
|
|
|
.join(" ")} |
|
|
|
|
</Avatar> |
|
|
|
|
)} |
|
|
|
|
|
|
|
|
|
<div |
|
|
|
|
className="d-flex" |
|
|
|
|
style={{ direction: isSelf ? 'rtl' : 'ltr', marginTop: hasavatar ? 0 : 0 }} |
|
|
|
|
style={{ |
|
|
|
|
direction: isSelf ? "rtl" : "ltr", |
|
|
|
|
marginTop: hasavatar ? 0 : 0, |
|
|
|
|
}} |
|
|
|
|
> |
|
|
|
|
<div |
|
|
|
|
className={ |
|
|
|
|
message.type == 'text' |
|
|
|
|
message.type == "text" |
|
|
|
|
? `normal-message__box ` |
|
|
|
|
: `normal-message__box normal-message__box--file` |
|
|
|
|
} |
|
|
|
|
style={{ |
|
|
|
|
paddingTop: hasavatar ? 25 : 15, |
|
|
|
|
backgroundColor: isSelf ? 'white' : 'rgb(220, 248, 198)', |
|
|
|
|
width: 'calc(100%-70px)', |
|
|
|
|
backgroundColor: isSelf ? "white" : "rgb(220, 248, 198)", |
|
|
|
|
width: "calc(100%-70px)", |
|
|
|
|
}} |
|
|
|
|
> |
|
|
|
|
<div |
|
|
|
@ -92,12 +103,15 @@ export default class NormalMessage extends Component { |
|
|
|
|
style={{ |
|
|
|
|
top: 0, |
|
|
|
|
|
|
|
|
|
direction: isSelf ? 'ltr' : 'rtl', |
|
|
|
|
direction: isSelf ? "ltr" : "rtl", |
|
|
|
|
paddingRight: isSelf ? 20 : 20, |
|
|
|
|
paddingLeft: isSelf ? 0 : 0, |
|
|
|
|
}} |
|
|
|
|
> |
|
|
|
|
<div style={{ color: isSelf ? '#aaa' : 'gray' }} onClick={() => addcounter('nothing')}> |
|
|
|
|
<div |
|
|
|
|
style={{ color: isSelf ? "#aaa" : "gray" }} |
|
|
|
|
onClick={() => addcounter("nothing")} |
|
|
|
|
> |
|
|
|
|
<ExpandMoreIcon fontSize="small" onClick={this.handleClick} /> |
|
|
|
|
</div> |
|
|
|
|
<Menu |
|
|
|
@ -113,7 +127,7 @@ export default class NormalMessage extends Component { |
|
|
|
|
onClick={() => { |
|
|
|
|
this.handleClose(); |
|
|
|
|
e.onClick(); |
|
|
|
|
addcounter('nothing'); |
|
|
|
|
addcounter("nothing"); |
|
|
|
|
}} |
|
|
|
|
> |
|
|
|
|
{e.text} |
|
|
|
@ -121,50 +135,67 @@ export default class NormalMessage extends Component { |
|
|
|
|
</MenuItem> |
|
|
|
|
))} |
|
|
|
|
</Menu> |
|
|
|
|
{hasavatar && <div style={{ color: isSelf ? '#aaa' : 'gray' }}>{user.name}</div>} |
|
|
|
|
{hasavatar && ( |
|
|
|
|
<div style={{ color: isSelf ? "#aaa" : "gray" }}> |
|
|
|
|
{user.name} |
|
|
|
|
</div> |
|
|
|
|
)} |
|
|
|
|
</div> |
|
|
|
|
|
|
|
|
|
{message.type == 'text' ? ( |
|
|
|
|
<p style={{ color: isSelf ? 'black' : 'black' }}>{message.text}</p> |
|
|
|
|
{message.type == "text" ? ( |
|
|
|
|
<p style={{ color: isSelf ? "black" : "black" }}> |
|
|
|
|
{message.text} |
|
|
|
|
</p> |
|
|
|
|
) : null} |
|
|
|
|
{message.type == 'voice' ? ( |
|
|
|
|
{message.type == "voice" ? ( |
|
|
|
|
<ReactAudioPlayer src={file(message.fileId)} controls /> |
|
|
|
|
) : null} |
|
|
|
|
{message.type == 'image' ? ( |
|
|
|
|
{message.type == "image" ? ( |
|
|
|
|
<div className="normal-message__box--caption"> |
|
|
|
|
<a href={file(message.fileId)} download> |
|
|
|
|
<img src={file(message.fileId)} download alt="" /> |
|
|
|
|
</a> |
|
|
|
|
<p style={{ color: isSelf ? 'black' : 'black' }}>{message.text}</p> |
|
|
|
|
<p style={{ color: isSelf ? "black" : "black" }}> |
|
|
|
|
{message.text} |
|
|
|
|
</p> |
|
|
|
|
</div> |
|
|
|
|
) : null} |
|
|
|
|
{message.type == 'video' ? ( |
|
|
|
|
{message.type == "video" ? ( |
|
|
|
|
<div className="normal-message__box--caption"> |
|
|
|
|
<a href={file(message.fileId)} download> |
|
|
|
|
<ReactPlayer url={file(message.fileId)} controls width={'100%'} height={250} /> |
|
|
|
|
<ReactPlayer |
|
|
|
|
url={file(message.fileId)} |
|
|
|
|
controls |
|
|
|
|
width={"100%"} |
|
|
|
|
height={250} |
|
|
|
|
/> |
|
|
|
|
</a> |
|
|
|
|
<p style={{ color: isSelf ? 'black' : 'black' }}>{message.text}</p> |
|
|
|
|
<p style={{ color: isSelf ? "black" : "black" }}> |
|
|
|
|
{message.text} |
|
|
|
|
</p> |
|
|
|
|
</div> |
|
|
|
|
) : null} |
|
|
|
|
{message.type == 'audio' ? ( |
|
|
|
|
{message.type == "audio" ? ( |
|
|
|
|
<div className="normal-message__box--caption"> |
|
|
|
|
<ReactAudioPlayer src={file(message.fileId)} controls /> |
|
|
|
|
<p style={{ color: isSelf ? 'black' : 'black' }}>{message.text}</p> |
|
|
|
|
<p style={{ color: isSelf ? "black" : "black" }}> |
|
|
|
|
{message.text} |
|
|
|
|
</p> |
|
|
|
|
</div> |
|
|
|
|
) : null} |
|
|
|
|
{message.type == 'document' ? ( |
|
|
|
|
{message.type == "document" ? ( |
|
|
|
|
<a |
|
|
|
|
href={file(message.fileId)} |
|
|
|
|
download |
|
|
|
|
className="normal-message__box--document d-flex" |
|
|
|
|
style={{ |
|
|
|
|
backgroundColor: isSelf ? 'rgb(15, 93, 190)' : 'white', |
|
|
|
|
color: isSelf ? 'black' : 'black', |
|
|
|
|
backgroundColor: isSelf ? "rgb(15, 93, 190)" : "white", |
|
|
|
|
color: isSelf ? "black" : "black", |
|
|
|
|
}} |
|
|
|
|
> |
|
|
|
|
<CloudDownloadIcon |
|
|
|
|
style={{ |
|
|
|
|
color: isSelf ? 'black' : 'black', |
|
|
|
|
color: isSelf ? "black" : "black", |
|
|
|
|
width: 32, |
|
|
|
|
height: 32, |
|
|
|
|
marginRight: 10, |
|
|
|
@ -174,41 +205,52 @@ export default class NormalMessage extends Component { |
|
|
|
|
</a> |
|
|
|
|
) : null} |
|
|
|
|
|
|
|
|
|
<div className={'normal-message__box--date d-flex ' + (isSelf ? 'self' : '')}> |
|
|
|
|
<span style={{ color: isSelf ? '#aaa' : 'gray' }}> |
|
|
|
|
<div |
|
|
|
|
className={ |
|
|
|
|
"normal-message__box--date d-flex " + (isSelf ? "self" : "") |
|
|
|
|
} |
|
|
|
|
> |
|
|
|
|
<span style={{ color: isSelf ? "#aaa" : "gray" }}> |
|
|
|
|
{message.updatedAt != message.createdAt ? ( |
|
|
|
|
<> |
|
|
|
|
<span> ویرایش در</span> |
|
|
|
|
|
|
|
|
|
{moment(message.updatedAt).format(' hh:mm jMM/jDD')} |
|
|
|
|
{moment(message.updatedAt).format(" hh:mm jMM/jDD")} |
|
|
|
|
</> |
|
|
|
|
) : ( |
|
|
|
|
moment(message.createdAt).format('hh:mm') |
|
|
|
|
moment(message.createdAt).format("hh:mm") |
|
|
|
|
)} |
|
|
|
|
</span> |
|
|
|
|
<span |
|
|
|
|
style={{ |
|
|
|
|
color: isSelf ? '#aaa' : 'gray', |
|
|
|
|
padding: '0 2px', |
|
|
|
|
color: isSelf ? "#aaa" : "gray", |
|
|
|
|
padding: "0 2px", |
|
|
|
|
}} |
|
|
|
|
> |
|
|
|
|
{isSelf && message.status == 0 && <ScheduleIcon fontSize="small" />} |
|
|
|
|
{isSelf && message.status == 0 && ( |
|
|
|
|
<ScheduleIcon fontSize="small" /> |
|
|
|
|
)} |
|
|
|
|
{isSelf && message.status == 2 && <DoneIcon fontSize="small" />} |
|
|
|
|
{isSelf && message.status == 1 && ( |
|
|
|
|
<DoneAllIcon fontSize="small" style={{ color: '#00afea', fontSize: '17px' }} /> |
|
|
|
|
<DoneAllIcon |
|
|
|
|
fontSize="small" |
|
|
|
|
style={{ color: "#00afea", fontSize: "17px" }} |
|
|
|
|
/> |
|
|
|
|
)} |
|
|
|
|
</span> |
|
|
|
|
</div> |
|
|
|
|
</div> |
|
|
|
|
|
|
|
|
|
<div className={isSelf ? 'icons self' : 'icons'} onClick={() => addcounter('nothing')}> |
|
|
|
|
<div |
|
|
|
|
className={isSelf ? "icons self" : "icons"} |
|
|
|
|
onClick={() => addcounter("nothing")} |
|
|
|
|
> |
|
|
|
|
{!isSelf ? ( |
|
|
|
|
<> |
|
|
|
|
{' '} |
|
|
|
|
{" "} |
|
|
|
|
<div> |
|
|
|
|
<span> {10}</span> |
|
|
|
|
<FavoriteIcon fontSize="samall" color="primary" /> |
|
|
|
|
|
|
|
|
|
</div> |
|
|
|
|
<div> |
|
|
|
|
<span> {10}</span> |
|
|
|
@ -231,10 +273,10 @@ export default class NormalMessage extends Component { |
|
|
|
|
<div |
|
|
|
|
className="f-flex keys" |
|
|
|
|
style={{ |
|
|
|
|
width: 'calc(100% - 70px)', |
|
|
|
|
width: "calc(100% - 70px)", |
|
|
|
|
marginRight: isSelf ? 0 : 70, |
|
|
|
|
marginLeft: isSelf ? 70 : 0, |
|
|
|
|
alignSelf: isSelf ? 'flex-end' : 'flex-start', |
|
|
|
|
alignSelf: isSelf ? "flex-end" : "flex-start", |
|
|
|
|
}} |
|
|
|
|
> |
|
|
|
|
{children} |
|
|
|
|