@tencentcloud/chat-uikit-react 1.0.3 → 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 +69 -83
- package/dist/cjs/components/ConversationCreate/ConversationCreatGroupDetail.js +1 -1
- 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/ConversationCreatGroupDetail.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 +5 -2
- 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,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>,
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { Dispatch, useCallback } from 'react';
|
|
2
|
-
import { ChatSDK, Conversation, Message } from '
|
|
2
|
+
import TencentCloudChat, { 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>,
|
|
@@ -18,25 +18,38 @@ export interface GetMessageListProps{
|
|
|
18
18
|
|
|
19
19
|
export function useHandleMessageList<T extends CreateMessageProps>(props:T) {
|
|
20
20
|
const {
|
|
21
|
-
|
|
21
|
+
chat,
|
|
22
22
|
conversation,
|
|
23
23
|
state,
|
|
24
24
|
dispatch,
|
|
25
25
|
} = props;
|
|
26
26
|
|
|
27
|
-
const { conversationID } = conversation;
|
|
27
|
+
const { conversationID, groupProfile, type } = conversation;
|
|
28
|
+
const isC2CConversation = type === TencentCloudChat.TYPES.CONV_C2C;
|
|
28
29
|
|
|
29
30
|
const basicConfig = {
|
|
30
31
|
conversationID,
|
|
31
32
|
};
|
|
32
33
|
|
|
33
|
-
const getMessageList = useCallback((params?: GetMessageListProps) => {
|
|
34
|
+
const getMessageList = useCallback(async (params?: GetMessageListProps) => {
|
|
34
35
|
const data = params || {};
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
36
|
+
let groupType = '';
|
|
37
|
+
if (groupProfile) {
|
|
38
|
+
try {
|
|
39
|
+
const res = await chat.searchGroupByID(groupProfile.groupID);
|
|
40
|
+
groupType = res?.data?.group?.type;
|
|
41
|
+
} catch (error) {
|
|
42
|
+
groupType = '';
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
if (isC2CConversation || (groupType && groupType !== TencentCloudChat.TYPES.GRP_AVCHATROOM)) {
|
|
46
|
+
return chat.getMessageList({
|
|
47
|
+
...basicConfig,
|
|
48
|
+
...data,
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
return null;
|
|
52
|
+
}, [chat]);
|
|
40
53
|
|
|
41
54
|
const updateMessage = useCallback((messageList: Array<Message>) => {
|
|
42
55
|
dispatch({
|
|
@@ -54,16 +67,16 @@ export function useHandleMessageList<T extends CreateMessageProps>(props:T) {
|
|
|
54
67
|
});
|
|
55
68
|
}, [dispatch]);
|
|
56
69
|
|
|
57
|
-
const
|
|
70
|
+
const editLocalMessage = useCallback((message: Message) => {
|
|
58
71
|
dispatch({
|
|
59
72
|
type: CONSTANT_DISPATCH_TYPE.SET_EDIT_MESSAGE,
|
|
60
73
|
value: message,
|
|
61
74
|
});
|
|
62
75
|
}, [dispatch]);
|
|
63
76
|
|
|
64
|
-
const
|
|
77
|
+
const updateUploadPendingMessageList = useCallback((message: Message) => {
|
|
65
78
|
dispatch({
|
|
66
|
-
type: CONSTANT_DISPATCH_TYPE.
|
|
79
|
+
type: CONSTANT_DISPATCH_TYPE.UPDATE_UPLOAD_PENDING_MESSAGE_LIST,
|
|
67
80
|
value: message,
|
|
68
81
|
});
|
|
69
82
|
}, [dispatch]);
|
|
@@ -72,7 +85,7 @@ export function useHandleMessageList<T extends CreateMessageProps>(props:T) {
|
|
|
72
85
|
getMessageList,
|
|
73
86
|
updateMessage,
|
|
74
87
|
removeMessage,
|
|
75
|
-
|
|
76
|
-
|
|
88
|
+
editLocalMessage,
|
|
89
|
+
updateUploadPendingMessageList,
|
|
77
90
|
};
|
|
78
91
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useEffect } from 'react';
|
|
2
|
-
import
|
|
2
|
+
import TencentCloudChat, { Message } from '@tencentcloud/chat';
|
|
3
3
|
import { useTUIKitContext } from '../../../context';
|
|
4
4
|
|
|
5
5
|
export function useMessageReceviedListener(
|
|
@@ -9,7 +9,7 @@ export function useMessageReceviedListener(
|
|
|
9
9
|
event: any,
|
|
10
10
|
) => void,
|
|
11
11
|
) {
|
|
12
|
-
const {
|
|
12
|
+
const { chat } = useTUIKitContext('useMessageReceviedListener');
|
|
13
13
|
useEffect(() => {
|
|
14
14
|
const handleMessageRecevied = (event: any) => {
|
|
15
15
|
if (customHandler && typeof customHandler === 'function') {
|
|
@@ -18,9 +18,9 @@ export function useMessageReceviedListener(
|
|
|
18
18
|
setMessageList(event.data);
|
|
19
19
|
}
|
|
20
20
|
};
|
|
21
|
-
|
|
21
|
+
chat.on(TencentCloudChat.EVENT.MESSAGE_RECEIVED, handleMessageRecevied, this);
|
|
22
22
|
return () => {
|
|
23
|
-
|
|
23
|
+
chat.off(TencentCloudChat.EVENT.MESSAGE_RECEIVED, handleMessageRecevied, this);
|
|
24
24
|
};
|
|
25
|
-
}, [
|
|
25
|
+
}, [chat]);
|
|
26
26
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import TencentCloudChat, { Message } from '@tencentcloud/chat';
|
|
2
2
|
import constant from '../../constants';
|
|
3
3
|
import type { TUIChatStateContextValue } from '../../context';
|
|
4
4
|
import { JSONStringToParse } from '../untils';
|
|
@@ -6,7 +6,7 @@ import { JSONStringToParse } from '../untils';
|
|
|
6
6
|
export const handleMessage = (messageList:Array<Message>):Array<Message> => {
|
|
7
7
|
let customPayloadData = null;
|
|
8
8
|
return messageList.filter((item) => {
|
|
9
|
-
if (item.type ===
|
|
9
|
+
if (item.type === TencentCloudChat.TYPES.MSG_CUSTOM) {
|
|
10
10
|
customPayloadData = JSONStringToParse(item?.payload?.data);
|
|
11
11
|
}
|
|
12
12
|
if (customPayloadData && customPayloadData?.businessID === constant.TYPE_TYPING) {
|
|
@@ -54,7 +54,7 @@ export const handleRemoveMessage = (
|
|
|
54
54
|
return list;
|
|
55
55
|
};
|
|
56
56
|
|
|
57
|
-
export const
|
|
57
|
+
export const handleUploadPendingMessage = (
|
|
58
58
|
messageList: Array<Message>,
|
|
59
59
|
message: Message,
|
|
60
60
|
) => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { PropsWithChildren } from 'react';
|
|
2
|
-
import { Conversation } from '
|
|
2
|
+
import { Conversation } from '@tencentcloud/chat';
|
|
3
3
|
import { useTUIChatStateContext } from '../../context/TUIChatStateContext';
|
|
4
4
|
import type { TUIChatHeaderDefaultProps } from './TUIChatHeaderDefault';
|
|
5
5
|
import { TUIChatHeaderDefault } from './TUIChatHeaderDefault';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { PropsWithChildren, useEffect, useState } from 'react';
|
|
2
|
-
import
|
|
2
|
+
import TencentCloudChat, { Conversation, Group, Profile } from '@tencentcloud/chat';
|
|
3
3
|
import { Avatar } from '../Avatar';
|
|
4
4
|
import { handleDisplayAvatar } from '../untils';
|
|
5
5
|
|
|
@@ -41,13 +41,13 @@ function TUIChatHeaderDefaultWithContext <T extends TUIChatHeaderBasicProps>(
|
|
|
41
41
|
setAvatar(propAvatar);
|
|
42
42
|
}
|
|
43
43
|
switch (conversation?.type) {
|
|
44
|
-
case
|
|
44
|
+
case TencentCloudChat.TYPES.CONV_C2C:
|
|
45
45
|
handleC2C(conversation.userProfile);
|
|
46
46
|
break;
|
|
47
|
-
case
|
|
47
|
+
case TencentCloudChat.TYPES.CONV_GROUP:
|
|
48
48
|
handleGroup(conversation.groupProfile);
|
|
49
49
|
break;
|
|
50
|
-
case
|
|
50
|
+
case TencentCloudChat.TYPES.CONV_SYSTEM:
|
|
51
51
|
setTitle('System Notice');
|
|
52
52
|
break;
|
|
53
53
|
default:
|
|
@@ -72,7 +72,7 @@ function TUIChatHeaderDefaultWithContext <T extends TUIChatHeaderBasicProps>(
|
|
|
72
72
|
if (!propAvatar) {
|
|
73
73
|
setAvatar(<Avatar
|
|
74
74
|
size={32}
|
|
75
|
-
image={handleDisplayAvatar(groupProfile.avatar,
|
|
75
|
+
image={handleDisplayAvatar(groupProfile.avatar, TencentCloudChat.TYPES.CONV_GROUP)}
|
|
76
76
|
/>);
|
|
77
77
|
}
|
|
78
78
|
};
|
|
@@ -87,9 +87,9 @@ function TUIChatHeaderDefaultWithContext <T extends TUIChatHeaderBasicProps>(
|
|
|
87
87
|
key={conversation?.conversationID}
|
|
88
88
|
>
|
|
89
89
|
<div
|
|
90
|
-
className={`tui-chat-header-left ${conversation?.type ===
|
|
90
|
+
className={`tui-chat-header-left ${conversation?.type === TencentCloudChat.TYPES.CONV_SYSTEM ? 'system' : ''}`}
|
|
91
91
|
>
|
|
92
|
-
{conversation?.type !==
|
|
92
|
+
{conversation?.type !== TencentCloudChat.TYPES.CONV_SYSTEM && avatar}
|
|
93
93
|
</div>
|
|
94
94
|
<div className="header-content">
|
|
95
95
|
<h3 className="title">{title}</h3>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { PropsWithChildren, useMemo } from 'react';
|
|
2
|
-
import { Conversation } from '
|
|
2
|
+
import { Conversation } from '@tencentcloud/chat';
|
|
3
3
|
import { TUIConversationProvider, TUIConversationContextValue } from '../../context/TUIConversationContext';
|
|
4
4
|
import { TUIConversationList } from '../TUIConversationList';
|
|
5
5
|
import { TUIProfile } from '../TUIProfile';
|
|
@@ -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 { useTUIKitContext } from '../../context';
|
|
4
4
|
import useConversationList from './hooks/useConversationList';
|
|
5
5
|
import './index.scss';
|
|
@@ -36,7 +36,7 @@ export function UnMemoTUIConversationList<T extends Props>(props: T):React.React
|
|
|
36
36
|
filterConversation: propsFilterConversation,
|
|
37
37
|
} = props;
|
|
38
38
|
const {
|
|
39
|
-
|
|
39
|
+
chat, customClasses, conversation, setActiveConversation, setTUIProfileShow,
|
|
40
40
|
} = useTUIKitContext('TUIConversationList');
|
|
41
41
|
const {
|
|
42
42
|
filterConversation: contextFilterConversation,
|
|
@@ -57,7 +57,7 @@ export function UnMemoTUIConversationList<T extends Props>(props: T):React.React
|
|
|
57
57
|
const {
|
|
58
58
|
conversationList,
|
|
59
59
|
setConversationList,
|
|
60
|
-
} = useConversationList(
|
|
60
|
+
} = useConversationList(chat, activeConversationHandler, filterConversation);
|
|
61
61
|
useConversationUpdate(
|
|
62
62
|
setConversationList,
|
|
63
63
|
onConversationListUpdated,
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import React, { useEffect, useState } from 'react';
|
|
2
|
-
import
|
|
2
|
+
import TencentCloudChat, { ChatSDK, Conversation } from '@tencentcloud/chat';
|
|
3
3
|
|
|
4
4
|
function useConversationList(
|
|
5
|
-
|
|
5
|
+
chat: ChatSDK,
|
|
6
6
|
activeConversationHandler?:(
|
|
7
7
|
conversationList: Array<Conversation>,
|
|
8
8
|
setConversationList: React.Dispatch<React.SetStateAction<Array<Conversation>>>,
|
|
@@ -16,14 +16,14 @@ function useConversationList(
|
|
|
16
16
|
}
|
|
17
17
|
const offset = queryType === 'reload' ? 0 : conversationList.length;
|
|
18
18
|
|
|
19
|
-
const res = await
|
|
19
|
+
const res = await chat?.getConversationList();
|
|
20
20
|
if (res?.code === 0) {
|
|
21
21
|
let resConversationList = [];
|
|
22
22
|
if (filterConversation) {
|
|
23
23
|
resConversationList = filterConversation(res.data.conversationList);
|
|
24
24
|
} else {
|
|
25
25
|
resConversationList = res.data.conversationList.filter(
|
|
26
|
-
(item) => item.type !==
|
|
26
|
+
(item) => item.type !== TencentCloudChat.TYPES.CONV_SYSTEM,
|
|
27
27
|
);
|
|
28
28
|
}
|
|
29
29
|
const newConversationList = queryType === 'reload'
|
|
@@ -37,7 +37,7 @@ function useConversationList(
|
|
|
37
37
|
};
|
|
38
38
|
useEffect(() => {
|
|
39
39
|
queryConversation('reload');
|
|
40
|
-
}, [
|
|
40
|
+
}, [chat]);
|
|
41
41
|
return {
|
|
42
42
|
conversationList,
|
|
43
43
|
setConversationList,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { useEffect } from 'react';
|
|
2
|
-
import
|
|
2
|
+
import TencentCloudChat, { Conversation } from '@tencentcloud/chat';
|
|
3
3
|
import { useTUIKitContext } from '../../../context';
|
|
4
4
|
|
|
5
5
|
export const useConversationUpdate = (
|
|
@@ -11,7 +11,7 @@ export const useConversationUpdate = (
|
|
|
11
11
|
forceUpdate?: () => void,
|
|
12
12
|
filterConversation?:(conversationList: Array<Conversation>) => Array<Conversation>,
|
|
13
13
|
) => {
|
|
14
|
-
const {
|
|
14
|
+
const { chat } = useTUIKitContext('useConversationUpdate');
|
|
15
15
|
useEffect(() => {
|
|
16
16
|
const onConversationListUpdated = (event:any) => {
|
|
17
17
|
if (setConversationList) {
|
|
@@ -19,7 +19,7 @@ export const useConversationUpdate = (
|
|
|
19
19
|
setConversationList(filterConversation(event.data));
|
|
20
20
|
} else {
|
|
21
21
|
setConversationList(event.data.filter(
|
|
22
|
-
(item) => item.type !==
|
|
22
|
+
(item) => item.type !== TencentCloudChat.TYPES.CONV_SYSTEM,
|
|
23
23
|
));
|
|
24
24
|
}
|
|
25
25
|
}
|
|
@@ -30,9 +30,9 @@ export const useConversationUpdate = (
|
|
|
30
30
|
customHandler(setConversationList, event);
|
|
31
31
|
}
|
|
32
32
|
};
|
|
33
|
-
|
|
33
|
+
chat?.on(TencentCloudChat.EVENT.CONVERSATION_LIST_UPDATED, onConversationListUpdated);
|
|
34
34
|
return () => {
|
|
35
|
-
|
|
35
|
+
chat?.off(TencentCloudChat.EVENT.CONVERSATION_LIST_UPDATED, onConversationListUpdated);
|
|
36
36
|
};
|
|
37
|
-
}, [
|
|
37
|
+
}, [chat, customHandler]);
|
|
38
38
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { PropsWithChildren } from 'react';
|
|
2
|
-
import { ChatSDK, Conversation } from '
|
|
2
|
+
import { ChatSDK, Conversation } from '@tencentcloud/chat';
|
|
3
3
|
import { useTUIKit } from './hooks/useTUIKit';
|
|
4
4
|
import { useCreateTUIKitContext } from './hooks/useCreateTUIKitContext';
|
|
5
5
|
import { TUIKitProvider } from '../../context/TUIKitContext';
|
|
@@ -9,7 +9,7 @@ import { TUIChat } from '../TUIChat';
|
|
|
9
9
|
import { TUIManage } from '../TUIManage';
|
|
10
10
|
|
|
11
11
|
export interface ChatProps {
|
|
12
|
-
|
|
12
|
+
chat?: ChatSDK | null,
|
|
13
13
|
customClasses?: unknown,
|
|
14
14
|
activeConversation?: Conversation,
|
|
15
15
|
}
|
|
@@ -19,7 +19,7 @@ export function TUIKit<
|
|
|
19
19
|
props:PropsWithChildren<T>,
|
|
20
20
|
):React.ReactElement {
|
|
21
21
|
const {
|
|
22
|
-
children,
|
|
22
|
+
children, chat, customClasses, activeConversation,
|
|
23
23
|
} = props;
|
|
24
24
|
(window as any).tencent_cloud_im_csig_react_uikit_23F_xa = true;
|
|
25
25
|
const {
|
|
@@ -30,9 +30,9 @@ export function TUIKit<
|
|
|
30
30
|
setTUIManageShow,
|
|
31
31
|
TUIProfileShow,
|
|
32
32
|
setTUIProfileShow,
|
|
33
|
-
} = useTUIKit({
|
|
33
|
+
} = useTUIKit({ chat, activeConversation });
|
|
34
34
|
const chatContextValue = useCreateTUIKitContext({
|
|
35
|
-
|
|
35
|
+
chat,
|
|
36
36
|
conversation,
|
|
37
37
|
setActiveConversation,
|
|
38
38
|
customClasses,
|
|
@@ -3,7 +3,7 @@ import { TUIKitContextValue } from '../../../context/TUIKitContext';
|
|
|
3
3
|
|
|
4
4
|
export const useCreateTUIKitContext = (value:TUIKitContextValue) => {
|
|
5
5
|
const {
|
|
6
|
-
|
|
6
|
+
chat,
|
|
7
7
|
conversation,
|
|
8
8
|
customClasses,
|
|
9
9
|
setActiveConversation,
|
|
@@ -16,7 +16,7 @@ export const useCreateTUIKitContext = (value:TUIKitContextValue) => {
|
|
|
16
16
|
|
|
17
17
|
const TUIKitContext = useMemo(
|
|
18
18
|
() => ({
|
|
19
|
-
|
|
19
|
+
chat,
|
|
20
20
|
conversation,
|
|
21
21
|
customClasses,
|
|
22
22
|
setActiveConversation,
|
|
@@ -29,7 +29,7 @@ export const useCreateTUIKitContext = (value:TUIKitContextValue) => {
|
|
|
29
29
|
[
|
|
30
30
|
conversation,
|
|
31
31
|
customClasses,
|
|
32
|
-
|
|
32
|
+
chat,
|
|
33
33
|
TUIManageShow,
|
|
34
34
|
TUIProfileShow,
|
|
35
35
|
setTUIProfileShow,
|
|
@@ -1,38 +1,38 @@
|
|
|
1
1
|
import React, { useState, useCallback, useEffect } from 'react';
|
|
2
|
-
import
|
|
2
|
+
import TencentCloudChat, {
|
|
3
3
|
ChatSDK,
|
|
4
4
|
Conversation,
|
|
5
5
|
Group,
|
|
6
6
|
Profile,
|
|
7
|
-
} from '
|
|
7
|
+
} from '@tencentcloud/chat';
|
|
8
8
|
|
|
9
9
|
export interface UseChatParams{
|
|
10
|
-
|
|
10
|
+
chat: ChatSDK,
|
|
11
11
|
activeConversation?: Conversation,
|
|
12
12
|
}
|
|
13
|
-
export const useTUIKit = ({
|
|
13
|
+
export const useTUIKit = ({ chat, activeConversation: paramsActiveConversation }:UseChatParams) => {
|
|
14
14
|
const [conversation, setConversation] = useState<Conversation>(paramsActiveConversation);
|
|
15
15
|
const [myProfile, setMyProfile] = useState<Profile>();
|
|
16
16
|
const [TUIManageShow, setTUIManageShow] = useState<boolean>(false);
|
|
17
17
|
const [TUIProfileShow, setTUIProfileShow] = useState<boolean>(false);
|
|
18
18
|
useEffect(() => {
|
|
19
19
|
const getMyProfile = async () => {
|
|
20
|
-
const res = await
|
|
20
|
+
const res = await chat?.getMyProfile();
|
|
21
21
|
setMyProfile(res?.data);
|
|
22
22
|
};
|
|
23
23
|
getMyProfile();
|
|
24
|
-
}, [
|
|
24
|
+
}, [chat]);
|
|
25
25
|
const setActiveConversation = useCallback(
|
|
26
26
|
(activeConversation?: Conversation) => {
|
|
27
27
|
if (activeConversation) {
|
|
28
|
-
|
|
28
|
+
chat?.setMessageRead({ conversationID: activeConversation.conversationID });
|
|
29
29
|
}
|
|
30
30
|
if (conversation && (activeConversation.conversationID !== conversation.conversationID)) {
|
|
31
31
|
setTUIManageShow(false);
|
|
32
32
|
}
|
|
33
33
|
setConversation(activeConversation);
|
|
34
34
|
},
|
|
35
|
-
[
|
|
35
|
+
[chat],
|
|
36
36
|
);
|
|
37
37
|
|
|
38
38
|
useEffect(() => {
|
|
@@ -16,14 +16,14 @@ export function TUIManage() {
|
|
|
16
16
|
const {
|
|
17
17
|
conversation: activeConversation,
|
|
18
18
|
setActiveConversation,
|
|
19
|
-
|
|
19
|
+
chat,
|
|
20
20
|
TUIManageShow,
|
|
21
21
|
setTUIManageShow,
|
|
22
22
|
} = useTUIKitContext('TUIManage');
|
|
23
23
|
useConversationUpdate(null, () => {
|
|
24
24
|
setForceUpdateCount((count) => count + 1);
|
|
25
25
|
});
|
|
26
|
-
const { pinConversation, deleteConversation } = useConversation(
|
|
26
|
+
const { pinConversation, deleteConversation } = useConversation(chat);
|
|
27
27
|
const pinChatChange = (e) => {
|
|
28
28
|
setIsPinned(e.target.checked);
|
|
29
29
|
pinConversation({
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, {
|
|
2
2
|
PropsWithChildren,
|
|
3
3
|
} from 'react';
|
|
4
|
-
import
|
|
4
|
+
import TencentCloudChat, { Message } from '@tencentcloud/chat';
|
|
5
5
|
import { MESSAGE_FLOW } from '../../constants';
|
|
6
6
|
import { messageShowType } from '../../context';
|
|
7
7
|
import { Avatar } from '../Avatar';
|
|
@@ -3,7 +3,7 @@ import React, {
|
|
|
3
3
|
ReactNode,
|
|
4
4
|
useState,
|
|
5
5
|
} from 'react';
|
|
6
|
-
import
|
|
6
|
+
import TencentCloudChat, { Message } from '@tencentcloud/chat';
|
|
7
7
|
import { MESSAGE_STATUS } from '../../constants';
|
|
8
8
|
import { useTUIChatActionContext } from '../../context';
|
|
9
9
|
import { Icon, IconTypes } from '../Icon';
|
|
@@ -39,9 +39,9 @@ function MessageBubbleWithContext <T extends MessageBubbleProps>(
|
|
|
39
39
|
const { setHighlightedMessageId } = useTUIChatActionContext('MessageBubbleWithContext');
|
|
40
40
|
|
|
41
41
|
const handleLoading = () => !!((
|
|
42
|
-
message?.type ===
|
|
43
|
-
|| message?.type ===
|
|
44
|
-
|| message?.type ===
|
|
42
|
+
message?.type === TencentCloudChat.TYPES.MSG_IMAGE
|
|
43
|
+
|| message?.type === TencentCloudChat.TYPES.MSG_VIDEO
|
|
44
|
+
|| message?.type === TencentCloudChat.TYPES.MSG_FILE
|
|
45
45
|
) && message?.status === MESSAGE_STATUS.UNSEND);
|
|
46
46
|
|
|
47
47
|
const handleMouseEnter = () => {
|