fix: 创建会话, 没有user ID

hotfix/new-conversation
Lei OT 11 months ago
parent 164d09fc6d
commit 1ef696cb19

@ -1,3 +1,4 @@
import useAuthStore from '@/stores/AuthStore';
import useConversationStore from '@/stores/ConversationStore'; import useConversationStore from '@/stores/ConversationStore';
import { fetchOrderConversationsList, postNewConversationItem } from '@/actions/ConversationActions'; import { fetchOrderConversationsList, postNewConversationItem } from '@/actions/ConversationActions';
import { isEmpty } from '@/utils/commons'; import { isEmpty } from '@/utils/commons';
@ -8,6 +9,7 @@ export function useConversationNewItem() {
]); ]);
const conversationsList = useConversationStore((state) => state.conversationsList); const conversationsList = useConversationStore((state) => state.conversationsList);
const addToConversationList = useConversationStore((state) => state.addToConversationList); 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 newConversation = async (whatsappID, whatsappName = '') => {
const { opi_sn } = currentConversation; const { opi_sn } = currentConversation;
const newChat = { phone_number: whatsappID, remark_name: whatsappName }; 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]); addToConversationList([createdNew]);
setCurrentConversation(createdNew); setCurrentConversation(createdNew);
}; };

Loading…
Cancel
Save