|
|
|
@ -16,38 +16,31 @@ import { ChatList, } from 'react-chat-elements';
|
|
|
|
|
import { isEmpty, pick } from '@/utils/utils';
|
|
|
|
|
import { v4 as uuid } from 'uuid';
|
|
|
|
|
|
|
|
|
|
const CDropdown = () => {
|
|
|
|
|
const { loginUser } = useAuthContext();
|
|
|
|
|
const { userId } = loginUser;
|
|
|
|
|
const { currentConversation } = useConversationState();
|
|
|
|
|
const CDropdown = (props) => {
|
|
|
|
|
const dispatch = useConversationDispatch();
|
|
|
|
|
const handleConversationItemClose = async (item) => {
|
|
|
|
|
console.log('invoke close', {conversationid: item.sn, opisn: userId });
|
|
|
|
|
// await fetchConversationItemClose({ conversationid: item.sn, opisn: userId });
|
|
|
|
|
dispatch(delConversationitem(item));
|
|
|
|
|
|
|
|
|
|
const handleConversationItemClose = async () => {
|
|
|
|
|
await fetchConversationItemClose({ conversationid: props.sn, opisn: props.opi_sn });
|
|
|
|
|
dispatch(delConversationitem(props));
|
|
|
|
|
};
|
|
|
|
|
return (
|
|
|
|
|
<Dropdown key={'more-action'}
|
|
|
|
|
<Dropdown
|
|
|
|
|
key={'more-action'}
|
|
|
|
|
trigger={'click'}
|
|
|
|
|
menu={{
|
|
|
|
|
items: [
|
|
|
|
|
{
|
|
|
|
|
key: 'close',
|
|
|
|
|
danger: true,
|
|
|
|
|
label: '关闭会话',
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
onClick: ({ key }) => {
|
|
|
|
|
switch (key) {
|
|
|
|
|
items: [{ key: 'close', danger: true, label: '关闭会话' }],
|
|
|
|
|
onClick: (e) => {
|
|
|
|
|
e.domEvent.stopPropagation();
|
|
|
|
|
switch (e.key) {
|
|
|
|
|
case 'close':
|
|
|
|
|
return handleConversationItemClose(currentConversation);
|
|
|
|
|
return handleConversationItemClose();
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
}}>
|
|
|
|
|
<Button key={'More'} type='text' title='More' className=' rounded-none text-gray-400' icon={<MoreOutlined />} size={'middle'} onClick={e => e.stopPropagation() } />
|
|
|
|
|
<Button key={'More'} type='text' title='More' className=' rounded-none text-gray-400' icon={<MoreOutlined />} size={'middle'} onClick={(e) => e.stopPropagation()} />
|
|
|
|
|
</Dropdown>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
@ -81,7 +74,7 @@ const Conversations = () => {
|
|
|
|
|
// statusColorType: 'badge',
|
|
|
|
|
// statusText: 'online',
|
|
|
|
|
className: String(item.sn) === String(currentConversation.sn) ? '__active text-primary underline bg-whatsapp-me ' : '',
|
|
|
|
|
customStatusComponents: [CDropdown],
|
|
|
|
|
customStatusComponents: [() => CDropdown(item)],
|
|
|
|
|
}))
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
@ -131,6 +124,7 @@ const Conversations = () => {
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
const switchConversation = async (item) => {
|
|
|
|
|
console.log('invoke switch');
|
|
|
|
|
if (String(item.sn) === String(currentConversation.sn)) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|