更新 weChatGroup 接口,新增 top 字段为可选项,调整 unreadCount 字段为可选;修改 getNewContractList 方法返回类型为 Promise;新增 addCtrlUser 方法以控制终端用户;修复 deleteChatSession 方法参数类型为 number。
This commit is contained in:
@@ -115,8 +115,9 @@ export interface weChatGroup {
|
||||
chatroomAvatar: string;
|
||||
groupId: number;
|
||||
config?: {
|
||||
top?: false;
|
||||
chat?: boolean;
|
||||
unreadCount: number;
|
||||
unreadCount?: number;
|
||||
};
|
||||
labels?: string[];
|
||||
notice: string;
|
||||
|
||||
@@ -113,11 +113,11 @@ export interface weChatGroup {
|
||||
chatroomAvatar: string;
|
||||
groupId: number;
|
||||
config?: {
|
||||
top?: false;
|
||||
chat?: boolean;
|
||||
unreadCount: number;
|
||||
};
|
||||
labels?: string[];
|
||||
|
||||
notice: string;
|
||||
selfDisplyName: string;
|
||||
wechatChatroomId: number;
|
||||
|
||||
@@ -46,7 +46,7 @@ export interface CkChatState {
|
||||
newContractList: ContactGroupByLabel[];
|
||||
getContractList: () => ContractData[];
|
||||
getSomeContractList: (kfSelected: number) => ContractData[];
|
||||
getNewContractList: () => ContactGroupByLabel[];
|
||||
getNewContractList: () => Promise<ContactGroupByLabel[]>;
|
||||
setSearchKeyword: (keyword: string) => void;
|
||||
clearSearchKeyword: () => void;
|
||||
asyncKfSelected: (data: number) => void;
|
||||
|
||||
@@ -37,7 +37,7 @@ export const useCkChatStore = createPersistStore<CkChatState>(
|
||||
set({ kfUserList: data });
|
||||
},
|
||||
// 获取客服列表
|
||||
getkfUserList: async () => {
|
||||
getkfUserList: () => {
|
||||
const state = useCkChatStore.getState();
|
||||
return state.kfUserList;
|
||||
},
|
||||
@@ -330,6 +330,12 @@ export const useCkChatStore = createPersistStore<CkChatState>(
|
||||
clearkfUserList: () => {
|
||||
set({ kfUserList: [] });
|
||||
},
|
||||
// 添加控制终端用户
|
||||
addCtrlUser: (user: KfUserListData) => {
|
||||
set(state => ({
|
||||
kfUserList: [...state.kfUserList, user],
|
||||
}));
|
||||
},
|
||||
// 获取聊天会话 - 使用缓存避免无限循环
|
||||
getChatSessions: (() => {
|
||||
let cachedResult: any = null;
|
||||
@@ -492,8 +498,8 @@ export const useCkChatStore = createPersistStore<CkChatState>(
|
||||
isLoggedIn: state.isLoggedIn,
|
||||
kfUserList: state.kfUserList,
|
||||
}),
|
||||
onRehydrateStorage: () => state => {
|
||||
// console.log("CkChat store hydrated:", state);
|
||||
onRehydrateStorage: () => () => {
|
||||
// console.log("CkChat store hydrated");
|
||||
},
|
||||
},
|
||||
);
|
||||
@@ -510,7 +516,7 @@ export const addChatSession = (session: ContractData | weChatGroup) =>
|
||||
useCkChatStore.getState().addChatSession(session);
|
||||
export const updateChatSession = (session: ContractData | weChatGroup) =>
|
||||
useCkChatStore.getState().updateChatSession(session);
|
||||
export const deleteChatSession = (sessionId: string) =>
|
||||
export const deleteChatSession = (sessionId: number) =>
|
||||
useCkChatStore.getState().deleteChatSession(sessionId);
|
||||
export const getkfUserList = () => useCkChatStore.getState().kfUserList;
|
||||
export const addCtrlUser = (user: KfUserListData) =>
|
||||
|
||||
Reference in New Issue
Block a user