diff --git a/client/shared/model/group.ts b/client/shared/model/group.ts index ede5cd7b..e06f0168 100644 --- a/client/shared/model/group.ts +++ b/client/shared/model/group.ts @@ -10,6 +10,9 @@ export const groupConfigNames = [ // 隐藏群组成员标识位 'hideGroupMemberDiscriminator', + // 禁止从群组中发起私信 + 'disableCreateConverseFromGroup', + // 群组背景图 'groupBackgroundImage', ] as const; diff --git a/client/shared/redux/slices/group.ts b/client/shared/redux/slices/group.ts index 7f5d9472..bb4b610f 100644 --- a/client/shared/redux/slices/group.ts +++ b/client/shared/redux/slices/group.ts @@ -75,6 +75,27 @@ const groupSlice = createSlice({ }; } }, + updateGroupConfig( + state, + action: PayloadAction<{ + groupId: string; + configName: string; + configValue: any; + }> + ) { + const { groupId, configName, configValue } = action.payload; + + const groupInfo = state.groups[groupId]; + if (groupInfo) { + state.groups[groupId] = { + ...groupInfo, + config: { + ...(groupInfo.config ?? {}), + [configName]: configValue, + }, + }; + } + }, }, }); diff --git a/client/web/src/components/modals/GroupDetail/Config.tsx b/client/web/src/components/modals/GroupDetail/Config.tsx index fbc54549..510f200b 100644 --- a/client/web/src/components/modals/GroupDetail/Config.tsx +++ b/client/web/src/components/modals/GroupDetail/Config.tsx @@ -1,9 +1,11 @@ import React from 'react'; import { + groupActions, model, showSuccessToasts, t, UploadFileResult, + useAppDispatch, useAsyncRequest, useGroupInfo, } from 'tailchat-shared'; @@ -21,10 +23,18 @@ export const GroupConfig: React.FC<{ }> = React.memo((props) => { const groupId = props.groupId; const groupInfo = useGroupInfo(groupId); + const dispatch = useAppDispatch(); const [{ loading }, handleModifyConfig] = useAsyncRequest( async (configName: model.group.GroupConfigNames, configValue: any) => { await model.group.modifyGroupConfig(groupId, configName, configValue); + dispatch( + groupActions.updateGroupConfig({ + groupId, + configName, + configValue, + }) + ); showSuccessToasts(); }, [groupId]