feat(微信): 添加wechatChatroomId字段并优化消息处理逻辑
- 在weChatGroup接口中添加wechatChatroomId字段 - 移除调试用的console.log语句 - 重构消息处理逻辑,简化条件判断并新增会话初始化处理
This commit is contained in:
@@ -91,18 +91,10 @@ export const useWeChatStore = create<WeChatState>()(
|
||||
const currentContract = useWeChatStore.getState().currentContract;
|
||||
//判断群还是好友
|
||||
const getMessageId =
|
||||
currentContract?.chatroomId || message.wechatFriendId;
|
||||
const isGroup = currentContract?.chatroomId;
|
||||
message?.wechatChatroomId || message.wechatFriendId;
|
||||
|
||||
if (
|
||||
currentContract &&
|
||||
currentContract.wechatAccountId == message.wechatAccountId &&
|
||||
currentContract.id == getMessageId
|
||||
) {
|
||||
console.log("进入");
|
||||
if (isGroup) {
|
||||
message.unreadCount = 1;
|
||||
}
|
||||
//当前选中聊天的群或好友
|
||||
if (currentContract && currentContract.id == getMessageId) {
|
||||
set(state => ({
|
||||
currentMessages: [...state.currentMessages, message],
|
||||
}));
|
||||
@@ -113,6 +105,12 @@ export const useWeChatStore = create<WeChatState>()(
|
||||
if (session) {
|
||||
session.unreadCount = Number(session.unreadCount) + 1;
|
||||
updateChatSession(session);
|
||||
} else {
|
||||
// 新增会话
|
||||
addChatSession({
|
||||
...session,
|
||||
unreadCount: 1,
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user