@tencentcloud/chat-uikit-react 2.1.4 → 2.2.3
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/README.md +6 -3
- 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/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/index.css +1 -1
- package/dist/cjs/index.d.css +1 -0
- package/dist/cjs/index.d.ts +1 -0
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/locales/en/TUIContact.js +1 -1
- package/dist/cjs/locales/en/index.js +1 -1
- package/dist/cjs/locales/zh_cn/TUIContact.js +1 -1
- package/dist/cjs/locales/zh_cn/index.js +1 -1
- package/dist/cjs/utils/env.d.ts +4 -0
- 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/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/index.css +1 -1
- package/dist/esm/index.d.css +1 -0
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/index.js +1 -1
- package/dist/esm/locales/en/TUIContact.js +1 -1
- package/dist/esm/locales/en/index.js +1 -1
- package/dist/esm/locales/zh_cn/TUIContact.js +1 -1
- package/dist/esm/locales/zh_cn/index.js +1 -1
- package/dist/esm/utils/env.d.ts +4 -0
- 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/TUIChat/styles/layout.scss +1 -0
- 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/TUIKit/TUIKit.tsx +6 -5
- package/src/components/TUIKit/hooks/useTUIKit.tsx +9 -3
- package/src/index.ts +1 -0
- package/src/locales/en/TUIContact.ts +1 -0
- package/src/locales/en/index.ts +2 -0
- package/src/locales/zh_cn/TUIContact.ts +1 -0
- package/src/locales/zh_cn/index.ts +2 -0
- package/src/server.ts +2 -3
|
@@ -4,13 +4,20 @@ import TencentCloudChat from '@tencentcloud/chat';
|
|
|
4
4
|
import { isH5 } from '../../../utils/env';
|
|
5
5
|
import { useTUIKitContext, useTUIContactContext } from '../../../context';
|
|
6
6
|
import useContactInfo from '../TUIContactInfo/hooks/useContactInfo';
|
|
7
|
-
|
|
7
|
+
import useTUIContact from '../hooks/useTUIContact';
|
|
8
8
|
import { Avatar, defaultUserAvatar } from '../../Avatar';
|
|
9
9
|
import rightArrow from '../../Icon/images/right-arrow.svg';
|
|
10
10
|
import downArrow from '../../Icon/images/down-arrow.png';
|
|
11
|
-
|
|
12
11
|
import './index.scss';
|
|
13
12
|
|
|
13
|
+
interface RenderContactListProps {
|
|
14
|
+
type: 'group' | 'block' | 'friend' ,
|
|
15
|
+
isShow: boolean,
|
|
16
|
+
title: string,
|
|
17
|
+
list: Array<any> | undefined,
|
|
18
|
+
setShow: (value: boolean) => void
|
|
19
|
+
}
|
|
20
|
+
|
|
14
21
|
function UnMemoizedTUIContactList<T>(): React.ReactElement {
|
|
15
22
|
const { setActiveContact } = useTUIKitContext();
|
|
16
23
|
const { t } = useTranslation();
|
|
@@ -20,16 +27,56 @@ function UnMemoizedTUIContactList<T>(): React.ReactElement {
|
|
|
20
27
|
const {
|
|
21
28
|
acceptFriendApplication,
|
|
22
29
|
} = useContactInfo();
|
|
23
|
-
|
|
30
|
+
const { groupList } = useTUIContact();
|
|
24
31
|
const [iShowFriendApplication, setShowFriendApplication] = useState(false);
|
|
25
32
|
const [iShowFriends, setShowFriends] = useState(false);
|
|
26
33
|
const [isShowBlocklist, setShowBlocklist] = useState(false);
|
|
34
|
+
const [isShowGrouplist, setShowGrouplist] = useState(false);
|
|
27
35
|
|
|
28
36
|
const acceptFriendApplicationHandle = (e: any, userID: string) => {
|
|
29
37
|
e.stopPropagation();
|
|
30
38
|
acceptFriendApplication(userID);
|
|
31
39
|
setActiveContact();
|
|
32
40
|
};
|
|
41
|
+
|
|
42
|
+
const RenderContactList = ({ type, isShow, setShow, list, title } : RenderContactListProps) => {
|
|
43
|
+
return (
|
|
44
|
+
<>
|
|
45
|
+
<div
|
|
46
|
+
className="tui-contacts-title"
|
|
47
|
+
role="button"
|
|
48
|
+
tabIndex={0}
|
|
49
|
+
onClick={() => setShow(!isShow)}
|
|
50
|
+
>
|
|
51
|
+
<div className="tui-contacts-list-title">{title}</div>
|
|
52
|
+
<div className="tui-contacts-list-icon">
|
|
53
|
+
<img src={isShow ? downArrow : rightArrow} alt="" />
|
|
54
|
+
</div>
|
|
55
|
+
</div>
|
|
56
|
+
{isShow
|
|
57
|
+
&& list?.map((item: any) => {
|
|
58
|
+
const { userID, groupID, avatar, name, nick } = item.profile || item;
|
|
59
|
+
const showName = item.remark || nick || userID || name || groupID;
|
|
60
|
+
return (
|
|
61
|
+
<div
|
|
62
|
+
role="button"
|
|
63
|
+
tabIndex={0}
|
|
64
|
+
className="tui-contacts-list-item"
|
|
65
|
+
key={userID || groupID}
|
|
66
|
+
onClick={() => {
|
|
67
|
+
setActiveContact({ type, data: item });
|
|
68
|
+
}}
|
|
69
|
+
>
|
|
70
|
+
<Avatar size={30} image={avatar || defaultUserAvatar} />
|
|
71
|
+
<div className="tui-contacts-list-item-container">
|
|
72
|
+
<p className="tui-contacts-list-item-name">{ showName }</p>
|
|
73
|
+
</div>
|
|
74
|
+
</div>
|
|
75
|
+
);
|
|
76
|
+
})}
|
|
77
|
+
</>
|
|
78
|
+
);
|
|
79
|
+
}
|
|
33
80
|
// eslint-disable-next-line
|
|
34
81
|
// @ts-ignore
|
|
35
82
|
return (
|
|
@@ -96,68 +143,27 @@ function UnMemoizedTUIContactList<T>(): React.ReactElement {
|
|
|
96
143
|
</div>
|
|
97
144
|
);
|
|
98
145
|
})}
|
|
99
|
-
<
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
setActiveContact({ type: 'block', data: item });
|
|
121
|
-
}}
|
|
122
|
-
>
|
|
123
|
-
<Avatar size={30} image={avatar || defaultUserAvatar} />
|
|
124
|
-
<div className="tui-contacts-list-item-container">
|
|
125
|
-
<p className="tui-contacts-list-item-name">{ nick || userID}</p>
|
|
126
|
-
</div>
|
|
127
|
-
</div>
|
|
128
|
-
);
|
|
129
|
-
})}
|
|
130
|
-
<div
|
|
131
|
-
className="tui-contacts-title"
|
|
132
|
-
role="button"
|
|
133
|
-
tabIndex={0}
|
|
134
|
-
onClick={() => setShowFriends(!iShowFriends)}
|
|
135
|
-
>
|
|
136
|
-
<div className="tui-contacts-list-title">{t('TUIContact.Friends')}</div>
|
|
137
|
-
<div className="tui-contacts-list-icon">
|
|
138
|
-
<img src={iShowFriends ? downArrow : rightArrow} alt="" />
|
|
139
|
-
</div>
|
|
140
|
-
</div>
|
|
141
|
-
{iShowFriends
|
|
142
|
-
&& friendList?.map((item, index) => {
|
|
143
|
-
const { userID, avatar, nick } = item.profile;
|
|
144
|
-
return (
|
|
145
|
-
<div
|
|
146
|
-
className="tui-contacts-list-item"
|
|
147
|
-
key={userID}
|
|
148
|
-
role="button"
|
|
149
|
-
tabIndex={0}
|
|
150
|
-
onClick={() => {
|
|
151
|
-
setActiveContact({ type: 'friend', data: item });
|
|
152
|
-
}}
|
|
153
|
-
>
|
|
154
|
-
<Avatar size={30} image={avatar || defaultUserAvatar} />
|
|
155
|
-
<div className="tui-contacts-list-item-container">
|
|
156
|
-
<p className="tui-contacts-list-item-name">{item.remark || nick || userID}</p>
|
|
157
|
-
</div>
|
|
158
|
-
</div>
|
|
159
|
-
);
|
|
160
|
-
})}
|
|
146
|
+
<RenderContactList
|
|
147
|
+
type={'block'}
|
|
148
|
+
title={t('TUIContact.Blocked List')}
|
|
149
|
+
isShow={isShowBlocklist}
|
|
150
|
+
setShow={setShowBlocklist}
|
|
151
|
+
list={blocklistProfile}
|
|
152
|
+
/>
|
|
153
|
+
<RenderContactList
|
|
154
|
+
type={'group'}
|
|
155
|
+
title={t('TUIContact.Group List')}
|
|
156
|
+
setShow={setShowGrouplist}
|
|
157
|
+
isShow={isShowGrouplist}
|
|
158
|
+
list={groupList}
|
|
159
|
+
/>
|
|
160
|
+
<RenderContactList
|
|
161
|
+
type={'friend'}
|
|
162
|
+
title={t('TUIContact.Friends')}
|
|
163
|
+
setShow={setShowFriends}
|
|
164
|
+
isShow={iShowFriends}
|
|
165
|
+
list={friendList}
|
|
166
|
+
/>
|
|
161
167
|
</div>
|
|
162
168
|
)
|
|
163
169
|
);
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import React, { useEffect, useState } from 'react';
|
|
2
2
|
import TencentCloudChat from '@tencentcloud/chat';
|
|
3
|
+
import {
|
|
4
|
+
TUIStore,
|
|
5
|
+
StoreName,
|
|
6
|
+
IGroupModel,
|
|
7
|
+
} from '@tencentcloud/chat-uikit-engine';
|
|
3
8
|
import { useTUIKitContext } from '../../../context';
|
|
4
9
|
|
|
5
10
|
function useTUIContact() {
|
|
@@ -8,14 +13,22 @@ function useTUIContact() {
|
|
|
8
13
|
const [blockList, setBlockList] = useState([]);
|
|
9
14
|
const [friendApplicationList, setFriendApplicationList] = useState([]);
|
|
10
15
|
const [blocklistProfile, setBlocklistProfile] = useState([]);
|
|
16
|
+
const [groupList, setGroupList] = useState<IGroupModel[]>();
|
|
17
|
+
|
|
11
18
|
const [isShowContactList, setShowContactList] = useState(true);
|
|
12
19
|
|
|
13
20
|
useEffect(() => {
|
|
21
|
+
TUIStore.watch(StoreName.GRP, {
|
|
22
|
+
groupList: onGroupListUpdated,
|
|
23
|
+
});
|
|
14
24
|
getFriendList();
|
|
15
25
|
getBlocklist();
|
|
16
26
|
getFriendApplicationList();
|
|
17
27
|
}, [chat]);
|
|
18
28
|
|
|
29
|
+
const onGroupListUpdated = (list: IGroupModel[]) => {
|
|
30
|
+
setGroupList(list);
|
|
31
|
+
};
|
|
19
32
|
useEffect(() => {
|
|
20
33
|
chat?.on(TencentCloudChat.EVENT.BLACKLIST_UPDATED, onBlocklistUpdated);
|
|
21
34
|
chat?.on(TencentCloudChat.EVENT.FRIEND_LIST_UPDATED, onFriendListUpdated);
|
|
@@ -64,6 +77,7 @@ function useTUIContact() {
|
|
|
64
77
|
|
|
65
78
|
return {
|
|
66
79
|
friendList,
|
|
80
|
+
groupList,
|
|
67
81
|
blocklistProfile,
|
|
68
82
|
friendApplicationList,
|
|
69
83
|
blockList,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { PropsWithChildren, useState, useEffect } from 'react';
|
|
2
2
|
import { ChatSDK, Conversation } from '@tencentcloud/chat';
|
|
3
|
-
import { TUIStore, StoreName, IConversationModel } from '@tencentcloud/chat-uikit-engine';
|
|
3
|
+
import { TUIStore, StoreName, IConversationModel, TUIConversationService } from '@tencentcloud/chat-uikit-engine';
|
|
4
4
|
import { TUILogin } from '@tencentcloud/tui-core';
|
|
5
5
|
import { useTranslation } from 'react-i18next';
|
|
6
6
|
import { isH5, isPC } from '../../utils/env';
|
|
@@ -81,7 +81,7 @@ function RenderForPC({ moduleValue, tabbarRender, setModuleValue } : RenderPCPro
|
|
|
81
81
|
{moduleValue === TUIKIT_TABBAR.CONTACTS && (
|
|
82
82
|
<TUIContact>
|
|
83
83
|
<TUIContactInfo
|
|
84
|
-
|
|
84
|
+
showChats={() => {
|
|
85
85
|
setModuleValue(TUIKIT_TABBAR.CHATS);
|
|
86
86
|
}}
|
|
87
87
|
/>
|
|
@@ -95,7 +95,7 @@ function RenderForH5({
|
|
|
95
95
|
moduleValue, contactData, tabbarRender, currentConversationID, setModuleValue,
|
|
96
96
|
}: RenderH5Props) {
|
|
97
97
|
return (
|
|
98
|
-
|
|
98
|
+
<div className='sample-chat-h5'>
|
|
99
99
|
{!currentConversationID && !contactData && (
|
|
100
100
|
<div className="sample-chat-h5-container">
|
|
101
101
|
<TUIProfile className="sample-profile" />
|
|
@@ -113,13 +113,13 @@ function RenderForH5({
|
|
|
113
113
|
{ moduleValue === TUIKIT_TABBAR.CONTACTS && contactData && (
|
|
114
114
|
<TUIContact>
|
|
115
115
|
<TUIContactInfo
|
|
116
|
-
|
|
116
|
+
showChats={() => {
|
|
117
117
|
setModuleValue(TUIKIT_TABBAR.CHATS);
|
|
118
118
|
}}
|
|
119
119
|
/>
|
|
120
120
|
</TUIContact>
|
|
121
121
|
)}
|
|
122
|
-
|
|
122
|
+
</div>
|
|
123
123
|
);
|
|
124
124
|
}
|
|
125
125
|
export function TUIKit<
|
|
@@ -176,6 +176,7 @@ export function TUIKit<
|
|
|
176
176
|
|
|
177
177
|
const switchTabbar = (value: string) => {
|
|
178
178
|
setModuleValue(value);
|
|
179
|
+
TUIConversationService.switchConversation('');
|
|
179
180
|
};
|
|
180
181
|
const onCurrentConversation = (conversationModel: IConversationModel) => {
|
|
181
182
|
setActiveConversation(conversationModel?.getConversation());
|
|
@@ -2,6 +2,7 @@ import React, { useState, useCallback, useEffect } from 'react';
|
|
|
2
2
|
import {
|
|
3
3
|
TUIStore,
|
|
4
4
|
StoreName,
|
|
5
|
+
IGroupModel
|
|
5
6
|
} from '@tencentcloud/chat-uikit-engine';
|
|
6
7
|
import { useTranslation } from 'react-i18next';
|
|
7
8
|
import {
|
|
@@ -32,8 +33,13 @@ interface addFriendData {
|
|
|
32
33
|
data: Profile
|
|
33
34
|
}
|
|
34
35
|
|
|
36
|
+
interface GroupData {
|
|
37
|
+
type: 'group',
|
|
38
|
+
data: IGroupModel
|
|
39
|
+
}
|
|
40
|
+
|
|
35
41
|
export type UseContactParams = blockData | friendData |
|
|
36
|
-
friendApplicationData | addFriendData| undefined;
|
|
42
|
+
friendApplicationData | addFriendData| GroupData | undefined;
|
|
37
43
|
|
|
38
44
|
export interface UseChatParams{
|
|
39
45
|
chat: ChatSDK,
|
|
@@ -68,11 +74,11 @@ export const useTUIKit = ({
|
|
|
68
74
|
if (conversation && (activeConversation?.conversationID !== conversation.conversationID)) {
|
|
69
75
|
setTUIManageShow(false);
|
|
70
76
|
}
|
|
71
|
-
|
|
77
|
+
setConversation(activeConversation);
|
|
72
78
|
},
|
|
73
79
|
[chat],
|
|
74
80
|
);
|
|
75
|
-
const setActiveContact = (actionContactData
|
|
81
|
+
const setActiveContact = (actionContactData?: UseContactParams) => {
|
|
76
82
|
setContactData(actionContactData);
|
|
77
83
|
};
|
|
78
84
|
|
package/src/index.ts
CHANGED
package/src/locales/en/index.ts
CHANGED
|
@@ -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': '联系人',
|
package/src/server.ts
CHANGED
|
@@ -12,8 +12,7 @@ export default class TUIChatKit {
|
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
|
-
*
|
|
16
|
-
* @param { TUIInitParam } params 初始化参数
|
|
15
|
+
* @param { TUIInitParam } params
|
|
17
16
|
*/
|
|
18
17
|
public onNotifyEvent(eventName: string, subKey: string) {
|
|
19
18
|
if (eventName === TUIConstants.TUILogin.EVENT.LOGIN_STATE_CHANGED) {
|
|
@@ -28,7 +27,7 @@ export default class TUIChatKit {
|
|
|
28
27
|
}
|
|
29
28
|
|
|
30
29
|
/**
|
|
31
|
-
* login
|
|
30
|
+
* login
|
|
32
31
|
*/
|
|
33
32
|
private login() {
|
|
34
33
|
const {
|