fix(weChat/ckchat): 修复切换联系人时未重置未读计数的问题

在切换联系人时,确保会话的未读计数被正确重置为0。将重置逻辑统一移至addChatSession方法中处理,避免遗漏。
This commit is contained in:
超级老白兔
2025-09-03 18:20:24 +08:00
parent 30cafc5619
commit 7bd7bd3564
2 changed files with 1 additions and 2 deletions

View File

@@ -9,7 +9,6 @@ import {
} from "@/pages/pc/ckbox/data";
import { kfUserService, weChatGroupService, contractService } from "@/utils/db";
import { createContractList } from "@/store/module/ckchat/api";
import { deepCopy } from "@/utils/common";
export const useCkChatStore = createPersistStore<CkChatState>(
set => ({
@@ -363,6 +362,7 @@ export const useCkChatStore = createPersistStore<CkChatState>(
})(),
// 添加聊天会话
addChatSession: (session: ContractData | weChatGroup) => {
session.unreadCount = 0;
set(state => {
// 检查是否已存在相同id的会话
const exists = state.chatSessions.some(item => item.id === session.id);

View File

@@ -24,7 +24,6 @@ export const useWeChatStore = create<WeChatState>()(
// 切换联系人时清空当前消息,等待重新加载
set({ currentMessages: [] });
clearUnreadCount([contract.id]).then(() => {
contract.unreadCount = 0;
addChatSession(contract);
set({ currentContract: contract });
updateConfig({