@tencentcloud/chat-uikit-react 2.1.3 → 2.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/dist/cjs/components/ConversationCreate/hooks/useConversationCreate.js +1 -1
- package/dist/cjs/components/ConversationPreview/ConversationPreviewContent.js +1 -1
- package/dist/cjs/components/TUIContact/TUIContactInfo/TUIContactInfo.d.ts +1 -1
- package/dist/cjs/components/TUIContact/TUIContactInfo/TUIContactInfo.js +1 -1
- package/dist/cjs/components/TUIContact/TUIContactInfo/friendInfo.js +1 -1
- package/dist/cjs/components/TUIContact/TUIContactInfo/groupInfo.js +1 -0
- package/dist/cjs/components/TUIContact/TUIContactList/TUIContactList.js +1 -1
- package/dist/cjs/components/TUIContact/hooks/useTUIContact.js +1 -1
- package/dist/cjs/components/TUIConversation/TUIConversation.js +1 -1
- package/dist/cjs/components/TUIConversationList/hooks/useConversationList.js +1 -1
- package/dist/cjs/components/TUIKit/TUIKit.js +1 -1
- package/dist/cjs/components/TUIKit/hooks/useTUIKit.d.ts +7 -2
- package/dist/cjs/components/TUIKit/hooks/useTUIKit.js +1 -1
- package/dist/cjs/components/TUIProfile/TUIProfile.js +1 -1
- package/dist/cjs/components/TUIProfile/TUIProfileDefault.d.ts +2 -2
- package/dist/cjs/components/TUIProfile/hooks/useMyProfile.js +1 -1
- package/dist/cjs/context/TUIConversationContext.js +1 -1
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/locales/en/TUIContact.js +1 -1
- package/dist/cjs/locales/zh_cn/TUIContact.js +1 -1
- package/dist/esm/components/ConversationCreate/hooks/useConversationCreate.js +1 -1
- package/dist/esm/components/ConversationPreview/ConversationPreviewContent.js +1 -1
- package/dist/esm/components/TUIContact/TUIContactInfo/TUIContactInfo.d.ts +1 -1
- package/dist/esm/components/TUIContact/TUIContactInfo/TUIContactInfo.js +1 -1
- package/dist/esm/components/TUIContact/TUIContactInfo/friendInfo.js +1 -1
- package/dist/esm/components/TUIContact/TUIContactInfo/groupInfo.js +1 -0
- package/dist/esm/components/TUIContact/TUIContactList/TUIContactList.js +1 -1
- package/dist/esm/components/TUIContact/hooks/useTUIContact.js +1 -1
- package/dist/esm/components/TUIConversation/TUIConversation.js +1 -1
- package/dist/esm/components/TUIConversationList/hooks/useConversationList.js +1 -1
- package/dist/esm/components/TUIKit/TUIKit.js +1 -1
- package/dist/esm/components/TUIKit/hooks/useTUIKit.d.ts +7 -2
- package/dist/esm/components/TUIKit/hooks/useTUIKit.js +1 -1
- package/dist/esm/components/TUIProfile/TUIProfile.js +1 -1
- package/dist/esm/components/TUIProfile/TUIProfileDefault.d.ts +2 -2
- package/dist/esm/components/TUIProfile/hooks/useMyProfile.js +1 -1
- package/dist/esm/context/TUIConversationContext.js +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/locales/en/TUIContact.js +1 -1
- package/dist/esm/locales/zh_cn/TUIContact.js +1 -1
- package/package.json +1 -1
- package/scripts/publish-intl-experience-demo.js +14 -0
- package/src/components/ConversationPreview/ConversationPreviewContent.tsx +1 -1
- package/src/components/Profile/index.ts +1 -2
- package/src/components/TUIContact/TUIContactInfo/TUIContactInfo.tsx +5 -3
- package/src/components/TUIContact/TUIContactInfo/friendInfo.tsx +10 -10
- package/src/components/TUIContact/TUIContactInfo/groupInfo.tsx +65 -0
- package/src/components/TUIContact/TUIContactList/TUIContactList.tsx +71 -65
- package/src/components/TUIContact/hooks/useTUIContact.tsx +14 -0
- package/src/components/TUIConversationList/hooks/useConversationList.tsx +19 -24
- package/src/components/TUIKit/TUIKit.tsx +33 -13
- package/src/components/TUIKit/hooks/useTUIKit.tsx +19 -9
- package/src/components/TUIProfile/TUIProfileDefault.tsx +2 -2
- package/src/components/TUIProfile/hooks/useMyProfile.tsx +18 -36
- package/src/locales/en/TUIContact.ts +1 -0
- package/src/locales/zh_cn/TUIContact.ts +1 -0
- package/dist/cjs/components/TUIProfile/hooks/useMyProfile.d.ts +0 -17
- package/dist/esm/components/TUIProfile/hooks/useMyProfile.d.ts +0 -17
- package/src/components/Profile/hooks/useProfile.tsx +0 -28
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React, { PropsWithChildren, useState, useEffect } from 'react';
|
|
2
2
|
import { ChatSDK, Conversation } from '@tencentcloud/chat';
|
|
3
|
-
import { TUIStore, StoreName } from '@tencentcloud/chat-uikit-engine';
|
|
3
|
+
import { TUIStore, StoreName, IConversationModel, TUIConversationService } from '@tencentcloud/chat-uikit-engine';
|
|
4
|
+
import { TUILogin } from '@tencentcloud/tui-core';
|
|
4
5
|
import { useTranslation } from 'react-i18next';
|
|
5
6
|
import { isH5, isPC } from '../../utils/env';
|
|
6
7
|
import { useTUIKit, UseContactParams } from './hooks/useTUIKit';
|
|
@@ -80,7 +81,7 @@ function RenderForPC({ moduleValue, tabbarRender, setModuleValue } : RenderPCPro
|
|
|
80
81
|
{moduleValue === TUIKIT_TABBAR.CONTACTS && (
|
|
81
82
|
<TUIContact>
|
|
82
83
|
<TUIContactInfo
|
|
83
|
-
|
|
84
|
+
showChats={() => {
|
|
84
85
|
setModuleValue(TUIKIT_TABBAR.CHATS);
|
|
85
86
|
}}
|
|
86
87
|
/>
|
|
@@ -112,7 +113,7 @@ function RenderForH5({
|
|
|
112
113
|
{ moduleValue === TUIKIT_TABBAR.CONTACTS && contactData && (
|
|
113
114
|
<TUIContact>
|
|
114
115
|
<TUIContactInfo
|
|
115
|
-
|
|
116
|
+
showChats={() => {
|
|
116
117
|
setModuleValue(TUIKIT_TABBAR.CHATS);
|
|
117
118
|
}}
|
|
118
119
|
/>
|
|
@@ -126,13 +127,16 @@ export function TUIKit<
|
|
|
126
127
|
>(
|
|
127
128
|
props:PropsWithChildren<T>,
|
|
128
129
|
):React.ReactElement {
|
|
129
|
-
const [currentConversationID, setCurrentConversationID] = useState<string>('');
|
|
130
130
|
const [moduleValue, setModuleValue] = useState('chats');
|
|
131
131
|
const { t } = useTranslation();
|
|
132
|
-
|
|
133
132
|
const {
|
|
134
|
-
children,
|
|
133
|
+
children,
|
|
134
|
+
chat = TUILogin.getContext().chat,
|
|
135
|
+
customClasses,
|
|
136
|
+
activeConversation,
|
|
137
|
+
language = 'en',
|
|
135
138
|
} = props;
|
|
139
|
+
|
|
136
140
|
(window as any).tencent_cloud_im_csig_react_uikit_23F_xa = true;
|
|
137
141
|
const {
|
|
138
142
|
conversation,
|
|
@@ -161,20 +165,21 @@ export function TUIKit<
|
|
|
161
165
|
});
|
|
162
166
|
useEffect(() => {
|
|
163
167
|
TUIStore.watch(StoreName.CONV, {
|
|
164
|
-
|
|
168
|
+
currentConversation: onCurrentConversation,
|
|
165
169
|
});
|
|
166
170
|
return () => {
|
|
167
171
|
TUIStore.unwatch(StoreName.CONV, {
|
|
168
|
-
|
|
172
|
+
currentConversation: onCurrentConversation,
|
|
169
173
|
});
|
|
170
174
|
};
|
|
171
175
|
}, []);
|
|
172
176
|
|
|
173
|
-
const onCurrentConversationID = (id: string) => {
|
|
174
|
-
setCurrentConversationID(id);
|
|
175
|
-
};
|
|
176
177
|
const switchTabbar = (value: string) => {
|
|
177
178
|
setModuleValue(value);
|
|
179
|
+
TUIConversationService.switchConversation('');
|
|
180
|
+
};
|
|
181
|
+
const onCurrentConversation = (conversationModel: IConversationModel) => {
|
|
182
|
+
setActiveConversation(conversationModel?.getConversation());
|
|
178
183
|
};
|
|
179
184
|
|
|
180
185
|
const tabbarRender = (
|
|
@@ -200,8 +205,23 @@ export function TUIKit<
|
|
|
200
205
|
return (
|
|
201
206
|
<TUIKitProvider value={chatContextValue}>
|
|
202
207
|
<div className="tui-kit">
|
|
203
|
-
{children ||
|
|
204
|
-
|
|
208
|
+
{children ||
|
|
209
|
+
(isPC && (
|
|
210
|
+
<RenderForPC
|
|
211
|
+
moduleValue={moduleValue}
|
|
212
|
+
tabbarRender={tabbarRender}
|
|
213
|
+
setModuleValue={setModuleValue}
|
|
214
|
+
/>
|
|
215
|
+
)) ||
|
|
216
|
+
(isH5 && (
|
|
217
|
+
<RenderForH5
|
|
218
|
+
contactData={contactData}
|
|
219
|
+
moduleValue={moduleValue}
|
|
220
|
+
tabbarRender={tabbarRender}
|
|
221
|
+
currentConversationID={conversation?.conversationID || ''}
|
|
222
|
+
setModuleValue={setModuleValue}
|
|
223
|
+
/>
|
|
224
|
+
))}
|
|
205
225
|
</div>
|
|
206
226
|
</TUIKitProvider>
|
|
207
227
|
);
|
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
import React, { useState, useCallback, useEffect } from 'react';
|
|
2
|
+
import {
|
|
3
|
+
TUIStore,
|
|
4
|
+
StoreName,
|
|
5
|
+
IGroupModel
|
|
6
|
+
} from '@tencentcloud/chat-uikit-engine';
|
|
2
7
|
import { useTranslation } from 'react-i18next';
|
|
3
8
|
import {
|
|
4
9
|
ChatSDK,
|
|
@@ -28,8 +33,13 @@ interface addFriendData {
|
|
|
28
33
|
data: Profile
|
|
29
34
|
}
|
|
30
35
|
|
|
36
|
+
interface GroupData {
|
|
37
|
+
type: 'group',
|
|
38
|
+
data: IGroupModel
|
|
39
|
+
}
|
|
40
|
+
|
|
31
41
|
export type UseContactParams = blockData | friendData |
|
|
32
|
-
friendApplicationData | addFriendData| undefined;
|
|
42
|
+
friendApplicationData | addFriendData| GroupData | undefined;
|
|
33
43
|
|
|
34
44
|
export interface UseChatParams{
|
|
35
45
|
chat: ChatSDK,
|
|
@@ -50,12 +60,12 @@ export const useTUIKit = ({
|
|
|
50
60
|
|
|
51
61
|
useEffect(() => {
|
|
52
62
|
i18n.changeLanguage(language);
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
}, [
|
|
63
|
+
TUIStore.watch(StoreName.USER, {
|
|
64
|
+
userProfile: (userProfileData: any) => {
|
|
65
|
+
setMyProfile(userProfileData);
|
|
66
|
+
},
|
|
67
|
+
});
|
|
68
|
+
}, [language]);
|
|
59
69
|
const setActiveConversation = useCallback(
|
|
60
70
|
(activeConversation?: Conversation) => {
|
|
61
71
|
if (activeConversation) {
|
|
@@ -64,11 +74,11 @@ export const useTUIKit = ({
|
|
|
64
74
|
if (conversation && (activeConversation?.conversationID !== conversation.conversationID)) {
|
|
65
75
|
setTUIManageShow(false);
|
|
66
76
|
}
|
|
67
|
-
|
|
77
|
+
setConversation(activeConversation);
|
|
68
78
|
},
|
|
69
79
|
[chat],
|
|
70
80
|
);
|
|
71
|
-
const setActiveContact = (actionContactData
|
|
81
|
+
const setActiveContact = (actionContactData?: UseContactParams) => {
|
|
72
82
|
setContactData(actionContactData);
|
|
73
83
|
};
|
|
74
84
|
|
|
@@ -2,6 +2,7 @@ import React, { PropsWithChildren, useEffect, useState } from 'react';
|
|
|
2
2
|
import { useTranslation } from 'react-i18next';
|
|
3
3
|
import DatePicker from 'react-date-picker';
|
|
4
4
|
import TencentCloudChat, { Profile } from '@tencentcloud/chat';
|
|
5
|
+
import { UpdateMyProfileParams } from "@tencentcloud/chat-uikit-engine";
|
|
5
6
|
import { isH5 } from '../../utils/env';
|
|
6
7
|
import { useTUIKitContext } from '../../context';
|
|
7
8
|
|
|
@@ -9,7 +10,6 @@ import { Avatar } from '../Avatar';
|
|
|
9
10
|
import { DivWithEdit } from '../DivWithEdit';
|
|
10
11
|
import { Icon, IconTypes } from '../Icon';
|
|
11
12
|
import { handleDisplayAvatar } from '../untils';
|
|
12
|
-
import { ProfileParams } from './hooks';
|
|
13
13
|
|
|
14
14
|
const gender: any = {
|
|
15
15
|
[TencentCloudChat.TYPES.GENDER_UNKNOWN]: 'unknow',
|
|
@@ -59,7 +59,7 @@ const allowTypeList = [
|
|
|
59
59
|
|
|
60
60
|
export interface TUIProfileDefaultProps {
|
|
61
61
|
userInfo?: Profile,
|
|
62
|
-
update?: (option:
|
|
62
|
+
update?: (option: UpdateMyProfileParams) => void,
|
|
63
63
|
className?: string,
|
|
64
64
|
}
|
|
65
65
|
|
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
|
|
1
|
+
import { useEffect, useState } from 'react';
|
|
2
|
+
import { Profile } from '@tencentcloud/chat';
|
|
3
|
+
import {
|
|
4
|
+
TUIUserService,
|
|
5
|
+
TUIStore,
|
|
6
|
+
StoreName,
|
|
7
|
+
UpdateMyProfileParams,
|
|
8
|
+
} from "@tencentcloud/chat-uikit-engine";
|
|
5
9
|
export interface ProfileParams {
|
|
6
10
|
nick?: string,
|
|
7
11
|
avatar?: string,
|
|
@@ -19,43 +23,21 @@ export interface ProfileParams {
|
|
|
19
23
|
}
|
|
20
24
|
|
|
21
25
|
export function useMyProfile() {
|
|
22
|
-
const [myProfile,
|
|
23
|
-
const { chat, myProfile: contextProfile } = useTUIKitContext('useMyProfile');
|
|
24
|
-
|
|
25
|
-
const getMyProfile = useCallback(async () => {
|
|
26
|
-
if (contextProfile) {
|
|
27
|
-
setMyPofile(contextProfile);
|
|
28
|
-
} else {
|
|
29
|
-
const res = await chat?.getMyProfile();
|
|
30
|
-
setMyPofile(res?.data);
|
|
31
|
-
}
|
|
32
|
-
}, [chat]);
|
|
26
|
+
const [myProfile, setMyProfile] = useState<Profile>();
|
|
33
27
|
|
|
34
|
-
const updateMyProfile =
|
|
35
|
-
|
|
28
|
+
const updateMyProfile = (options: UpdateMyProfileParams) => {
|
|
29
|
+
TUIUserService.updateMyProfile(options);
|
|
36
30
|
const userInfo: any = { ...myProfile };
|
|
37
|
-
|
|
38
|
-
keys.map((name) => {
|
|
39
|
-
userInfo[name] = res.data[name];
|
|
40
|
-
return name;
|
|
41
|
-
});
|
|
42
|
-
setMyPofile(userInfo);
|
|
43
|
-
return res;
|
|
44
|
-
}, [chat]);
|
|
45
|
-
|
|
46
|
-
const onProfileUpdated = (event: any) => {
|
|
47
|
-
console.log('onProfileUpdated', event.data);
|
|
31
|
+
setMyProfile(userInfo);
|
|
48
32
|
};
|
|
49
33
|
|
|
50
34
|
useEffect(() => {
|
|
51
|
-
(
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
};
|
|
58
|
-
}, [chat]);
|
|
35
|
+
TUIStore.watch(StoreName.USER, {
|
|
36
|
+
userProfile: (userProfileData: any) => {
|
|
37
|
+
setMyProfile(userProfileData);
|
|
38
|
+
},
|
|
39
|
+
});
|
|
40
|
+
}, []);
|
|
59
41
|
|
|
60
42
|
return {
|
|
61
43
|
myProfile,
|
|
@@ -13,6 +13,7 @@ const TUIContact = {
|
|
|
13
13
|
'Successful application, waiting for the administrator to agree to join the group application': '等待管理员同意',
|
|
14
14
|
'New Contacts': '新的联系人',
|
|
15
15
|
'Blocked List': '黑名单',
|
|
16
|
+
'Group List': '我的群聊',
|
|
16
17
|
'No Result': '无搜索结果',
|
|
17
18
|
'ID': 'ID',
|
|
18
19
|
'User': '联系人',
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
interface ProfileParams {
|
|
2
|
-
nick?: string;
|
|
3
|
-
avatar?: string;
|
|
4
|
-
gender?: string;
|
|
5
|
-
selfSignature?: string;
|
|
6
|
-
allowType?: string;
|
|
7
|
-
birthday?: number;
|
|
8
|
-
location?: string;
|
|
9
|
-
language?: string;
|
|
10
|
-
messageSettings?: number;
|
|
11
|
-
adminForbidType?: string;
|
|
12
|
-
level?: number;
|
|
13
|
-
role?: number;
|
|
14
|
-
profileCustomField?: Array<any>;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export { ProfileParams };
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
interface ProfileParams {
|
|
2
|
-
nick?: string;
|
|
3
|
-
avatar?: string;
|
|
4
|
-
gender?: string;
|
|
5
|
-
selfSignature?: string;
|
|
6
|
-
allowType?: string;
|
|
7
|
-
birthday?: number;
|
|
8
|
-
location?: string;
|
|
9
|
-
language?: string;
|
|
10
|
-
messageSettings?: number;
|
|
11
|
-
adminForbidType?: string;
|
|
12
|
-
level?: number;
|
|
13
|
-
role?: number;
|
|
14
|
-
profileCustomField?: Array<any>;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export { ProfileParams };
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import React, { useState, useEffect } from 'react';
|
|
2
|
-
import { ChatSDK, Profile } from '@tencentcloud/chat';
|
|
3
|
-
|
|
4
|
-
export function useProfile(chat: ChatSDK, profileHandler?: (
|
|
5
|
-
profile: Profile,
|
|
6
|
-
setProfile?: React.Dispatch<React.SetStateAction<Profile>>,
|
|
7
|
-
) => void) {
|
|
8
|
-
const [myProfile, setMyProfile] = useState<Profile>();
|
|
9
|
-
|
|
10
|
-
const getProfile = async (userIDList: Array<string>) => {
|
|
11
|
-
const res = await chat?.getUserProfile({
|
|
12
|
-
userIDList,
|
|
13
|
-
});
|
|
14
|
-
return res.data;
|
|
15
|
-
};
|
|
16
|
-
const getMyProfile = async () => {
|
|
17
|
-
const res = await chat?.getMyProfile();
|
|
18
|
-
setMyProfile(res?.data);
|
|
19
|
-
};
|
|
20
|
-
useEffect(() => {
|
|
21
|
-
getMyProfile();
|
|
22
|
-
}, [chat]);
|
|
23
|
-
return {
|
|
24
|
-
myProfile,
|
|
25
|
-
setMyProfile,
|
|
26
|
-
getProfile,
|
|
27
|
-
};
|
|
28
|
-
}
|