更新投递成功的时间到会话列表

dev/chat
Lei OT 2 years ago
parent 3f678d09c6
commit 7f0a1dc8e7

@ -188,6 +188,18 @@ const conversationSlice = (set, get) => ({
conversationsList: [...conversationsList],
}));
},
updateConversationItem: (conversation) => {
const { conversationsList } = get();
const targetId = conversation.sn;
const targetIndex = conversationsList.findIndex((ele) => String(ele.sn) === String(targetId));
targetIndex !== -1
? conversationsList.splice(targetIndex, 1, {
...conversationsList[targetIndex],
...conversation,
})
: null;
return set({ conversationsList: [...conversationsList] });
},
});
const messageSlice = (set, get) => ({
@ -204,7 +216,7 @@ const messageSlice = (set, get) => ({
// msgUpdate
console.log('UPDATE_SENT_MESSAGE_ITEM-----------------------------------------------------------------');
// 更新会话中的消息
const { activeConversations } = get();
const { activeConversations, conversationsList } = get();
const targetId = message.conversationid;
const targetMsgs = (activeConversations[String(targetId)] || []).map((ele) => {
// 更新状态
@ -224,17 +236,17 @@ const messageSlice = (set, get) => ({
}
// 更新列表的时间
// if (message.type !== 'error') {
// const targetIndex = conversationsList.findIndex((ele) => String(ele.sn) === String(targetId));
// conversationsList.splice(targetIndex, 1, {
// ...conversationsList[targetIndex],
// last_received_time: message.date,
// });
// }
if (message.status === 'received') { // 'delivered'
const targetIndex = conversationsList.findIndex((ele) => String(ele.sn) === String(targetId));
conversationsList.splice(targetIndex, 1, {
...conversationsList[targetIndex],
last_received_time: message.deliverTime, // todo: 需要+8 hours
});
}
return set({
activeConversations: { ...activeConversations, [String(targetId)]: targetMsgs },
// conversationsList: [...conversationsList],
conversationsList: [...conversationsList],
});
},
sentOrReceivedNewMessage: (targetId, message) => {

Loading…
Cancel
Save