diff --git a/shared/api/socket.ts b/shared/api/socket.ts index a1fd8f4e..42871d7a 100644 --- a/shared/api/socket.ts +++ b/shared/api/socket.ts @@ -30,7 +30,7 @@ export class AppSocket { const matched = this.listener.filter(([ev]) => ev === eventName); // 匹配到的监听器列表 if (matched.length === 0) { // 没有匹配到任何处理函数 - console.warn(`[Socket IO] Unhandler event: ${eventName}`); + console.warn(`[Socket IO] Unhandler event: ${eventName}`, data); return; } diff --git a/shared/redux/setup.ts b/shared/redux/setup.ts index 2434e1ab..c46c895d 100644 --- a/shared/redux/setup.ts +++ b/shared/redux/setup.ts @@ -69,4 +69,8 @@ function listenNotify(socket: AppSocket, store: AppStore) { store.dispatch(userActions.removeFriendRequest(requestId)); } ); + + socket.listen('group.updateInfo', (groupInfo) => { + store.dispatch(groupActions.updateGroup(groupInfo)); + }); } diff --git a/shared/redux/slices/group.ts b/shared/redux/slices/group.ts index ecd12680..889f5abf 100644 --- a/shared/redux/slices/group.ts +++ b/shared/redux/slices/group.ts @@ -23,6 +23,14 @@ const groupSlice = createSlice({ }; } }, + updateGroup(state, action: PayloadAction) { + const group = action.payload; + const groupId = group._id; + state.groups[groupId] = { + ...state.groups[groupId], + ...group, + }; + }, }, });