diff --git a/src/hooks/useConversation.js b/src/hooks/useConversation.js index 7f2c693..d55b92d 100644 --- a/src/hooks/useConversation.js +++ b/src/hooks/useConversation.js @@ -1,3 +1,4 @@ +import useAuthStore from '@/stores/AuthStore'; import useConversationStore from '@/stores/ConversationStore'; import { fetchOrderConversationsList, postNewConversationItem } from '@/actions/ConversationActions'; import { isEmpty } from '@/utils/commons'; @@ -8,6 +9,7 @@ export function useConversationNewItem() { ]); const conversationsList = useConversationStore((state) => state.conversationsList); const addToConversationList = useConversationStore((state) => state.addToConversationList); + const userId = useAuthStore((state) => state.loginUser.userId); /** * 打开订单的会话, 不存在自动新增 */ @@ -42,7 +44,7 @@ export function useConversationNewItem() { const newConversation = async (whatsappID, whatsappName = '') => { const { opi_sn } = currentConversation; const newChat = { phone_number: whatsappID, remark_name: whatsappName }; - const createdNew = await postNewConversationItem({ ...newChat, opi_sn: opi_sn }); + const createdNew = await postNewConversationItem({ ...newChat, opi_sn: opi_sn || userId }); addToConversationList([createdNew]); setCurrentConversation(createdNew); };