@tencentcloud/chat-uikit-react 1.0.4 → 1.1.0
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 +10 -0
- package/README.md +70 -42
- package/dist/cjs/components/ConversationCreate/ConversationCreate.js +1 -1
- package/dist/cjs/components/ConversationCreate/ConversationCreateUserSelectList.js +1 -1
- package/dist/cjs/components/ConversationCreate/hooks/useConversationCreate.js +1 -1
- package/dist/cjs/components/ConversationPreview/ConversationListContainer.d.ts +1 -1
- package/dist/cjs/components/ConversationPreview/ConversationPreview.d.ts +1 -1
- package/dist/cjs/components/ConversationPreview/ConversationPreviewContent.js +1 -1
- package/dist/cjs/components/ConversationPreview/utils.js +1 -1
- package/dist/cjs/components/ConversationSearch/ConversationSearchResult.d.ts +1 -1
- package/dist/cjs/components/ConversationSearch/ConversationSearchResult.js +1 -1
- package/dist/cjs/components/TUIChat/TUIChat.d.ts +1 -1
- package/dist/cjs/components/TUIChat/TUIChat.js +1 -1
- package/dist/cjs/components/TUIChat/TUIChatState.js +1 -1
- package/dist/cjs/components/TUIChat/hooks/useCreateMessage.d.ts +2 -2
- package/dist/cjs/components/TUIChat/hooks/useCreateMessage.js +1 -1
- package/dist/cjs/components/TUIChat/hooks/useCreateTUIChatStateContext.js +1 -1
- package/dist/cjs/components/TUIChat/hooks/useHandleMessage.d.ts +1 -1
- package/dist/cjs/components/TUIChat/hooks/useHandleMessageList.js +1 -1
- package/dist/cjs/components/TUIChat/hooks/useMessageReceviedListener.js +1 -1
- package/dist/cjs/components/TUIChat/unitls.js +1 -1
- package/dist/cjs/components/TUIChatHeader/TUIChatHeader.d.ts +1 -1
- package/dist/cjs/components/TUIChatHeader/TUIChatHeaderDefault.d.ts +1 -1
- package/dist/cjs/components/TUIChatHeader/TUIChatHeaderDefault.js +1 -1
- package/dist/cjs/components/TUIConversation/TUIConversation.d.ts +1 -1
- package/dist/cjs/components/TUIConversation/TUIConversation.js +1 -1
- package/dist/cjs/components/TUIConversationList/TUIConversationList.d.ts +1 -1
- package/dist/cjs/components/TUIConversationList/TUIConversationList.js +1 -1
- package/dist/cjs/components/TUIConversationList/hooks/useConversationList.js +1 -1
- package/dist/cjs/components/TUIConversationList/hooks/useConversationUpdate.js +1 -1
- package/dist/cjs/components/TUIKit/TUIKit.d.ts +2 -2
- package/dist/cjs/components/TUIKit/TUIKit.js +1 -1
- package/dist/cjs/components/TUIKit/hooks/useCreateTUIKitContext.d.ts +5 -5
- package/dist/cjs/components/TUIKit/hooks/useCreateTUIKitContext.js +1 -1
- package/dist/cjs/components/TUIKit/hooks/useTUIKit.d.ts +3 -3
- package/dist/cjs/components/TUIKit/hooks/useTUIKit.js +1 -1
- package/dist/cjs/components/TUIManage/TUIManage.js +1 -1
- package/dist/cjs/components/TUIMessage/MessageBubble.js +1 -1
- package/dist/cjs/components/TUIMessage/MessageContext.d.ts +1 -1
- package/dist/cjs/components/TUIMessage/MessageContext.js +1 -1
- package/dist/cjs/components/TUIMessage/MessageCustom.js +1 -1
- package/dist/cjs/components/TUIMessage/MessageFile.js +1 -1
- package/dist/cjs/components/TUIMessage/MessageImage.js +1 -1
- package/dist/cjs/components/TUIMessage/MessageMerger.js +1 -1
- package/dist/cjs/components/TUIMessage/MessageName.js +1 -1
- package/dist/cjs/components/TUIMessage/MessagePlugins.d.ts +2 -2
- package/dist/cjs/components/TUIMessage/MessagePlugins.js +1 -1
- package/dist/cjs/components/TUIMessage/MessageProgress.js +1 -1
- package/dist/cjs/components/TUIMessage/MessageRevoke.js +1 -1
- package/dist/cjs/components/TUIMessage/MessageText.js +1 -1
- package/dist/cjs/components/TUIMessage/TUIMessage.d.ts +1 -1
- package/dist/cjs/components/TUIMessage/TUIMessage.js +1 -1
- package/dist/cjs/components/TUIMessage/TUIMessageDefault.js +1 -1
- package/dist/cjs/components/TUIMessage/hooks/useMessageContextHandler.js +1 -1
- package/dist/cjs/components/TUIMessage/hooks/useMessageHandler.js +1 -1
- package/dist/cjs/components/TUIMessage/hooks/useMessageReply.js +1 -1
- package/dist/cjs/components/TUIMessage/utils/index.js +1 -1
- package/dist/cjs/components/TUIMessageInput/TUIMessageInput.js +1 -1
- package/dist/cjs/components/TUIMessageInput/hooks/useHandleForwardMessage.js +1 -1
- package/dist/cjs/components/TUIMessageInput/hooks/useHandleQuoteMessage.js +1 -1
- package/dist/cjs/components/TUIMessageInput/hooks/useMessageInputText.js +1 -1
- package/dist/cjs/components/TUIMessageInput/hooks/useUploadPicker.js +1 -1
- package/dist/cjs/components/TUIMessageList/TUIMessageList.d.ts +1 -1
- package/dist/cjs/components/TUIMessageList/TUIMessageList.js +1 -1
- package/dist/cjs/components/TUIMessageList/hooks/useMessageListElement.js +1 -1
- package/dist/cjs/components/TUIProfile/TUIProfileDefault.d.ts +1 -1
- package/dist/cjs/components/TUIProfile/TUIProfileDefault.js +1 -1
- package/dist/cjs/components/TUIProfile/hooks/useMyProfile.js +1 -1
- package/dist/cjs/components/untils.js +1 -1
- package/dist/cjs/constants.js +1 -1
- package/dist/cjs/context/TUIChatActionContext.d.ts +3 -3
- package/dist/cjs/context/TUIChatStateContext.d.ts +2 -2
- package/dist/cjs/context/TUIConversationContext.js +1 -1
- package/dist/cjs/context/TUIKitContext.d.ts +2 -2
- package/dist/cjs/context/TUIMessageContext.d.ts +1 -1
- package/dist/cjs/hooks/useConversation.d.ts +3 -3
- package/dist/cjs/hooks/useConversation.js +1 -1
- package/dist/cjs/hooks/useProfile.d.ts +1 -1
- package/dist/cjs/index.js +1 -1
- package/dist/esm/components/ConversationCreate/ConversationCreate.js +1 -1
- package/dist/esm/components/ConversationCreate/ConversationCreateUserSelectList.js +1 -1
- package/dist/esm/components/ConversationCreate/hooks/useConversationCreate.js +1 -1
- package/dist/esm/components/ConversationPreview/ConversationListContainer.d.ts +1 -1
- package/dist/esm/components/ConversationPreview/ConversationPreview.d.ts +1 -1
- package/dist/esm/components/ConversationPreview/ConversationPreviewContent.js +1 -1
- package/dist/esm/components/ConversationPreview/utils.js +1 -1
- package/dist/esm/components/ConversationSearch/ConversationSearchResult.d.ts +1 -1
- package/dist/esm/components/ConversationSearch/ConversationSearchResult.js +1 -1
- package/dist/esm/components/TUIChat/TUIChat.d.ts +1 -1
- package/dist/esm/components/TUIChat/TUIChat.js +1 -1
- package/dist/esm/components/TUIChat/TUIChatState.js +1 -1
- package/dist/esm/components/TUIChat/hooks/useCreateMessage.d.ts +2 -2
- package/dist/esm/components/TUIChat/hooks/useCreateMessage.js +1 -1
- package/dist/esm/components/TUIChat/hooks/useCreateTUIChatStateContext.js +1 -1
- package/dist/esm/components/TUIChat/hooks/useHandleMessage.d.ts +1 -1
- package/dist/esm/components/TUIChat/hooks/useHandleMessageList.js +1 -1
- package/dist/esm/components/TUIChat/hooks/useMessageReceviedListener.js +1 -1
- package/dist/esm/components/TUIChat/unitls.js +1 -1
- package/dist/esm/components/TUIChatHeader/TUIChatHeader.d.ts +1 -1
- package/dist/esm/components/TUIChatHeader/TUIChatHeaderDefault.d.ts +1 -1
- package/dist/esm/components/TUIChatHeader/TUIChatHeaderDefault.js +1 -1
- package/dist/esm/components/TUIConversation/TUIConversation.d.ts +1 -1
- package/dist/esm/components/TUIConversation/TUIConversation.js +1 -1
- package/dist/esm/components/TUIConversationList/TUIConversationList.d.ts +1 -1
- package/dist/esm/components/TUIConversationList/TUIConversationList.js +1 -1
- package/dist/esm/components/TUIConversationList/hooks/useConversationList.js +1 -1
- package/dist/esm/components/TUIConversationList/hooks/useConversationUpdate.js +1 -1
- package/dist/esm/components/TUIKit/TUIKit.d.ts +2 -2
- package/dist/esm/components/TUIKit/TUIKit.js +1 -1
- package/dist/esm/components/TUIKit/hooks/useCreateTUIKitContext.d.ts +5 -5
- package/dist/esm/components/TUIKit/hooks/useCreateTUIKitContext.js +1 -1
- package/dist/esm/components/TUIKit/hooks/useTUIKit.d.ts +3 -3
- package/dist/esm/components/TUIKit/hooks/useTUIKit.js +1 -1
- package/dist/esm/components/TUIManage/TUIManage.js +1 -1
- package/dist/esm/components/TUIMessage/MessageBubble.js +1 -1
- package/dist/esm/components/TUIMessage/MessageContext.d.ts +1 -1
- package/dist/esm/components/TUIMessage/MessageContext.js +1 -1
- package/dist/esm/components/TUIMessage/MessageCustom.js +1 -1
- package/dist/esm/components/TUIMessage/MessageFile.js +1 -1
- package/dist/esm/components/TUIMessage/MessageImage.js +1 -1
- package/dist/esm/components/TUIMessage/MessageMerger.js +1 -1
- package/dist/esm/components/TUIMessage/MessageName.js +1 -1
- package/dist/esm/components/TUIMessage/MessagePlugins.d.ts +2 -2
- package/dist/esm/components/TUIMessage/MessagePlugins.js +1 -1
- package/dist/esm/components/TUIMessage/MessageProgress.js +1 -1
- package/dist/esm/components/TUIMessage/MessageRevoke.js +1 -1
- package/dist/esm/components/TUIMessage/MessageText.js +1 -1
- package/dist/esm/components/TUIMessage/TUIMessage.d.ts +1 -1
- package/dist/esm/components/TUIMessage/TUIMessage.js +1 -1
- package/dist/esm/components/TUIMessage/TUIMessageDefault.js +1 -1
- package/dist/esm/components/TUIMessage/hooks/useMessageContextHandler.js +1 -1
- package/dist/esm/components/TUIMessage/hooks/useMessageHandler.js +1 -1
- package/dist/esm/components/TUIMessage/hooks/useMessageReply.js +1 -1
- package/dist/esm/components/TUIMessage/utils/index.js +1 -1
- package/dist/esm/components/TUIMessageInput/TUIMessageInput.js +1 -1
- package/dist/esm/components/TUIMessageInput/hooks/useHandleForwardMessage.js +1 -1
- package/dist/esm/components/TUIMessageInput/hooks/useHandleQuoteMessage.js +1 -1
- package/dist/esm/components/TUIMessageInput/hooks/useMessageInputText.js +1 -1
- package/dist/esm/components/TUIMessageInput/hooks/useUploadPicker.js +1 -1
- package/dist/esm/components/TUIMessageList/TUIMessageList.d.ts +1 -1
- package/dist/esm/components/TUIMessageList/TUIMessageList.js +1 -1
- package/dist/esm/components/TUIMessageList/hooks/useMessageListElement.js +1 -1
- package/dist/esm/components/TUIProfile/TUIProfileDefault.d.ts +1 -1
- package/dist/esm/components/TUIProfile/TUIProfileDefault.js +1 -1
- package/dist/esm/components/TUIProfile/hooks/useMyProfile.js +1 -1
- package/dist/esm/components/untils.js +1 -1
- package/dist/esm/constants.js +1 -1
- package/dist/esm/context/TUIChatActionContext.d.ts +3 -3
- package/dist/esm/context/TUIChatStateContext.d.ts +2 -2
- package/dist/esm/context/TUIConversationContext.js +1 -1
- package/dist/esm/context/TUIKitContext.d.ts +2 -2
- package/dist/esm/context/TUIMessageContext.d.ts +1 -1
- package/dist/esm/hooks/useConversation.d.ts +3 -3
- package/dist/esm/hooks/useConversation.js +1 -1
- package/dist/esm/hooks/useProfile.d.ts +1 -1
- package/dist/esm/index.js +1 -1
- package/package.json +2 -3
- package/src/components/ConversationCreate/ConversationCreatGroupDetail.tsx +1 -1
- package/src/components/ConversationCreate/ConversationCreate.tsx +3 -3
- package/src/components/ConversationCreate/ConversationCreateSelectView.tsx +1 -1
- package/src/components/ConversationCreate/ConversationCreateUserSelectList.tsx +4 -4
- package/src/components/ConversationCreate/ConversationGroupTypeInfo.tsx +5 -5
- package/src/components/ConversationCreate/hooks/useConversationCreate.tsx +6 -6
- package/src/components/ConversationPreview/ConversationListContainer.tsx +1 -1
- package/src/components/ConversationPreview/ConversationPreview.tsx +1 -1
- package/src/components/ConversationPreview/ConversationPreviewContent.tsx +2 -2
- package/src/components/ConversationPreview/utils.tsx +10 -10
- package/src/components/ConversationSearch/ConversationSearchResult.tsx +1 -1
- package/src/components/Profile/Profile.tsx +1 -1
- package/src/components/Profile/hooks/useProfile.tsx +5 -5
- package/src/components/TUIChat/TUIChat.tsx +23 -17
- package/src/components/TUIChat/TUIChatState.tsx +7 -7
- package/src/components/TUIChat/hooks/useCreateMessage.tsx +29 -29
- package/src/components/TUIChat/hooks/useCreateTUIChatStateContext.tsx +5 -5
- package/src/components/TUIChat/hooks/useHandleMessage.tsx +2 -2
- package/src/components/TUIChat/hooks/useHandleMessageList.tsx +28 -15
- package/src/components/TUIChat/hooks/useMessageReceviedListener.tsx +5 -5
- package/src/components/TUIChat/unitls.ts +3 -3
- package/src/components/TUIChatHeader/TUIChatHeader.tsx +1 -1
- package/src/components/TUIChatHeader/TUIChatHeaderDefault.tsx +7 -7
- package/src/components/TUIConversation/TUIConversation.tsx +1 -1
- package/src/components/TUIConversationList/TUIConversationList.tsx +3 -3
- package/src/components/TUIConversationList/hooks/useConversationList.tsx +5 -5
- package/src/components/TUIConversationList/hooks/useConversationUpdate.tsx +6 -6
- package/src/components/TUIKit/TUIKit.tsx +5 -5
- package/src/components/TUIKit/hooks/useCreateTUIKitContext.tsx +3 -3
- package/src/components/TUIKit/hooks/useTUIKit.tsx +8 -8
- package/src/components/TUIManage/TUIManage.tsx +2 -2
- package/src/components/TUIMessage/MessageAvatar.tsx +1 -1
- package/src/components/TUIMessage/MessageBubble.tsx +4 -4
- package/src/components/TUIMessage/MessageContext.tsx +19 -19
- package/src/components/TUIMessage/MessageCustom.tsx +2 -2
- package/src/components/TUIMessage/MessageFile.tsx +2 -2
- package/src/components/TUIMessage/MessageImage.tsx +2 -2
- package/src/components/TUIMessage/MessageMerger.tsx +2 -2
- package/src/components/TUIMessage/MessageName.tsx +2 -2
- package/src/components/TUIMessage/MessagePlugins.tsx +3 -3
- package/src/components/TUIMessage/MessageProgress.tsx +8 -8
- package/src/components/TUIMessage/MessageRevoke.tsx +2 -2
- package/src/components/TUIMessage/MessageStatus.tsx +1 -1
- package/src/components/TUIMessage/MessageText.tsx +2 -2
- package/src/components/TUIMessage/TUIMessage.tsx +1 -1
- package/src/components/TUIMessage/TUIMessageDefault.tsx +7 -8
- package/src/components/TUIMessage/hooks/useMessageContextHandler.ts +12 -12
- package/src/components/TUIMessage/hooks/useMessageHandler.ts +12 -12
- package/src/components/TUIMessage/hooks/useMessagePluginElement.tsx +2 -2
- package/src/components/TUIMessage/hooks/useMessageReply.ts +11 -11
- package/src/components/TUIMessage/utils/index.ts +16 -16
- package/src/components/TUIMessageInput/InputQuoteDefalut.tsx +1 -1
- package/src/components/TUIMessageInput/TUIForward.tsx +1 -1
- package/src/components/TUIMessageInput/TUIMessageInput.tsx +2 -2
- package/src/components/TUIMessageInput/hooks/useHandleForwardMessage.tsx +5 -5
- package/src/components/TUIMessageInput/hooks/useHandleQuoteMessage.tsx +15 -15
- package/src/components/TUIMessageInput/hooks/useMessageInputText.tsx +2 -2
- package/src/components/TUIMessageInput/hooks/useUploadPicker.tsx +2 -2
- package/src/components/TUIMessageList/TUIMessageList.tsx +2 -2
- package/src/components/TUIMessageList/hooks/useEnrichedMessageList.tsx +1 -1
- package/src/components/TUIMessageList/hooks/useMessageListElement.tsx +8 -11
- package/src/components/TUIProfile/TUIProfileDefault.tsx +6 -6
- package/src/components/TUIProfile/hooks/useMyProfile.tsx +9 -9
- package/src/components/untils.ts +4 -4
- package/src/constants.ts +1 -1
- package/src/context/TUIChatActionContext.tsx +3 -3
- package/src/context/TUIChatStateContext.tsx +2 -2
- package/src/context/TUIConversationContext.tsx +1 -1
- package/src/context/TUIKitContext.tsx +2 -2
- package/src/context/TUIMessageContext.tsx +1 -1
- package/src/hooks/useConversation.tsx +11 -11
- package/src/hooks/useProfile.tsx +2 -2
- package/readme.zh_cn.md +0 -60
- package/src/@types/index.d.ts +0 -1
- package/src/@types/index.js +0 -3
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { useMemo, useState } from 'react';
|
|
2
2
|
import './styles/index.scss';
|
|
3
|
-
import { Conversation } from '
|
|
3
|
+
import { Conversation } from '@tencentcloud/chat';
|
|
4
4
|
import { Icon, IconTypes } from '../Icon';
|
|
5
5
|
import { ConversationCreateUserSelectList } from './ConversationCreateUserSelectList';
|
|
6
6
|
import { ConversationCreatGroupDetail } from './ConversationCreatGroupDetail';
|
|
@@ -22,8 +22,8 @@ export function ConversationCreate<T extends ConversationCreateProps>(props:T) {
|
|
|
22
22
|
const [isCreateGroup, setIsCreateGroup] = useState(false);
|
|
23
23
|
const [pageState, setPageState] = useState<PageStateTypes>(PageStateTypes.USER_SELECT);
|
|
24
24
|
const [selectList, setSelectList] = useState([]);
|
|
25
|
-
const {
|
|
26
|
-
const { createConversation } = useConversation(
|
|
25
|
+
const { chat } = useTUIKitContext();
|
|
26
|
+
const { createConversation } = useConversation(chat);
|
|
27
27
|
const back = () => {
|
|
28
28
|
if (isCreateGroup) {
|
|
29
29
|
switch (pageState) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { Profile } from '
|
|
2
|
+
import { Profile } from '@tencentcloud/chat';
|
|
3
3
|
import { Avatar, defaultUserAvatar } from '../Avatar';
|
|
4
4
|
import './styles/conversationCreateSelectView.scss';
|
|
5
5
|
import { Icon, IconTypes } from '../Icon';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { useRef, useState } from 'react';
|
|
2
|
-
import { Conversation } from '
|
|
2
|
+
import { Conversation } from '@tencentcloud/chat';
|
|
3
3
|
import { Input } from '../Input';
|
|
4
4
|
import { Icon, IconTypes } from '../Icon';
|
|
5
5
|
import { ConversationCreateSelectView, ConversationCreateSelectViewProps } from './ConversationCreateSelectView';
|
|
@@ -30,14 +30,14 @@ export function ConversationCreateUserSelectList(props: ConversationCreateUserSe
|
|
|
30
30
|
setPageState,
|
|
31
31
|
} = props;
|
|
32
32
|
const [searchValue, setSearchValue] = useState('');
|
|
33
|
-
const {
|
|
33
|
+
const { chat, setActiveConversation } = useTUIKitContext();
|
|
34
34
|
const [friendList, setFriendList] = useState({});
|
|
35
35
|
const {
|
|
36
36
|
getFriendListSortSearchResult,
|
|
37
|
-
} = useConversationCreate(
|
|
37
|
+
} = useConversationCreate(chat, conversationList, (newFriendListResult) => {
|
|
38
38
|
setFriendList(newFriendListResult);
|
|
39
39
|
});
|
|
40
|
-
const { createConversation } = useConversation(
|
|
40
|
+
const { createConversation } = useConversation(chat);
|
|
41
41
|
const userCheckedList = useRef(new Map());
|
|
42
42
|
const searchValueChange = async (e) => {
|
|
43
43
|
const { value } = e.target;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import './styles/conversationGroupTypeInfo.scss';
|
|
3
|
-
import
|
|
3
|
+
import TencentCloudChat from '@tencentcloud/chat';
|
|
4
4
|
import { PageStateTypes } from './ConversationCreate';
|
|
5
5
|
import { Icon, IconTypes } from '../Icon';
|
|
6
6
|
|
|
7
7
|
export enum GroupType {
|
|
8
|
-
Work=
|
|
9
|
-
Public=
|
|
10
|
-
Meeting=
|
|
11
|
-
AVChatRoom=
|
|
8
|
+
Work= TencentCloudChat.TYPES.GRP_WORK,
|
|
9
|
+
Public= TencentCloudChat.TYPES.GRP_PUBLIC,
|
|
10
|
+
Meeting= TencentCloudChat.TYPES.GRP_MEETING,
|
|
11
|
+
AVChatRoom= TencentCloudChat.TYPES.GRP_AVCHATROOM,
|
|
12
12
|
}
|
|
13
13
|
export interface ConversationGroupTypeInfoProps {
|
|
14
14
|
groupType: string,
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import React, { useState, useEffect } from 'react';
|
|
2
|
-
import
|
|
2
|
+
import TencentCloudChat from '@tencentcloud/chat';
|
|
3
3
|
import { strChineseFirstPy } from '../static/word';
|
|
4
4
|
import { useProfile } from '../../../hooks';
|
|
5
5
|
|
|
6
6
|
export const useConversationCreate = (
|
|
7
|
-
|
|
7
|
+
chat,
|
|
8
8
|
conversationList,
|
|
9
9
|
setFriendListResultHandler?:(
|
|
10
10
|
newFriendListResult: object,
|
|
@@ -22,9 +22,9 @@ export const useConversationCreate = (
|
|
|
22
22
|
};
|
|
23
23
|
const queryFriendList = async () => {
|
|
24
24
|
const frequentlyConversationProfile = conversationList.filter(
|
|
25
|
-
(item) => item.type ===
|
|
25
|
+
(item) => item.type === TencentCloudChat.TYPES.CONV_C2C,
|
|
26
26
|
).slice(0, 5).map((item) => item.userProfile);
|
|
27
|
-
const { code, data } = await
|
|
27
|
+
const { code, data } = await chat.getFriendList();
|
|
28
28
|
if (code === 0) {
|
|
29
29
|
const sortResult = handleData(
|
|
30
30
|
data.map((item) => item.profile),
|
|
@@ -69,7 +69,7 @@ export const useConversationCreate = (
|
|
|
69
69
|
});
|
|
70
70
|
return sortResult;
|
|
71
71
|
};
|
|
72
|
-
const { getUserProfile } = useProfile(
|
|
72
|
+
const { getUserProfile } = useProfile(chat);
|
|
73
73
|
const getFriendListSortSearchResult = async (searchValue: string) => {
|
|
74
74
|
if (!searchValue) return friendListSortResult;
|
|
75
75
|
const { data: profileList } = await getUserProfile([searchValue]);
|
|
@@ -95,7 +95,7 @@ export const useConversationCreate = (
|
|
|
95
95
|
};
|
|
96
96
|
useEffect(() => {
|
|
97
97
|
queryFriendList();
|
|
98
|
-
}, [
|
|
98
|
+
}, [chat]);
|
|
99
99
|
return {
|
|
100
100
|
getFirstLetter,
|
|
101
101
|
queryFriendList,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { useState, useEffect } from 'react';
|
|
2
|
-
import { Conversation } from '
|
|
2
|
+
import { Conversation } from '@tencentcloud/chat';
|
|
3
3
|
import { TUIKitContextValue, useTUIKitContext } from '../../context';
|
|
4
4
|
import { ConversationPreviewContent } from './ConversationPreviewContent';
|
|
5
5
|
import { AvatarProps } from '../Avatar';
|
|
@@ -41,8 +41,8 @@ export function unMemoConversationPreviewContent<T extends ConversationPreviewUI
|
|
|
41
41
|
const handleMouseLeave = () => {
|
|
42
42
|
setIsHover(false);
|
|
43
43
|
};
|
|
44
|
-
const {
|
|
45
|
-
const { pinConversation, deleteConversation } = useConversation(
|
|
44
|
+
const { chat, conversation: activeConversation } = useTUIKitContext('ConversationPreviewContent');
|
|
45
|
+
const { pinConversation, deleteConversation } = useConversation(chat);
|
|
46
46
|
const moreHandle = (type: string) => {
|
|
47
47
|
const { conversationID, isPinned } = conversation;
|
|
48
48
|
switch (type) {
|
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
format, isToday, isYesterday, formatDistance, isThisYear, isThisWeek,
|
|
3
3
|
} from 'date-fns';
|
|
4
4
|
import React from 'react';
|
|
5
|
-
import
|
|
5
|
+
import TencentCloudChat, { Conversation, Group, Profile } from '@tencentcloud/chat';
|
|
6
6
|
import { defaultGroupAvatarWork, defaultUserAvatar } from '../Avatar';
|
|
7
7
|
import { formatEmojiString } from '../TUIMessage/utils/emojiMap';
|
|
8
8
|
|
|
@@ -17,10 +17,10 @@ export const getDisplayTitle = (
|
|
|
17
17
|
const { type } = conversation;
|
|
18
18
|
let title = '';
|
|
19
19
|
switch (type) {
|
|
20
|
-
case
|
|
20
|
+
case TencentCloudChat.TYPES.CONV_C2C:
|
|
21
21
|
title = nick || userID;
|
|
22
22
|
break;
|
|
23
|
-
case
|
|
23
|
+
case TencentCloudChat.TYPES.CONV_GROUP:
|
|
24
24
|
title = name || groupID;
|
|
25
25
|
break;
|
|
26
26
|
default:
|
|
@@ -45,10 +45,10 @@ export const getDisplayImage = (conversation: Conversation) => {
|
|
|
45
45
|
let displayImage = avatar;
|
|
46
46
|
if (!avatar) {
|
|
47
47
|
switch (type) {
|
|
48
|
-
case
|
|
48
|
+
case TencentCloudChat.TYPES.CONV_C2C:
|
|
49
49
|
displayImage = defaultUserAvatar;
|
|
50
50
|
break;
|
|
51
|
-
case
|
|
51
|
+
case TencentCloudChat.TYPES.CONV_GROUP:
|
|
52
52
|
displayImage = defaultGroupAvatarWork;
|
|
53
53
|
break;
|
|
54
54
|
default:
|
|
@@ -64,11 +64,11 @@ export const getDisplayMessage = (conversation:Conversation, myProfile:Profile)
|
|
|
64
64
|
} = lastMessage;
|
|
65
65
|
let from = '';
|
|
66
66
|
switch (type) {
|
|
67
|
-
case
|
|
67
|
+
case TencentCloudChat.TYPES.CONV_GROUP:
|
|
68
68
|
from = lastMessage?.fromAccount === myProfile?.userID ? 'You' : `${nameCard || nick || fromAccount || ''}`;
|
|
69
69
|
from = `${from ? `${from}:` : ''}`;
|
|
70
70
|
break;
|
|
71
|
-
case
|
|
71
|
+
case TencentCloudChat.TYPES.CONV_C2C:
|
|
72
72
|
from = isRevoked ? 'you ' : '';
|
|
73
73
|
break;
|
|
74
74
|
default:
|
|
@@ -91,13 +91,13 @@ export const getMessageProfile = (conversation: Conversation):TProfile => {
|
|
|
91
91
|
let result = {};
|
|
92
92
|
const { type, groupProfile, userProfile } = conversation;
|
|
93
93
|
switch (type) {
|
|
94
|
-
case
|
|
94
|
+
case TencentCloudChat.TYPES.CONV_C2C:
|
|
95
95
|
result = userProfile;
|
|
96
96
|
break;
|
|
97
|
-
case
|
|
97
|
+
case TencentCloudChat.TYPES.CONV_GROUP:
|
|
98
98
|
result = groupProfile;
|
|
99
99
|
break;
|
|
100
|
-
case
|
|
100
|
+
case TencentCloudChat.TYPES.CONV_SYSTEM:
|
|
101
101
|
default:
|
|
102
102
|
}
|
|
103
103
|
return result as TProfile;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import './styles/index.scss';
|
|
3
|
-
import { Profile as TProfile } from '
|
|
3
|
+
import { Profile as TProfile } from '@tencentcloud/chat';
|
|
4
4
|
import { Avatar, defaultUserAvatar } from '../Avatar';
|
|
5
5
|
import { Icon, IconTypes } from '../Icon';
|
|
6
6
|
|
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
import React, { useState, useEffect } from 'react';
|
|
2
|
-
import { ChatSDK, Profile } from '
|
|
2
|
+
import { ChatSDK, Profile } from '@tencentcloud/chat';
|
|
3
3
|
|
|
4
|
-
export function useProfile(
|
|
4
|
+
export function useProfile(chat: ChatSDK, profileHandler?: (
|
|
5
5
|
profile: Profile,
|
|
6
6
|
setProfile?: React.Dispatch<React.SetStateAction<Profile>>,
|
|
7
7
|
) => void) {
|
|
8
8
|
const [myProfile, setMyProfile] = useState<Profile>();
|
|
9
9
|
|
|
10
10
|
const getProfile = async (userIDList: Array<string>) => {
|
|
11
|
-
const res = await
|
|
11
|
+
const res = await chat?.getUserProfile({
|
|
12
12
|
userIDList,
|
|
13
13
|
});
|
|
14
14
|
return res.data;
|
|
15
15
|
};
|
|
16
16
|
const getMyProfile = async () => {
|
|
17
|
-
const res = await
|
|
17
|
+
const res = await chat?.getMyProfile();
|
|
18
18
|
setMyProfile(res?.data);
|
|
19
19
|
};
|
|
20
20
|
useEffect(() => {
|
|
21
21
|
getMyProfile();
|
|
22
|
-
}, [
|
|
22
|
+
}, [chat]);
|
|
23
23
|
return {
|
|
24
24
|
myProfile,
|
|
25
25
|
setMyProfile,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, {
|
|
2
2
|
PropsWithChildren, useEffect, useMemo, useReducer, useRef, useState,
|
|
3
3
|
} from 'react';
|
|
4
|
-
import { ChatSDK, Conversation, Message } from '
|
|
4
|
+
import { ChatSDK, Conversation, Message } from '@tencentcloud/chat';
|
|
5
5
|
import { useTUIKitContext } from '../../context/TUIKitContext';
|
|
6
6
|
import { TUIChatStateContextProvider } from '../../context/TUIChatStateContext';
|
|
7
7
|
import { TUIChatActionProvider } from '../../context/TUIChatActionContext';
|
|
@@ -58,7 +58,7 @@ interface TUIChatProps {
|
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
interface TUIChatInnerProps extends TUIChatProps {
|
|
61
|
-
|
|
61
|
+
chat?: ChatSDK,
|
|
62
62
|
key?: string;
|
|
63
63
|
}
|
|
64
64
|
|
|
@@ -70,7 +70,7 @@ function UnMemoizedTUIChat <T extends TUIChatProps>(
|
|
|
70
70
|
EmptyPlaceholder = <EmptyStateIndicator listType="chat" />,
|
|
71
71
|
} = props;
|
|
72
72
|
|
|
73
|
-
const { conversation: contextConversation,
|
|
73
|
+
const { conversation: contextConversation, chat } = useTUIKitContext('TUIChat');
|
|
74
74
|
|
|
75
75
|
const conversation = propsConversation || contextConversation;
|
|
76
76
|
|
|
@@ -78,7 +78,7 @@ function UnMemoizedTUIChat <T extends TUIChatProps>(
|
|
|
78
78
|
|
|
79
79
|
return (
|
|
80
80
|
<TUIChatInner
|
|
81
|
-
|
|
81
|
+
chat={chat}
|
|
82
82
|
{...props}
|
|
83
83
|
conversation={conversation}
|
|
84
84
|
key={conversation.conversationID}
|
|
@@ -90,7 +90,7 @@ function TUIChatInner <T extends TUIChatInnerProps>(
|
|
|
90
90
|
props: PropsWithChildren<T>,
|
|
91
91
|
):React.ReactElement {
|
|
92
92
|
const {
|
|
93
|
-
|
|
93
|
+
chat,
|
|
94
94
|
conversation,
|
|
95
95
|
className,
|
|
96
96
|
children,
|
|
@@ -118,7 +118,7 @@ function TUIChatInner <T extends TUIChatInnerProps>(
|
|
|
118
118
|
const messageListRef = useRef(null);
|
|
119
119
|
const textareaRef = useRef<HTMLTextAreaElement>();
|
|
120
120
|
const chatStateContextValue = useCreateTUIChatStateContext({
|
|
121
|
-
|
|
121
|
+
chat,
|
|
122
122
|
conversation,
|
|
123
123
|
messageListRef,
|
|
124
124
|
textareaRef,
|
|
@@ -141,16 +141,16 @@ function TUIChatInner <T extends TUIChatInnerProps>(
|
|
|
141
141
|
createTextAtMessage,
|
|
142
142
|
createLocationMessage,
|
|
143
143
|
createMergerMessage,
|
|
144
|
-
} = useCreateMessage({
|
|
144
|
+
} = useCreateMessage({ chat, conversation, cloudCustomData });
|
|
145
145
|
|
|
146
146
|
const {
|
|
147
147
|
getMessageList,
|
|
148
148
|
updateMessage,
|
|
149
|
-
|
|
149
|
+
editLocalMessage,
|
|
150
150
|
removeMessage,
|
|
151
|
-
|
|
151
|
+
updateUploadPendingMessageList,
|
|
152
152
|
} = useHandleMessageList({
|
|
153
|
-
|
|
153
|
+
chat, conversation, state, dispatch,
|
|
154
154
|
});
|
|
155
155
|
|
|
156
156
|
const {
|
|
@@ -168,12 +168,12 @@ function TUIChatInner <T extends TUIChatInnerProps>(
|
|
|
168
168
|
if (propsSendMessage) {
|
|
169
169
|
await propsSendMessage(message, options);
|
|
170
170
|
} else {
|
|
171
|
-
await
|
|
171
|
+
await chat.sendMessage(message, options);
|
|
172
172
|
}
|
|
173
|
-
|
|
173
|
+
editLocalMessage(message);
|
|
174
174
|
} catch (error) {
|
|
175
175
|
Toast({ text: error, type: 'error' });
|
|
176
|
-
|
|
176
|
+
editLocalMessage(message);
|
|
177
177
|
throw new Error(error);
|
|
178
178
|
}
|
|
179
179
|
};
|
|
@@ -189,6 +189,9 @@ function TUIChatInner <T extends TUIChatInnerProps>(
|
|
|
189
189
|
const historyMessageData = await getMessageList({
|
|
190
190
|
nextReqMessageID: state.nextReqMessageID,
|
|
191
191
|
});
|
|
192
|
+
if (!historyMessageData) {
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
192
195
|
dispatch({
|
|
193
196
|
type: CONSTANT_DISPATCH_TYPE.SET_HISTORY_MESSAGELIST,
|
|
194
197
|
value: historyMessageData.data.messageList,
|
|
@@ -208,6 +211,9 @@ function TUIChatInner <T extends TUIChatInnerProps>(
|
|
|
208
211
|
useEffect(() => {
|
|
209
212
|
(async () => {
|
|
210
213
|
const res = await getMessageList();
|
|
214
|
+
if (!res) {
|
|
215
|
+
return;
|
|
216
|
+
}
|
|
211
217
|
if (res.data.messageList.length > 0) {
|
|
212
218
|
dispatch({
|
|
213
219
|
type: CONSTANT_DISPATCH_TYPE.SET_MESSAGELIST,
|
|
@@ -245,14 +251,14 @@ function TUIChatInner <T extends TUIChatInnerProps>(
|
|
|
245
251
|
createTextAtMessage,
|
|
246
252
|
createLocationMessage,
|
|
247
253
|
createMergerMessage,
|
|
248
|
-
|
|
254
|
+
editLocalMessage,
|
|
249
255
|
operateMessage,
|
|
250
256
|
loadMore,
|
|
251
257
|
revokeMessage,
|
|
252
258
|
setAudioSource,
|
|
253
259
|
setVideoSource,
|
|
254
260
|
setHighlightedMessageId,
|
|
255
|
-
|
|
261
|
+
updateUploadPendingMessageList,
|
|
256
262
|
}),
|
|
257
263
|
[
|
|
258
264
|
sendMessage,
|
|
@@ -269,14 +275,14 @@ function TUIChatInner <T extends TUIChatInnerProps>(
|
|
|
269
275
|
createTextAtMessage,
|
|
270
276
|
createLocationMessage,
|
|
271
277
|
createMergerMessage,
|
|
272
|
-
|
|
278
|
+
editLocalMessage,
|
|
273
279
|
operateMessage,
|
|
274
280
|
loadMore,
|
|
275
281
|
revokeMessage,
|
|
276
282
|
setAudioSource,
|
|
277
283
|
setVideoSource,
|
|
278
284
|
setHighlightedMessageId,
|
|
279
|
-
|
|
285
|
+
updateUploadPendingMessageList,
|
|
280
286
|
],
|
|
281
287
|
);
|
|
282
288
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Reducer } from 'react';
|
|
2
|
-
import { Conversation, Message } from '
|
|
2
|
+
import { Conversation, Message } from '@tencentcloud/chat';
|
|
3
3
|
import { CONSTANT_DISPATCH_TYPE } from '../../constants';
|
|
4
4
|
import type { TUIChatStateContextValue } from '../../context';
|
|
5
5
|
import { OperateMessageParams } from './hooks/useHandleMessage';
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
handleMessageList,
|
|
9
9
|
handleEditMessage,
|
|
10
10
|
handleRemoveMessage,
|
|
11
|
-
|
|
11
|
+
handleUploadPendingMessage,
|
|
12
12
|
} from './unitls';
|
|
13
13
|
|
|
14
14
|
export type ChatStateReducerAction =
|
|
@@ -70,7 +70,7 @@ export type ChatStateReducerAction =
|
|
|
70
70
|
value?: HTMLVideoElement | null,
|
|
71
71
|
}
|
|
72
72
|
| {
|
|
73
|
-
type: CONSTANT_DISPATCH_TYPE.
|
|
73
|
+
type: CONSTANT_DISPATCH_TYPE.UPDATE_UPLOAD_PENDING_MESSAGE_LIST,
|
|
74
74
|
value?: Message,
|
|
75
75
|
}
|
|
76
76
|
export type ChatStateReducer = Reducer<TUIChatStateContextValue, ChatStateReducerAction>;
|
|
@@ -128,11 +128,11 @@ export const chatReducer = (
|
|
|
128
128
|
return { ...state, audioSource: action.value };
|
|
129
129
|
case CONSTANT_DISPATCH_TYPE.SET_VIDEO_SOURCE:
|
|
130
130
|
return { ...state, vidoeSource: action.value };
|
|
131
|
-
case CONSTANT_DISPATCH_TYPE.
|
|
131
|
+
case CONSTANT_DISPATCH_TYPE.UPDATE_UPLOAD_PENDING_MESSAGE_LIST:
|
|
132
132
|
return {
|
|
133
133
|
...state,
|
|
134
|
-
|
|
135
|
-
...
|
|
134
|
+
uploadPendingMessageList: [
|
|
135
|
+
...handleUploadPendingMessage(state.uploadPendingMessageList, action.value),
|
|
136
136
|
],
|
|
137
137
|
};
|
|
138
138
|
default: return state;
|
|
@@ -152,5 +152,5 @@ export const initialState:TUIChatStateContextValue = {
|
|
|
152
152
|
noMore: false,
|
|
153
153
|
audioSource: null,
|
|
154
154
|
vidoeSource: null,
|
|
155
|
-
|
|
155
|
+
uploadPendingMessageList: [],
|
|
156
156
|
};
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { useCallback, useEffect, useState } from 'react';
|
|
2
|
-
import
|
|
2
|
+
import TencentCloudChat, { ChatSDK, Conversation, Message } from '@tencentcloud/chat';
|
|
3
3
|
|
|
4
4
|
export interface CreateMessageProps {
|
|
5
|
-
|
|
5
|
+
chat?: ChatSDK,
|
|
6
6
|
conversation?: Conversation,
|
|
7
7
|
to?: string,
|
|
8
|
-
type?:
|
|
8
|
+
type?: TencentCloudChat.TYPES,
|
|
9
9
|
cloudCustomData?: string,
|
|
10
10
|
}
|
|
11
11
|
export interface BasicCreateMessageProps {
|
|
12
12
|
needReadReceipt?: boolean,
|
|
13
|
-
priority?:
|
|
13
|
+
priority?: TencentCloudChat.TYPES,
|
|
14
14
|
onProgress?: (num:number) => void,
|
|
15
15
|
cloudCustomData?: string;
|
|
16
16
|
receiverList?: Array<string>;
|
|
@@ -74,7 +74,7 @@ export interface CreateMergerMessageProps extends BasicCreateMessageProps{
|
|
|
74
74
|
|
|
75
75
|
export function useCreateMessage<T extends CreateMessageProps>(props:T) {
|
|
76
76
|
const {
|
|
77
|
-
|
|
77
|
+
chat,
|
|
78
78
|
conversation,
|
|
79
79
|
to = '',
|
|
80
80
|
type: propType,
|
|
@@ -86,7 +86,7 @@ export function useCreateMessage<T extends CreateMessageProps>(props:T) {
|
|
|
86
86
|
const type = propType || conversationType;
|
|
87
87
|
|
|
88
88
|
const [basicConfig, setBasicConfig] = useState({
|
|
89
|
-
to: to || (type ===
|
|
89
|
+
to: to || (type === TencentCloudChat.TYPES.CONV_C2C ? userProfile?.userID : groupProfile?.groupID),
|
|
90
90
|
conversationType: type,
|
|
91
91
|
cloudCustomData,
|
|
92
92
|
});
|
|
@@ -96,36 +96,36 @@ export function useCreateMessage<T extends CreateMessageProps>(props:T) {
|
|
|
96
96
|
setBasicConfig(basicConfig);
|
|
97
97
|
}, [cloudCustomData]);
|
|
98
98
|
|
|
99
|
-
const createTextMessage = useCallback((params: CreateTextMessageProps) =>
|
|
99
|
+
const createTextMessage = useCallback((params: CreateTextMessageProps) => chat.createTextMessage({
|
|
100
100
|
...basicConfig,
|
|
101
101
|
...params,
|
|
102
|
-
}), [
|
|
102
|
+
}), [chat]);
|
|
103
103
|
|
|
104
|
-
const createFaceMessage = useCallback((params: CreateFaceMessageProps) =>
|
|
104
|
+
const createFaceMessage = useCallback((params: CreateFaceMessageProps) => chat.createFaceMessage({
|
|
105
105
|
...basicConfig,
|
|
106
106
|
...params,
|
|
107
|
-
}), [
|
|
107
|
+
}), [chat]);
|
|
108
108
|
|
|
109
109
|
const createImageMessage = useCallback((
|
|
110
110
|
params: CreateUploadMessageProps,
|
|
111
|
-
) =>
|
|
111
|
+
) => chat.createImageMessage({
|
|
112
112
|
...basicConfig,
|
|
113
113
|
...params,
|
|
114
|
-
}), [
|
|
114
|
+
}), [chat]);
|
|
115
115
|
|
|
116
116
|
const createVideoMessage = useCallback((
|
|
117
117
|
params: CreateUploadMessageProps,
|
|
118
|
-
) =>
|
|
118
|
+
) => chat.createVideoMessage({
|
|
119
119
|
...basicConfig,
|
|
120
120
|
...params,
|
|
121
|
-
}), [
|
|
121
|
+
}), [chat]);
|
|
122
122
|
|
|
123
123
|
const createFileMessage = useCallback((
|
|
124
124
|
params: CreateUploadMessageProps,
|
|
125
|
-
) =>
|
|
125
|
+
) => chat.createFileMessage({
|
|
126
126
|
...basicConfig,
|
|
127
127
|
...params,
|
|
128
|
-
}), [
|
|
128
|
+
}), [chat]);
|
|
129
129
|
|
|
130
130
|
const createForwardMessage = useCallback((
|
|
131
131
|
params: CreateForwardMessageProps,
|
|
@@ -136,51 +136,51 @@ export function useCreateMessage<T extends CreateMessageProps>(props:T) {
|
|
|
136
136
|
userProfile: forwardUserProfile,
|
|
137
137
|
groupProfile: forwardGroupProfile,
|
|
138
138
|
} = forwardConversation;
|
|
139
|
-
const forwardTo = forwardType ===
|
|
139
|
+
const forwardTo = forwardType === TencentCloudChat.TYPES.CONV_C2C
|
|
140
140
|
? forwardUserProfile?.userID : forwardGroupProfile?.groupID;
|
|
141
|
-
return
|
|
141
|
+
return chat.createForwardMessage({
|
|
142
142
|
to: forwardTo,
|
|
143
143
|
conversationType: forwardType,
|
|
144
144
|
payload: message,
|
|
145
145
|
...other,
|
|
146
146
|
});
|
|
147
|
-
}, [
|
|
147
|
+
}, [chat]);
|
|
148
148
|
|
|
149
149
|
const createCustomMessage = useCallback((
|
|
150
150
|
params: CreateCustomMessageProps,
|
|
151
151
|
// ChatSDK < V2.26.0 createCustomMessage ts declaration error
|
|
152
|
-
) => (
|
|
152
|
+
) => (chat as any).createCustomMessage({
|
|
153
153
|
...basicConfig,
|
|
154
154
|
...params,
|
|
155
|
-
}), [
|
|
155
|
+
}), [chat]);
|
|
156
156
|
|
|
157
157
|
const createAudioMessage = useCallback((
|
|
158
158
|
params: CreateUploadMessageProps,
|
|
159
|
-
) =>
|
|
159
|
+
) => chat.createAudioMessage({
|
|
160
160
|
...basicConfig,
|
|
161
161
|
...params,
|
|
162
|
-
}), [
|
|
162
|
+
}), [chat]);
|
|
163
163
|
|
|
164
164
|
const createTextAtMessage = useCallback((
|
|
165
165
|
params: CreateTextAtMessageProps,
|
|
166
|
-
) =>
|
|
166
|
+
) => chat.createTextAtMessage({
|
|
167
167
|
...basicConfig,
|
|
168
168
|
...params,
|
|
169
|
-
}), [
|
|
169
|
+
}), [chat]);
|
|
170
170
|
|
|
171
171
|
const createLocationMessage = useCallback((
|
|
172
172
|
params: CreateLocationMessageProps,
|
|
173
|
-
) =>
|
|
173
|
+
) => chat.createLocationMessage({
|
|
174
174
|
...basicConfig,
|
|
175
175
|
...params,
|
|
176
|
-
}), [
|
|
176
|
+
}), [chat]);
|
|
177
177
|
|
|
178
178
|
const createMergerMessage = useCallback((
|
|
179
179
|
params: CreateMergerMessageProps,
|
|
180
|
-
) =>
|
|
180
|
+
) => chat.createMergerMessage({
|
|
181
181
|
...basicConfig,
|
|
182
182
|
...params,
|
|
183
|
-
}), [
|
|
183
|
+
}), [chat]);
|
|
184
184
|
|
|
185
185
|
return {
|
|
186
186
|
createTextMessage,
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { useMemo } from 'react';
|
|
2
|
-
import { ChatSDK } from '
|
|
2
|
+
import { ChatSDK } from '@tencentcloud/chat';
|
|
3
3
|
import { TUIChatStateContextValue } from '../../../context';
|
|
4
4
|
|
|
5
5
|
interface CreateTUIChatStateContextProp extends TUIChatStateContextValue {
|
|
6
|
-
|
|
6
|
+
chat?: ChatSDK,
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
function useCreateTUIChatStateContext(props:CreateTUIChatStateContextProp) {
|
|
10
10
|
const {
|
|
11
|
-
|
|
11
|
+
chat,
|
|
12
12
|
conversation,
|
|
13
13
|
messageList,
|
|
14
14
|
messageListRef,
|
|
@@ -19,7 +19,7 @@ function useCreateTUIChatStateContext(props:CreateTUIChatStateContextProp) {
|
|
|
19
19
|
...state
|
|
20
20
|
} = props;
|
|
21
21
|
const TUIChatStateContext = useMemo(() => ({
|
|
22
|
-
|
|
22
|
+
chat,
|
|
23
23
|
conversation,
|
|
24
24
|
messageList,
|
|
25
25
|
messageListRef,
|
|
@@ -29,7 +29,7 @@ function useCreateTUIChatStateContext(props:CreateTUIChatStateContextProp) {
|
|
|
29
29
|
TUIMessageListConfig,
|
|
30
30
|
...state,
|
|
31
31
|
}), [
|
|
32
|
-
|
|
32
|
+
chat,
|
|
33
33
|
conversation,
|
|
34
34
|
messageList,
|
|
35
35
|
messageListRef,
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { Dispatch, useCallback } from 'react';
|
|
2
|
-
import { ChatSDK, Conversation, Message } from '
|
|
2
|
+
import { ChatSDK, Conversation, Message } from '@tencentcloud/chat';
|
|
3
3
|
import { CONSTANT_DISPATCH_TYPE } from '../../../constants';
|
|
4
4
|
import type { TUIChatStateContextValue } from '../../../context';
|
|
5
5
|
import type { ChatStateReducerAction } from '../TUIChatState';
|
|
6
6
|
|
|
7
7
|
export interface CreateMessageProps {
|
|
8
|
-
|
|
8
|
+
chat?: ChatSDK,
|
|
9
9
|
conversation?: Conversation,
|
|
10
10
|
state?: TUIChatStateContextValue,
|
|
11
11
|
dispatch?: Dispatch<ChatStateReducerAction>,
|