|
@@ -6,7 +6,7 @@ import Popover from '@mui/material/Popover';
|
|
|
import List from '@mui/material/List';
|
|
|
import ListItemButton from '@mui/material/ListItemButton';
|
|
|
import { connect } from 'react-redux'
|
|
|
-import { dateFromStamp, stringColor, backURL, decorateLinks } from '../helpers'
|
|
|
+import { dateFromStamp, stringColor, backURL } from '../helpers'
|
|
|
|
|
|
import { UserAvatar, CMyAvatar } from '.'
|
|
|
|
|
@@ -127,13 +127,14 @@ const textDownload = {
|
|
|
}
|
|
|
|
|
|
|
|
|
+
|
|
|
const Msg = ({ msg, myProfile, onEdit }) => {
|
|
|
|
|
|
const myId = myProfile?._id || null
|
|
|
const myLogin = myProfile?.login || null
|
|
|
const myNick = myProfile?.nick || null
|
|
|
|
|
|
- const { _id, text, owner, media, createdAt, nextOwner, nextTime } = msg
|
|
|
+ const { _id, text, owner, media, createdAt, nextMsg } = msg
|
|
|
const { nick, login, avatar } = owner
|
|
|
|
|
|
const allMedia = {}
|
|
@@ -153,30 +154,24 @@ const Msg = ({ msg, myProfile, onEdit }) => {
|
|
|
|
|
|
|
|
|
const [anchorEl, setAnchorEl] = useState(null)
|
|
|
- // const [top, setTop] = useState(0)
|
|
|
- // const [left, setLeft] = useState(0)
|
|
|
+ const [top, setTop] = useState(0)
|
|
|
+ const [left, setLeft] = useState(0)
|
|
|
|
|
|
const handleClick = (e) => {
|
|
|
- // e.preventDefault()
|
|
|
- // console.log(e)
|
|
|
- // if (e.button === 2) {
|
|
|
- // console.log('dasdadasdas')
|
|
|
- // }
|
|
|
- // console.log(e.pageX - e.target.offsetLeft, e.pageY - e.target.offsetTop)
|
|
|
- // console.log(e.target.offsetTop, e.target.offsetLeft)
|
|
|
-
|
|
|
- // setTop(e.clientY)
|
|
|
- // setLeft(e.clientX)
|
|
|
+ e.preventDefault()
|
|
|
+ setTop(e.clientY)
|
|
|
+ setLeft(e.clientX)
|
|
|
setAnchorEl(e.currentTarget)
|
|
|
-
|
|
|
}
|
|
|
|
|
|
const handleClose = () => {
|
|
|
setAnchorEl(null)
|
|
|
}
|
|
|
|
|
|
- const open = Boolean(anchorEl);
|
|
|
-
|
|
|
+ const open = !!anchorEl
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
const nameBlockNew = {...nameBlock, color: stringColor.stringToColor(nick || login)}
|
|
|
return (
|
|
@@ -185,14 +180,11 @@ const Msg = ({ msg, myProfile, onEdit }) => {
|
|
|
open={open}
|
|
|
anchorEl={anchorEl}
|
|
|
onClose={handleClose}
|
|
|
- anchorOrigin={{
|
|
|
- vertical: 'bottom',
|
|
|
- horizontal: 'left',
|
|
|
+ anchorReference={'anchorPosition'}
|
|
|
+ anchorPosition={{
|
|
|
+ top: top,
|
|
|
+ left: left
|
|
|
}}
|
|
|
- // anchorPosition={{
|
|
|
- // top: 300,
|
|
|
- // left: 300
|
|
|
- // }}
|
|
|
>
|
|
|
|
|
|
<List sx={{ width: '100%', maxWidth: 300, bgcolor: 'background.paper' }}>
|
|
@@ -213,7 +205,6 @@ const Msg = ({ msg, myProfile, onEdit }) => {
|
|
|
</ListItemButton>
|
|
|
}
|
|
|
|
|
|
-
|
|
|
</List>
|
|
|
|
|
|
|
|
@@ -222,16 +213,16 @@ const Msg = ({ msg, myProfile, onEdit }) => {
|
|
|
<div onClick={handleClick}
|
|
|
|
|
|
style={ (myId === owner._id) ?
|
|
|
- ( (nextOwner === owner._id) ?
|
|
|
+ ( (nextMsg?.owner?._id === owner._id) ?
|
|
|
{...myMsgBlock, marginBottom: "2px"} : {...myMsgBlock, marginBottom: "15px"}) :
|
|
|
- ( (nextOwner === owner._id) ?
|
|
|
+ ( (nextMsg?.owner?._id === owner._id) ?
|
|
|
{...msgBlock, marginBottom: "2px"} : {...msgBlock, marginBottom: "15px"})
|
|
|
}
|
|
|
>
|
|
|
|
|
|
<div style={avBlock} >
|
|
|
- { (nextOwner === owner._id &&
|
|
|
- nextTime - createdAt < 600000) ||
|
|
|
+ { (nextMsg?.owner?._id === owner._id &&
|
|
|
+ nextMsg?.createdAt - createdAt < 600000) ||
|
|
|
( (myId === owner._id) ?
|
|
|
<CMyAvatar /> :
|
|
|
<UserAvatar profile={owner} /> ) }
|
|
@@ -308,7 +299,7 @@ const Msg = ({ msg, myProfile, onEdit }) => {
|
|
|
</div>
|
|
|
}
|
|
|
|
|
|
- <pre style={textBlock}>
|
|
|
+ <pre style={textBlock} >
|
|
|
{text}
|
|
|
</pre>
|
|
|
|
|
@@ -324,52 +315,3 @@ const Msg = ({ msg, myProfile, onEdit }) => {
|
|
|
}
|
|
|
export const CMsg = connect( state => ({ myProfile: state.promise.myProfile?.payload || {}}))(Msg)
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-//tg
|
|
|
-
|
|
|
-{/* <div class="media-inner dark interactive" style="">
|
|
|
- <canvas class="thumbnail" width="1304" height="720" style="width: 480px; height: 265px;">
|
|
|
- </canvas>
|
|
|
- <img class="thumbnail opacity-transition slow" alt=""
|
|
|
- draggable="true" style="width: 480px; height: 265px;">
|
|
|
- <video class="full-media" width="480" height="265" autoplay="" loop="" playsinline="" draggable="true">
|
|
|
- <source src="blob:https://web.telegram.org/464cc156-4e7f-415e-bec5-5fdf5b6c2d98">
|
|
|
- </video>
|
|
|
- <div class="message-media-duration">5:27</div>
|
|
|
-</div> */}
|
|
|
-
|
|
|
-
|
|
|
-{/* <div class="File interactive">
|
|
|
- <div class="file-icon-container">
|
|
|
- <div class="file-icon orange">
|
|
|
- <span class="file-ext" dir="auto">
|
|
|
- zip
|
|
|
- </span>
|
|
|
- </div>
|
|
|
- <i class="action-icon icon-download"></i>
|
|
|
- </div>
|
|
|
- <div class="file-info">
|
|
|
- <div class="file-title" dir="auto">2.1 01-02.zip</div>
|
|
|
- <div class="file-subtitle" dir="auto">
|
|
|
- <span>0.6 KB</span>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- </div> */}
|