关闭会话: 传参

dev/chat
Lei OT 2 years ago
parent 0e257d93f1
commit 92c5a8636d

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

Loading…
Cancel
Save