Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

群组内一键添加好友 || One-click to add friends to the group #251

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions client/web/src/components/modals/ModifyPassword.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ const schema = createMetaFormSchema({
newPassword: metaFormFieldSchema
.string()
.min(6, t('密码不能低于6位'))
.matches(/[A-Z]/, '密码必须包含大写字母')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you should wrap with t which can include translation support

.matches(/[a-z]/, '密码必须包含小写字母')
.matches(/\d/, '密码必须包含数字')
.matches(/[`~!@#$%^&*()_+./,;':"*]/, '密码必须包含符号')
.required(t('密码不能为空')),
newPasswordRepeat: metaFormFieldSchema
.string()
Expand Down
17 changes: 17 additions & 0 deletions client/web/src/components/popover/UserPopover/GroupUserPopover.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import {
useAsyncRequest,
UserBaseInfo,
useUserId,
request,
showToasts,
} from 'tailchat-shared';
import { UserProfileContainer } from '../../UserProfileContainer';
import { usePluginUserExtraInfo } from './usePluginUserExtraInfo';
Expand Down Expand Up @@ -41,6 +43,15 @@ export const GroupUserPopover: React.FC<{
navigate(`/main/personal/converse/${converse._id}`);
}, [navigate]);

// 一键添加好友
const [, handleAddFriend] = useAsyncRequest(async () => {
const { data } = await request.post('/api/friend/request/add', {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think you should use addFriendRequest in client/shared/model/friend.ts

to: userId,
});
showToasts(t('成功发送好友申请'));
return data;
}, [userId, request]);

useEffect(() => {
if (userInfo.avatar) {
fetchImagePrimaryColor(userInfo.avatar).then((rgba) => {
Expand Down Expand Up @@ -84,6 +95,12 @@ export const GroupUserPopover: React.FC<{
<div className="pt-2">{pluginUserExtraInfoEl}</div>

<div className="text-right">
<Tooltip title={t('添加好友')}>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think its should also have a permission check like allowSendMessage because its should can be close if some group dont wanna allow user DM

<IconBtn
icon="mdi:account-multiple-plus"
onClick={handleAddFriend}
/>
</Tooltip>
{allowSendMessage && (
<Tooltip title={t('发送消息')}>
<IconBtn
Expand Down
Loading