|
|
|
|
@ -304,7 +304,12 @@ const conversationSlice = (set, get) => ({
|
|
|
|
|
// conversationsList: [...conversationsList],
|
|
|
|
|
}));
|
|
|
|
|
},
|
|
|
|
|
updateCurrentConversation: (conversation) => set((state) => ({ currentConversation: { ...state.currentConversation, ...conversation } })),
|
|
|
|
|
updateCurrentConversation: (conversation) => {
|
|
|
|
|
const { updateConversationItem, currentConversation } = get();
|
|
|
|
|
updateConversationItem({...currentConversation, ...conversation})
|
|
|
|
|
|
|
|
|
|
return set((state) => ({ currentConversation: { ...state.currentConversation, ...conversation } }))
|
|
|
|
|
},
|
|
|
|
|
updateConversationItem: (conversation) => {
|
|
|
|
|
const { conversationsList } = get();
|
|
|
|
|
const targetId = conversation.sn;
|
|
|
|
|
@ -443,8 +448,10 @@ const messageSlice = (set, get) => ({
|
|
|
|
|
"whatsapp_phone_number": message.type === 'email' ? null : message.from,
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
conversationsList.splice(targetIndex, 1);
|
|
|
|
|
conversationsList.unshift(newConversation);
|
|
|
|
|
if (String(targetId)!== '0') {
|
|
|
|
|
conversationsList.splice(targetIndex, 1);
|
|
|
|
|
conversationsList.unshift(newConversation);
|
|
|
|
|
}
|
|
|
|
|
// console.log('find in list, i:', targetIndex);
|
|
|
|
|
// console.log('find in list, chat updated and Top: \n', JSON.stringify(newConversation, null, 2));
|
|
|
|
|
// console.log('list updated : \n', JSON.stringify(conversationsList, null, 2));
|
|
|
|
|
|