fix(weChat/ckchat): 修复切换联系人时未重置未读计数的问题
在切换联系人时,确保会话的未读计数被正确重置为0。将重置逻辑统一移至addChatSession方法中处理,避免遗漏。
This commit is contained in:
@@ -9,7 +9,6 @@ import {
|
|||||||
} from "@/pages/pc/ckbox/data";
|
} from "@/pages/pc/ckbox/data";
|
||||||
import { kfUserService, weChatGroupService, contractService } from "@/utils/db";
|
import { kfUserService, weChatGroupService, contractService } from "@/utils/db";
|
||||||
import { createContractList } from "@/store/module/ckchat/api";
|
import { createContractList } from "@/store/module/ckchat/api";
|
||||||
import { deepCopy } from "@/utils/common";
|
|
||||||
|
|
||||||
export const useCkChatStore = createPersistStore<CkChatState>(
|
export const useCkChatStore = createPersistStore<CkChatState>(
|
||||||
set => ({
|
set => ({
|
||||||
@@ -363,6 +362,7 @@ export const useCkChatStore = createPersistStore<CkChatState>(
|
|||||||
})(),
|
})(),
|
||||||
// 添加聊天会话
|
// 添加聊天会话
|
||||||
addChatSession: (session: ContractData | weChatGroup) => {
|
addChatSession: (session: ContractData | weChatGroup) => {
|
||||||
|
session.unreadCount = 0;
|
||||||
set(state => {
|
set(state => {
|
||||||
// 检查是否已存在相同id的会话
|
// 检查是否已存在相同id的会话
|
||||||
const exists = state.chatSessions.some(item => item.id === session.id);
|
const exists = state.chatSessions.some(item => item.id === session.id);
|
||||||
|
|||||||
@@ -24,7 +24,6 @@ export const useWeChatStore = create<WeChatState>()(
|
|||||||
// 切换联系人时清空当前消息,等待重新加载
|
// 切换联系人时清空当前消息,等待重新加载
|
||||||
set({ currentMessages: [] });
|
set({ currentMessages: [] });
|
||||||
clearUnreadCount([contract.id]).then(() => {
|
clearUnreadCount([contract.id]).then(() => {
|
||||||
contract.unreadCount = 0;
|
|
||||||
addChatSession(contract);
|
addChatSession(contract);
|
||||||
set({ currentContract: contract });
|
set({ currentContract: contract });
|
||||||
updateConfig({
|
updateConfig({
|
||||||
|
|||||||
Reference in New Issue
Block a user