|
@@ -12,11 +12,11 @@ import ListItemText from '@mui/material/ListItemText';
|
|
|
import ListItemIcon from '@mui/material/ListItemIcon';
|
|
|
import Badge from '@mui/material/Badge';
|
|
|
import DoneAllIcon from '@mui/icons-material/DoneAll';
|
|
|
-import PushPinIcon from '@mui/icons-material/PushPin';
|
|
|
|
|
|
-import { muteChat,removeChatForBoth } from '../../../../../api-data';
|
|
|
+import { muteChat } from '../../../../../api-data';
|
|
|
import { TChat } from '../../../../../typescript/redux/chats/types';
|
|
|
-import { firstLetter,slicedWord,timeStampEU } from '../../../../../helpers';
|
|
|
+import { firstLetter, slicedWord, timeStampEU } from '../../../../../helpers';
|
|
|
+import DeleteModal from './DeleteModal';
|
|
|
|
|
|
const StyledMenu = styled((props:any) => (
|
|
|
<Menu
|
|
@@ -196,13 +196,14 @@ const ChatItem = ({chat,handleListItemClick,handleNewMsgs}:IChatItem) => {
|
|
|
const classes = useStyles()
|
|
|
const [anchorEl, setAnchorEl] = useState<any>(null);
|
|
|
const [selected, setSelected] = useState<boolean>(false);
|
|
|
+ const [modal, setModal] = useState<boolean>(false);
|
|
|
const open = Boolean(anchorEl);
|
|
|
const { name, lastName, avatarUrl, color, companionId, mute, seen, total, watched,
|
|
|
typing, online, lastMessage, lastMessageCreatedAt, createdAt } = chat
|
|
|
|
|
|
const handleClose = (type: string | undefined): void => {
|
|
|
if (type === 'mute') muteChat(companionId)
|
|
|
- if (type === 'delete') removeChatForBoth(companionId)
|
|
|
+ if (type === 'delete') setModal(true)
|
|
|
setAnchorEl(null)
|
|
|
setSelected(false)
|
|
|
}
|
|
@@ -214,6 +215,7 @@ const ChatItem = ({chat,handleListItemClick,handleNewMsgs}:IChatItem) => {
|
|
|
|
|
|
return (
|
|
|
<div>
|
|
|
+ {modal&&<DeleteModal setModal={setModal} chat={chat}/>}
|
|
|
<ListItemButton
|
|
|
selected={selected}
|
|
|
onClick={() => handleListItemClick(companionId)}
|
|
@@ -254,11 +256,7 @@ const ChatItem = ({chat,handleListItemClick,handleNewMsgs}:IChatItem) => {
|
|
|
anchorEl={anchorEl}
|
|
|
open={open}
|
|
|
onClose={handleClose}
|
|
|
- >
|
|
|
- <MenuItem onClick={() => handleClose('pin')}>
|
|
|
- <PushPinIcon />
|
|
|
- Pin to top
|
|
|
- </MenuItem>
|
|
|
+ >
|
|
|
<MenuItem onClick={() => handleClose('mute')}>
|
|
|
{mute ? <NotificationsNoneIcon /> : <VolumeOffIcon />}
|
|
|
{mute ? 'Unmute chat':'Mute chat'}
|