feat: add group description

limit 120 words
pull/105/head
moonrailgun 2 years ago
parent 59720e716e
commit 065f7d44c8

@ -106,6 +106,7 @@
"k517db7e5": "Text Channel",
"k51db56bf": "Temporary Meeting",
"k52643761": "6-digit OTP code",
"k5343016d": "Modify group description successfully",
"k547a7a99": "This record was not found",
"k551b0348": "Password",
"k56f9469b": "No friends yet",
@ -226,6 +227,7 @@
"ka4dac521": "Are you sure you want to delete role {{name}}?",
"ka50c7408": "Please enter the JSON information manually, if you are not sure what you are doing, please do not use this function",
"ka5616453": "Mute {{length}}, expected until {{until}}",
"ka58c246": "Group Description",
"ka5d64ee9": "Choose the following template and start creating your own group!",
"ka62886b9": "Load File Failed",
"ka64624b1": "Join the group successfully!",

@ -106,6 +106,7 @@
"k517db7e5": "文字频道",
"k51db56bf": "临时会议",
"k52643761": "6位校验码",
"k5343016d": "修改群组描述成功",
"k547a7a99": "没有找到该记录",
"k551b0348": "密码",
"k56f9469b": "暂无好友",
@ -226,6 +227,7 @@
"ka4dac521": "确认要删除角色 {{name}} 么?",
"ka50c7408": "请手动输入JSON信息如果你不明确你在做什么请不要使用该功能",
"ka5616453": "禁言 {{length}}, 预计到 {{until}} 为止",
"ka58c246": "群组描述",
"ka5d64ee9": "选择以下模板, 开始创建属于自己的群组吧!",
"ka62886b9": "文件读取失败",
"ka64624b1": "加入群组成功!",

@ -62,6 +62,7 @@ export interface GroupInfo {
name: string;
avatar?: string;
owner: string;
description?: string;
members: GroupMember[];
panels: GroupPanel[];
roles: GroupRole[];
@ -152,6 +153,7 @@ export async function getGroupBasicInfo(
type AllowedModifyField =
| 'name'
| 'avatar'
| 'description'
| 'panels'
| 'roles'
| 'fallbackPermissions';

@ -3,12 +3,15 @@ import { FullModalCommonTitle } from '@/components/FullModal/CommonTitle';
import {
DefaultFullModalInputEditorRender,
FullModalField,
FullModalFieldEditorRenderComponent,
} from '@/components/FullModal/Field';
import { NoData } from '@/components/NoData';
import { Input } from 'antd';
import React from 'react';
import { Avatar } from 'tailchat-design';
import {
modifyGroupField,
showSuccessToasts,
showToasts,
t,
UploadFileResult,
@ -24,7 +27,15 @@ export const GroupSummary: React.FC<{
const [, handleUpdateGroupName] = useAsyncRequest(
async (newName: string) => {
await modifyGroupField(groupId, 'name', newName);
showToasts(t('修改群组名成功'), 'success');
showSuccessToasts(t('修改群组名成功'));
},
[groupId]
);
const [, handleUpdateGroupDescription] = useAsyncRequest(
async (newName: string) => {
await modifyGroupField(groupId, 'description', newName);
showSuccessToasts(t('修改群组描述成功'));
},
[groupId]
);
@ -69,9 +80,31 @@ export const GroupSummary: React.FC<{
title={t('成员数')}
value={String(groupInfo.members.length)}
/>
<FullModalField
title={t('群组描述')}
value={groupInfo.description ?? ''}
content={<pre>{groupInfo.description ?? ''}</pre>}
editable={true}
renderEditor={GroupDescriptionEditorRender}
onSave={handleUpdateGroupDescription}
/>
</div>
</div>
</div>
);
});
GroupSummary.displayName = 'GroupSummary';
const GroupDescriptionEditorRender: FullModalFieldEditorRenderComponent = ({
value,
onChange,
}) => (
<Input.TextArea
autoSize={{ minRows: 4, maxRows: 6 }}
maxLength={120}
value={value}
onChange={(e) => onChange(e.target.value)}
showCount={true}
/>
);

@ -69,3 +69,7 @@
padding: 0 4px;
}
}
.ant-input-textarea-show-count::after {
font-size: 0.7rem;
}

@ -122,6 +122,11 @@ export class Group extends TimeStamps implements Base {
})
owner: Ref<User>;
@prop({
maxlength: 120,
})
description?: string;
@prop({ type: () => GroupMember, _id: false })
members: GroupMember[];

@ -50,7 +50,10 @@ export type TcContext<P = {}, M = {}> = TcPureContext<
} & M
>;
export type GroupBaseInfo = Pick<GroupStruct, 'name' | 'avatar' | 'owner'> & {
export type GroupBaseInfo = Pick<
GroupStruct,
'name' | 'avatar' | 'owner' | 'description'
> & {
memberCount: number;
};

@ -47,6 +47,8 @@ export interface GroupStruct {
owner: string;
description?: string;
members: GroupMemberStruct[];
panels: GroupPanelStruct[];

@ -348,6 +348,7 @@ class GroupService extends TcService {
name: 1,
avatar: 1,
owner: 1,
description: 1,
members: 1,
})
.exec();
@ -362,6 +363,7 @@ class GroupService extends TcService {
name: group.name,
avatar: group.avatar,
owner: String(group.owner),
description: group.description ?? '',
memberCount: groupMemberCount,
};
}
@ -390,9 +392,14 @@ class GroupService extends TcService {
const userId = ctx.meta.userId;
const t = ctx.meta.t;
if (
!['name', 'avatar', 'panels', 'roles', 'fallbackPermissions'].includes(
fieldName
)
![
'name',
'avatar',
'description',
'panels',
'roles',
'fallbackPermissions',
].includes(fieldName)
) {
throw new EntityError(t('该数据不允许修改'));
}

Loading…
Cancel
Save