|
@@ -5,6 +5,7 @@ import ListItemText from '@mui/material/ListItemText';
|
|
|
import ListItemIcon from '@mui/material/ListItemIcon';
|
|
|
import { styled } from '@mui/material/styles';
|
|
|
import Badge from '@mui/material/Badge';
|
|
|
+import VolumeOffIcon from '@mui/icons-material/VolumeOff';
|
|
|
import { makeStyles, Typography } from '@material-ui/core'
|
|
|
import { useState,useEffect } from 'react';
|
|
|
import shortid from 'shortid';
|
|
@@ -69,7 +70,16 @@ const useStyles = makeStyles({
|
|
|
backgroundColor: "#959595",
|
|
|
},
|
|
|
},
|
|
|
- listItem: {},
|
|
|
+ listItemInnerText: {
|
|
|
+ display: 'flex',
|
|
|
+ alignContent: 'center',
|
|
|
+ alignItems: 'center',
|
|
|
+ flexWrap: 'nowrap',
|
|
|
+ },
|
|
|
+ listItemInnerText__icon: {
|
|
|
+ marginLeft: 5,
|
|
|
+ color: '#959595',
|
|
|
+ },
|
|
|
listItem_iconAvatar: {
|
|
|
marginRight:10
|
|
|
},
|
|
@@ -106,6 +116,24 @@ const useStyles = makeStyles({
|
|
|
'&:hover': {
|
|
|
outline: 'solid 3px #3ee415',
|
|
|
}
|
|
|
+ },
|
|
|
+ listItem_iconRightBtnMute: {
|
|
|
+ background: '#a7aaa7',
|
|
|
+ borderRadius: '50%',
|
|
|
+ color: '#ffffff',
|
|
|
+ border: 'none',
|
|
|
+ height: 24,
|
|
|
+ width: 24,
|
|
|
+ textAlign: 'center',
|
|
|
+ display: 'flex',
|
|
|
+ alignItems: 'center',
|
|
|
+ justifyContent: 'center',
|
|
|
+ alignContent: 'center',
|
|
|
+ fontSize: 12,
|
|
|
+ marginLeft: 'auto',
|
|
|
+ '&:hover': {
|
|
|
+ outline: 'solid 3px #cccbcb',
|
|
|
+ }
|
|
|
},
|
|
|
listItem_iconRightBtnHidden: {
|
|
|
background: 'inherit',
|
|
@@ -132,7 +160,7 @@ const ChatsList = () => {
|
|
|
const classes = useStyles()
|
|
|
const dispatch = useDispatch()
|
|
|
const [selectedIndex, setSelectedIndex] = useState<number>(1);
|
|
|
- const { total, chats , lastMessages } = useSelector(getState)
|
|
|
+ const { total, chats , lastMessages,lastOnline } = useSelector(getState)
|
|
|
|
|
|
|
|
|
const handleListItemClick = async (i: number, companionId: string) => {
|
|
@@ -154,19 +182,19 @@ const ChatsList = () => {
|
|
|
useEffect(() => {
|
|
|
dispatch(asyncGetChats())
|
|
|
}, [dispatch])
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
return total !== '0' ? (
|
|
|
<List className={classes.list} component="nav"
|
|
|
aria-label="main mailbox folders">
|
|
|
- {chats.map(({name, lastName, avatarUrl, updatedAt, color,companionId,online }, i: number) =>
|
|
|
+ {chats.map(({name, lastName, avatarUrl, updatedAt, color,companionId,mute }, i: number) =>
|
|
|
<ListItemButton
|
|
|
- className={classes.listItem}
|
|
|
key={shortid.generate()}
|
|
|
selected={selectedIndex === i}
|
|
|
- onClick={(e) => handleListItemClick(i,companionId)}
|
|
|
+ onClick={() => handleListItemClick(i,companionId)}
|
|
|
>
|
|
|
<ListItemIcon className={classes.listItem_iconAvatar}>
|
|
|
- <StyledBadge overlap="circular" variant={online === 'true'?'dot':'standard'}
|
|
|
+ <StyledBadge overlap="circular" variant={lastOnline[i].online === 'true'?'dot':'standard'}
|
|
|
anchorOrigin={{ vertical: 'bottom', horizontal: 'right' }}>
|
|
|
<Avatar alt={name} src={avatarUrl?`http://localhost:3000/${avatarUrl}`:undefined}
|
|
|
sx={{ background: color, width: 54, height: 54 }}>
|
|
@@ -174,18 +202,21 @@ const ChatsList = () => {
|
|
|
</Avatar>
|
|
|
</StyledBadge>
|
|
|
</ListItemIcon>
|
|
|
- <ListItemText primary={`${firstLetter(name)}${slicedWord(name, 15, 1)}
|
|
|
- ${firstLetter(lastName)}${slicedWord(lastName, 15, 1)}`}
|
|
|
+ <ListItemText primary={<div className={classes.listItemInnerText}>
|
|
|
+ <span>{`${firstLetter(name)}${slicedWord(name, 15, 1)}
|
|
|
+ ${firstLetter(lastName)}${slicedWord(lastName, 15, 1)}`}</span>
|
|
|
+ {mute&&<VolumeOffIcon className={classes.listItemInnerText__icon} fontSize='small' />}</div>}
|
|
|
secondary={lastMessages[i] ? slicedWord(lastMessages[i].message, 35) :
|
|
|
`${firstLetter(name)}${slicedWord(name, 8, 1)} joined Telegram`} />
|
|
|
<ListItemIcon className={classes.listItem_iconRight}>
|
|
|
<div className={classes.listItem_iconTimeChecked}>
|
|
|
<img alt='double check' width="16" height='16' src={doubleCheck} />
|
|
|
<Typography className={classes.listItem_icon_time} variant="h6" color="initial">
|
|
|
- {timeStamp(updatedAt)}</Typography>
|
|
|
+ {lastMessages[i] ? timeStamp(lastMessages[i].updatedAt) :
|
|
|
+ timeStamp(updatedAt)}</Typography>
|
|
|
</div>
|
|
|
{lastMessages[i] ? <button onClick={(e) => handleNewMsgS(e, i)}
|
|
|
- className={classes.listItem_iconRightBtn}>0</button> :
|
|
|
+ className={mute?classes.listItem_iconRightBtnMute:classes.listItem_iconRightBtn}>0</button> :
|
|
|
<button className={classes.listItem_iconRightBtnHidden}/>}
|
|
|
</ListItemIcon>
|
|
|
</ListItemButton>)}
|