perf: 新建会话: 加到列表顶部, 置顶的下面

2.0/email-builder
Lei OT 10 months ago
parent ee60c4fff4
commit 9bda8945da

@ -79,12 +79,13 @@ export function useConversationNewItem() {
} }
const createdNew = await postNewOrEditConversationItem({ ...newChat, opisn: opisn || userId, conversationid }); const createdNew = await postNewOrEditConversationItem({ ...newChat, opisn: opisn || userId, conversationid });
// addToConversationList([{...createdNew, sn: createdNew.conversationid}]); // addToConversationList([{...createdNew, sn: createdNew.conversationid}]);
const _list = await fetchConversationsList({ opisn }); // const _list = await fetchConversationsList({ opisn });
addToConversationList(_list); // addToConversationList(_list, 'top');
if (!body.conversationid) { if (isEmpty(body.conversationid)) {
const newChat = _list.find((item) => item.sn === createdNew.conversationid) // const newChat = _list.find((item) => item.sn === createdNew.conversationid)
if (isEmpty(newChat)) { const newChat = createdNew;
setCurrentConversation({ if (!isEmpty(newChat)) {
const buildChatItem = {
...CHAT_ITEM_RECORD, ...CHAT_ITEM_RECORD,
...createdNew, ...createdNew,
sn: createdNew.conversationid, sn: createdNew.conversationid,
@ -96,13 +97,16 @@ export function useConversationNewItem() {
conversation_memo: createdNew.remark, conversation_memo: createdNew.remark,
lasttime: createdNew.session_creatime, lasttime: createdNew.session_creatime,
show_default: createdNew.remark || createdNew.guest_name || createdNew.guest_phone || createdNew.guest_email || createdNew.whatsapp_phone_number || '', show_default: createdNew.remark || createdNew.guest_name || createdNew.guest_phone || createdNew.guest_email || createdNew.whatsapp_phone_number || '',
}) }
setCurrentConversation(buildChatItem);
addToConversationList([buildChatItem], 'top');
return ; return ;
} }
setCurrentConversation({ // setCurrentConversation({
...newChat, // ...newChat,
show_default: newChat.conversation_memo || newChat.whatsapp_name || newChat?.channels?.whatsapp_phone_number || newChat?.channels?.phone_number || newChat?.channels?.email || '', // show_default: newChat.conversation_memo || newChat.whatsapp_name || newChat?.channels?.whatsapp_phone_number || newChat?.channels?.phone_number || newChat?.channels?.email || '',
}) // })
return ; return ;
} }
}; };

@ -38,9 +38,12 @@ const MessagesHeader = () => {
<Flex vertical={false} gap={12} justify='space-between'> <Flex vertical={false} gap={12} justify='space-between'>
{(currentConversation.coli_sn || currentConversation.sn) ? ( {(currentConversation.coli_sn || currentConversation.sn) ? (
<> <>
<Typography.Text strong>{currentConversation.customer_name}</Typography.Text> <Typography.Text strong>{currentConversation.show_default}</Typography.Text>
{currentConversation.sn ? ( {currentConversation.sn ? (
<Typography.Text>{currentConversation.show_default}</Typography.Text> <>
<Typography.Text>{currentConversation?.channels?.whatsapp_phone_number}</Typography.Text>
<Typography.Text>{currentConversation?.channels?.email}</Typography.Text>
</>
) : ( ) : (
<Typography.Text strong type='danger'> <Typography.Text strong type='danger'>
没有WhatsApp号码 没有WhatsApp号码

Loading…
Cancel
Save