@tencentcloud/chat-uikit-react 2.2.6 → 2.2.7
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/dist/cjs/assets/fonts/iconfont.ttf +0 -0
- package/dist/cjs/assets/fonts/iconfont.woff +0 -0
- package/dist/cjs/assets/fonts/iconfont.woff2 +0 -0
- package/dist/cjs/components/ConversationCreate/hooks/useConversationCreate.js +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.js +1 -1
- package/dist/cjs/components/Icon/config.js +1 -1
- package/dist/cjs/components/Icon/images/video-call.svg.js +1 -0
- package/dist/cjs/components/Icon/images/voice-call.svg.js +1 -0
- package/dist/cjs/components/Icon/type.d.ts +3 -1
- package/dist/cjs/components/Icon/type.js +1 -1
- package/dist/cjs/components/TUIChat/TUIChat.d.ts +3 -2
- package/dist/cjs/components/TUIChat/TUIChat.js +1 -1
- package/dist/cjs/components/TUIChat/TUIChatState.js +1 -1
- package/dist/cjs/components/TUIChat/index.js +1 -0
- package/dist/cjs/components/TUIChat/server.js +1 -0
- package/dist/cjs/components/TUIChat/utils.js +1 -0
- package/dist/cjs/components/TUIChatHeader/TUIChatHeader.d.ts +1 -0
- package/dist/cjs/components/TUIChatHeader/TUIChatHeader.js +1 -1
- package/dist/cjs/components/TUIChatHeader/TUIChatHeaderDefault.d.ts +2 -1
- package/dist/cjs/components/TUIChatHeader/TUIChatHeaderDefault.js +1 -1
- package/dist/cjs/components/TUIContact/TUIContactList/TUIContactList.js +1 -1
- package/dist/cjs/components/TUIContact/hooks/useTUIContact.js +1 -1
- package/dist/cjs/components/TUIMessage/MessageAvatar.js +1 -1
- package/dist/cjs/components/TUIMessage/MessageCustom.js +1 -1
- package/dist/cjs/components/TUIMessage/MessageStatus.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/InputPluginsDefalut.js +1 -1
- package/dist/cjs/components/TUIMessageInput/hooks/useHandleForwardMessage.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/hooks/useMessageListElement.js +1 -1
- package/dist/cjs/components/TUIProfile/TUIProfileDefault.js +1 -1
- package/dist/cjs/components/{untils.js → utils.js} +1 -1
- package/dist/cjs/context/LanguageContext.js +1 -1
- package/dist/cjs/context/TUIChatActionContext.d.ts +2 -1
- package/dist/cjs/context/TUIConversationContext.js +1 -1
- package/dist/cjs/context/ThemeContext.js +1 -1
- package/dist/cjs/context/UIKitContext.d.ts +2 -2
- package/dist/cjs/context/UIKitContext.js +1 -1
- package/dist/cjs/index.css +1 -1
- package/dist/cjs/index.d.css +589 -259
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/locales/en-US/index.js +1 -1
- package/dist/cjs/locales/index.js +1 -1
- package/dist/cjs/locales/ja-JP/index.js +1 -1
- package/dist/cjs/locales/ko-KR/index.js +1 -1
- package/dist/cjs/locales/zh-CN/index.js +1 -1
- package/dist/cjs/locales/zh-TW/TUIChat.js +1 -0
- package/dist/cjs/locales/zh-TW/TUIContact.js +1 -0
- package/dist/cjs/locales/zh-TW/TUIConversation.js +1 -0
- package/dist/cjs/locales/zh-TW/TUIProfile.js +1 -0
- package/dist/cjs/locales/zh-TW/index.js +1 -0
- package/dist/esm/assets/fonts/iconfont.ttf +0 -0
- package/dist/esm/assets/fonts/iconfont.woff +0 -0
- package/dist/esm/assets/fonts/iconfont.woff2 +0 -0
- package/dist/esm/components/ConversationCreate/hooks/useConversationCreate.js +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.js +1 -1
- package/dist/esm/components/Icon/config.js +1 -1
- package/dist/esm/components/Icon/images/video-call.svg.js +1 -0
- package/dist/esm/components/Icon/images/voice-call.svg.js +1 -0
- package/dist/esm/components/Icon/type.d.ts +3 -1
- package/dist/esm/components/Icon/type.js +1 -1
- package/dist/esm/components/TUIChat/TUIChat.d.ts +3 -2
- package/dist/esm/components/TUIChat/TUIChat.js +1 -1
- package/dist/esm/components/TUIChat/TUIChatState.js +1 -1
- package/dist/esm/components/TUIChat/index.js +1 -0
- package/dist/esm/components/TUIChat/server.js +1 -0
- package/dist/esm/components/TUIChat/utils.js +1 -0
- package/dist/esm/components/TUIChatHeader/TUIChatHeader.d.ts +1 -0
- package/dist/esm/components/TUIChatHeader/TUIChatHeader.js +1 -1
- package/dist/esm/components/TUIChatHeader/TUIChatHeaderDefault.d.ts +2 -1
- package/dist/esm/components/TUIChatHeader/TUIChatHeaderDefault.js +1 -1
- package/dist/esm/components/TUIContact/TUIContactList/TUIContactList.js +1 -1
- package/dist/esm/components/TUIContact/hooks/useTUIContact.js +1 -1
- package/dist/esm/components/TUIMessage/MessageAvatar.js +1 -1
- package/dist/esm/components/TUIMessage/MessageCustom.js +1 -1
- package/dist/esm/components/TUIMessage/MessageStatus.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/InputPluginsDefalut.js +1 -1
- package/dist/esm/components/TUIMessageInput/hooks/useHandleForwardMessage.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/hooks/useMessageListElement.js +1 -1
- package/dist/esm/components/TUIProfile/TUIProfileDefault.js +1 -1
- package/dist/esm/components/utils.js +1 -0
- package/dist/esm/context/LanguageContext.js +1 -1
- package/dist/esm/context/TUIChatActionContext.d.ts +2 -1
- package/dist/esm/context/TUIConversationContext.js +1 -1
- package/dist/esm/context/ThemeContext.js +1 -1
- package/dist/esm/context/UIKitContext.d.ts +2 -2
- package/dist/esm/context/UIKitContext.js +1 -1
- package/dist/esm/index.css +1 -1
- package/dist/esm/index.d.css +589 -259
- package/dist/esm/index.js +1 -1
- package/dist/esm/locales/en-US/index.js +1 -1
- package/dist/esm/locales/index.js +1 -1
- package/dist/esm/locales/ja-JP/index.js +1 -1
- package/dist/esm/locales/ko-KR/index.js +1 -1
- package/dist/esm/locales/zh-CN/index.js +1 -1
- package/dist/esm/locales/zh-TW/TUIChat.js +1 -0
- package/dist/esm/locales/zh-TW/TUIContact.js +1 -0
- package/dist/esm/locales/zh-TW/TUIConversation.js +1 -0
- package/dist/esm/locales/zh-TW/TUIProfile.js +1 -0
- package/dist/esm/locales/zh-TW/index.js +1 -0
- package/package.json +2 -1
- package/rollup.config.js +1 -1
- package/src/assets/fonts/iconfont.ttf +0 -0
- package/src/assets/fonts/iconfont.woff +0 -0
- package/src/assets/fonts/iconfont.woff2 +0 -0
- package/src/components/Avatar/styles/index.scss +11 -4
- package/src/components/Checkbox/styles/color.scss +17 -6
- package/src/components/ConversationCreate/hooks/useConversationCreate.tsx +5 -5
- package/src/components/ConversationCreate/styles/ConversationCreatGroupDetail.scss +7 -16
- package/src/components/ConversationCreate/styles/conversationCreateSelectView.scss +13 -8
- package/src/components/ConversationCreate/styles/conversationGroupTypeInfo.scss +20 -21
- package/src/components/ConversationCreate/styles/index.scss +30 -17
- package/src/components/ConversationPreview/ConversationPreviewContent.tsx +1 -0
- package/src/components/ConversationPreview/styles/index.scss +20 -20
- package/src/components/ConversationPreview/utils.tsx +3 -2
- package/src/components/DivWithEdit/styles/index.scss +30 -10
- package/src/components/Icon/config.ts +14 -4
- package/src/components/Icon/images/video-call.svg +3 -0
- package/src/components/Icon/images/voice-call.svg +3 -0
- package/src/components/Icon/type.ts +2 -0
- package/src/components/Input/styles/index.scss +22 -6
- package/src/components/Plugins/styles/color.scss +3 -11
- package/src/components/Profile/styles/index.scss +12 -3
- package/src/components/TUIChat/TUIChat.tsx +36 -32
- package/src/components/TUIChat/TUIChatState.tsx +41 -41
- package/src/components/TUIChat/index.ts +3 -0
- package/src/components/TUIChat/server.ts +44 -0
- package/src/components/TUIChat/styles/layout.scss +7 -2
- package/src/components/TUIChat/utils.ts +72 -0
- package/src/components/TUIChatHeader/TUIChatHeader.tsx +10 -7
- package/src/components/TUIChatHeader/TUIChatHeaderDefault.tsx +72 -29
- package/src/components/TUIChatHeader/styles/layout.scss +16 -9
- package/src/components/TUIContact/TUIContactInfo/index.scss +44 -21
- package/src/components/TUIContact/TUIContactList/TUIContactList.tsx +75 -71
- package/src/components/TUIContact/TUIContactList/index.scss +40 -20
- package/src/components/TUIContact/hooks/useTUIContact.tsx +3 -3
- package/src/components/TUIContact/index.scss +30 -11
- package/src/components/TUIContactSearch/index.scss +12 -3
- package/src/components/TUIConversationList/index.scss +3 -4
- package/src/components/TUIManage/styles/index.scss +20 -14
- package/src/components/TUIMessage/MessageAvatar.tsx +7 -7
- package/src/components/TUIMessage/MessageBubble.tsx +22 -21
- package/src/components/TUIMessage/MessageCustom.tsx +26 -5
- package/src/components/TUIMessage/MessageStatus.tsx +5 -5
- package/src/components/TUIMessage/hooks/useMessageHandler.ts +6 -6
- package/src/components/TUIMessage/hooks/useMessageReply.ts +6 -5
- package/src/components/TUIMessage/styles/color.scss +6 -5
- package/src/components/TUIMessage/styles/layout.scss +111 -42
- package/src/components/TUIMessage/utils/index.ts +23 -12
- package/src/components/TUIMessageInput/InputPluginsDefalut.tsx +12 -12
- package/src/components/TUIMessageInput/hooks/useHandleForwardMessage.tsx +5 -4
- package/src/components/TUIMessageInput/hooks/useMessageInputText.tsx +12 -12
- package/src/components/TUIMessageInput/hooks/useUploadPicker.tsx +4 -4
- package/src/components/TUIMessageInput/styles/color.scss +15 -11
- package/src/components/TUIMessageInput/styles/layout.scss +33 -17
- package/src/components/TUIMessageList/hooks/useMessageListElement.tsx +13 -9
- package/src/components/TUIMessageList/styles/layout.scss +16 -9
- package/src/components/TUIProfile/TUIProfileDefault.tsx +12 -11
- package/src/components/TUIProfile/styles/color.scss +6 -5
- package/src/components/TUIProfile/styles/layout.scss +16 -14
- package/src/components/{untils.ts → utils.ts} +5 -4
- package/src/context/LanguageContext.tsx +5 -4
- package/src/context/TUIChatActionContext.tsx +14 -13
- package/src/context/ThemeContext.tsx +12 -5
- package/src/context/UIKitContext.tsx +11 -2
- package/src/locales/en-US/index.ts +0 -3
- package/src/locales/index.ts +6 -2
- package/src/locales/ja-JP/index.ts +0 -2
- package/src/locales/ko-KR/index.ts +0 -2
- package/src/locales/zh-CN/index.ts +0 -2
- package/src/locales/zh-TW/TUIChat.ts +27 -0
- package/src/locales/zh-TW/TUIContact.ts +29 -0
- package/src/locales/zh-TW/TUIConversation.ts +32 -0
- package/src/locales/zh-TW/TUIProfile.ts +15 -0
- package/src/locales/zh-TW/index.ts +11 -0
- package/src/styles/colors/_color-dark.scss +31 -21
- package/src/styles/colors/_color-light.scss +31 -21
- package/src/styles/colors/_color-theme.scss +32 -21
- package/src/styles/normalize.scss +6 -0
- package/dist/cjs/components/Icon/images/down-arrow.png.js +0 -1
- package/dist/cjs/components/Icon/images/right-arrow.svg.js +0 -1
- package/dist/cjs/components/TUIChat/unitls.js +0 -1
- package/dist/cjs/locales/en-US/TUIGlobal.js +0 -1
- package/dist/cjs/locales/ja-JP/TUIGlobal.js +0 -1
- package/dist/cjs/locales/ko-KR/TUIGlobal.js +0 -1
- package/dist/cjs/locales/zh-CN/TUIGlobal.js +0 -1
- package/dist/esm/components/Icon/images/down-arrow.png.js +0 -1
- package/dist/esm/components/Icon/images/right-arrow.svg.js +0 -1
- package/dist/esm/components/TUIChat/unitls.js +0 -1
- package/dist/esm/components/untils.js +0 -1
- package/dist/esm/locales/en-US/TUIGlobal.js +0 -1
- package/dist/esm/locales/ja-JP/TUIGlobal.js +0 -1
- package/dist/esm/locales/ko-KR/TUIGlobal.js +0 -1
- package/dist/esm/locales/zh-CN/TUIGlobal.js +0 -1
- package/scripts/publish-github.js +0 -60
- package/scripts/publish-intl-demo.js +0 -14
- package/scripts/publish-intl-experience-demo.js +0 -14
- package/src/components/TUIChat/unitls.ts +0 -39
- package/src/locales/en-US/TUIGlobal.ts +0 -6
- package/src/locales/ja-JP/TUIGlobal.ts +0 -6
- package/src/locales/ko-KR/TUIGlobal.ts +0 -6
- package/src/locales/zh-CN/TUIGlobal.ts +0 -6
|
@@ -7,61 +7,61 @@ import { OperateMessageParams } from './hooks/useHandleMessage';
|
|
|
7
7
|
import {
|
|
8
8
|
handleEditMessage,
|
|
9
9
|
handleUploadPendingMessage,
|
|
10
|
-
} from './
|
|
10
|
+
} from './utils';
|
|
11
11
|
|
|
12
12
|
export type ChatStateReducerAction =
|
|
13
13
|
| {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
type: CONSTANT_DISPATCH_TYPE.SET_CONVERSATION_PRPFILE;
|
|
15
|
+
value?: Conversation;
|
|
16
|
+
}
|
|
17
17
|
| {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
type: CONSTANT_DISPATCH_TYPE.SET_MESSAGELIST;
|
|
19
|
+
value?: IMessageModel[];
|
|
20
|
+
}
|
|
21
21
|
| {
|
|
22
|
-
type: CONSTANT_DISPATCH_TYPE.SET_EDIT_MESSAGE
|
|
23
|
-
value?: Message
|
|
24
|
-
index?: number
|
|
22
|
+
type: CONSTANT_DISPATCH_TYPE.SET_EDIT_MESSAGE;
|
|
23
|
+
value?: Message;
|
|
24
|
+
index?: number;
|
|
25
25
|
}
|
|
26
26
|
| {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
type: CONSTANT_DISPATCH_TYPE.SET_IS_COMPLETE;
|
|
28
|
+
value?: boolean;
|
|
29
|
+
}
|
|
30
30
|
| {
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
type: CONSTANT_DISPATCH_TYPE.RESET;
|
|
32
|
+
}
|
|
33
33
|
| {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
34
|
+
type: CONSTANT_DISPATCH_TYPE.SET_HIGH_LIGHTED_MESSAGE_ID;
|
|
35
|
+
value?: string;
|
|
36
|
+
}
|
|
37
37
|
| {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
38
|
+
type: CONSTANT_DISPATCH_TYPE.OPERATE_MESSAGE;
|
|
39
|
+
value?: OperateMessageParams;
|
|
40
|
+
}
|
|
41
41
|
| {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
42
|
+
type: CONSTANT_DISPATCH_TYPE.SET_NO_MORE;
|
|
43
|
+
value?: boolean;
|
|
44
|
+
}
|
|
45
45
|
| {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
46
|
+
type: CONSTANT_DISPATCH_TYPE.SET_AUDIO_SOURCE;
|
|
47
|
+
value?: HTMLAudioElement | null;
|
|
48
|
+
}
|
|
49
49
|
| {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
50
|
+
type: CONSTANT_DISPATCH_TYPE.SET_VIDEO_SOURCE;
|
|
51
|
+
value?: HTMLVideoElement | null;
|
|
52
|
+
}
|
|
53
53
|
| {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
54
|
+
type: CONSTANT_DISPATCH_TYPE.UPDATE_UPLOAD_PENDING_MESSAGE_LIST;
|
|
55
|
+
value?: Message;
|
|
56
|
+
}
|
|
57
57
|
| {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
58
|
+
type: CONSTANT_DISPATCH_TYPE.SET_FIRST_SEND_MESSAGE;
|
|
59
|
+
value?: Message;
|
|
60
|
+
}
|
|
61
61
|
| {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
62
|
+
type: CONSTANT_DISPATCH_TYPE.SET_ACTIVE_MESSAGE_ID;
|
|
63
|
+
value?: string;
|
|
64
|
+
};
|
|
65
65
|
export type ChatStateReducer = Reducer<TUIChatStateContextValue, ChatStateReducerAction>;
|
|
66
66
|
|
|
67
67
|
export const chatReducer = (
|
|
@@ -78,7 +78,7 @@ export const chatReducer = (
|
|
|
78
78
|
messageList: action.value,
|
|
79
79
|
};
|
|
80
80
|
case CONSTANT_DISPATCH_TYPE.SET_EDIT_MESSAGE:
|
|
81
|
-
return state.messageList &&
|
|
81
|
+
return state.messageList && action.value && {
|
|
82
82
|
...state,
|
|
83
83
|
messageList: [...handleEditMessage(state.messageList, action.value)],
|
|
84
84
|
};
|
|
@@ -110,7 +110,7 @@ export const chatReducer = (
|
|
|
110
110
|
}
|
|
111
111
|
};
|
|
112
112
|
|
|
113
|
-
export const initialState:TUIChatStateContextValue = {
|
|
113
|
+
export const initialState: TUIChatStateContextValue = {
|
|
114
114
|
conversation: {} as Conversation,
|
|
115
115
|
messageList: [],
|
|
116
116
|
nextReqMessageID: '',
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import TUICore, { TUIConstants } from '@tencentcloud/tui-core';
|
|
2
|
+
import {
|
|
3
|
+
IMessageModel,
|
|
4
|
+
TUIStore,
|
|
5
|
+
StoreName,
|
|
6
|
+
TUIChatService,
|
|
7
|
+
} from '@tencentcloud/chat-uikit-engine';
|
|
8
|
+
|
|
9
|
+
export default class TUIChatServer {
|
|
10
|
+
public currentConversationID = '';
|
|
11
|
+
public currentMessageList: IMessageModel[] = [];
|
|
12
|
+
|
|
13
|
+
constructor() {
|
|
14
|
+
// register service
|
|
15
|
+
TUICore.registerService(TUIConstants.TUIChat.SERVICE.NAME, this);
|
|
16
|
+
// watch current conversationID
|
|
17
|
+
TUIStore.watch(StoreName.CONV, {
|
|
18
|
+
currentConversationID: (id: string) => {
|
|
19
|
+
this.currentConversationID = id;
|
|
20
|
+
},
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
public onCall(method: string, params: Record<string, any>, callback: void): any {
|
|
25
|
+
let message;
|
|
26
|
+
switch (method) {
|
|
27
|
+
case TUIConstants.TUIChat.SERVICE.METHOD.UPDATE_MESSAGE_LIST:
|
|
28
|
+
message = params.message;
|
|
29
|
+
// Two screen-up situations
|
|
30
|
+
// 1. If the call message conversationID is currentConversation,
|
|
31
|
+
// You need to use UPDATE_MESSAGE_LIST to update the messageList of TUIStore in the engine to display it on the screen
|
|
32
|
+
// (because you cannot get the messages you sent at this time)
|
|
33
|
+
// 2. If the call message conversationID is not currentConversation,
|
|
34
|
+
// The next time you switch to the conversation where the call message is located, getMessageList can get all the call messages you sent
|
|
35
|
+
// No need to process here
|
|
36
|
+
if (message?.conversationID === this.currentConversationID) {
|
|
37
|
+
TUIChatService.updateMessageList([message], 'push');
|
|
38
|
+
}
|
|
39
|
+
break;
|
|
40
|
+
default:
|
|
41
|
+
break;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
@use "../../../styles/colors/color-theme" as *;
|
|
2
|
+
|
|
1
3
|
.chat {
|
|
2
4
|
flex: 1;
|
|
3
5
|
width: 100%;
|
|
@@ -6,5 +8,8 @@
|
|
|
6
8
|
display: flex;
|
|
7
9
|
flex-direction: column;
|
|
8
10
|
position: relative;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
+
|
|
12
|
+
@include theme() {
|
|
13
|
+
background-color: get(bg-color-operate);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import TencentCloudChat, { Message, Conversation } from '@tencentcloud/chat';
|
|
2
|
+
import TUICore, { TUIConstants } from '@tencentcloud/tui-core';
|
|
3
|
+
import TUIChatEngine from '@tencentcloud/chat-uikit-engine';
|
|
4
|
+
import { useTUIChatActionContext } from '../../context';
|
|
5
|
+
import constant from '../../constants';
|
|
6
|
+
import { JSONStringToParse } from '../utils';
|
|
7
|
+
|
|
8
|
+
export const handleMessage = (messageList: Message[]): Message[] => {
|
|
9
|
+
let customPayloadData: any = null;
|
|
10
|
+
return messageList.filter((item) => {
|
|
11
|
+
if (item.type === TencentCloudChat.TYPES.MSG_CUSTOM) {
|
|
12
|
+
customPayloadData = JSONStringToParse(item?.payload?.data);
|
|
13
|
+
}
|
|
14
|
+
if (customPayloadData && customPayloadData?.businessID === constant.TYPE_TYPING) {
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
return true;
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export const handleEditMessage = (
|
|
22
|
+
messageList: Message[],
|
|
23
|
+
message: Message,
|
|
24
|
+
) => {
|
|
25
|
+
const list = [...messageList];
|
|
26
|
+
const index = list.findIndex(item => item?.ID === message?.ID);
|
|
27
|
+
list[index] = message;
|
|
28
|
+
return list;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export const handleUploadPendingMessage = (
|
|
32
|
+
messageList: Message[],
|
|
33
|
+
message: Message,
|
|
34
|
+
) => {
|
|
35
|
+
const list = [...messageList];
|
|
36
|
+
if (!list.some((item: Message) => item.ID === message?.ID)) {
|
|
37
|
+
list.push(message);
|
|
38
|
+
}
|
|
39
|
+
const index = list.findIndex(item => item?.ID === message?.ID);
|
|
40
|
+
list[index] = message;
|
|
41
|
+
return list;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
interface IStartCallParams {
|
|
45
|
+
callType: any;
|
|
46
|
+
callMediaType: number;
|
|
47
|
+
userIDList: string[];
|
|
48
|
+
callButtonClicked?: (callMediaType?: number, callType?: any) => void;
|
|
49
|
+
}
|
|
50
|
+
export const startCall = (params: IStartCallParams) => {
|
|
51
|
+
const { callType, callMediaType, userIDList, callButtonClicked } = params;
|
|
52
|
+
if (callType === TUIChatEngine.TYPES.CONV_C2C) {
|
|
53
|
+
callButtonClicked && callButtonClicked(callMediaType, callType);
|
|
54
|
+
TUICore.callService({
|
|
55
|
+
serviceName: TUIConstants.TUICalling.SERVICE.NAME,
|
|
56
|
+
method: TUIConstants.TUICalling.SERVICE.METHOD.START_CALL,
|
|
57
|
+
params: {
|
|
58
|
+
userIDList,
|
|
59
|
+
type: callMediaType,
|
|
60
|
+
callParams: {
|
|
61
|
+
// doc: https://cloud.tencent.com/document/product/269/105713
|
|
62
|
+
offlinePushInfo: {
|
|
63
|
+
title: 'call',
|
|
64
|
+
description: 'you have a call',
|
|
65
|
+
androidSound: 'private_ring',
|
|
66
|
+
iOSSound: '01.caf',
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
};
|
|
@@ -8,29 +8,31 @@ import './styles/index.scss';
|
|
|
8
8
|
import { useComponentContext } from '../../context';
|
|
9
9
|
|
|
10
10
|
interface TUIChatHeaderProps {
|
|
11
|
-
title?: string
|
|
12
|
-
TUIChatHeader?: React.ComponentType<TUIChatHeaderDefaultProps
|
|
13
|
-
conversation?: Conversation
|
|
14
|
-
avatar?: React.ReactElement | string
|
|
15
|
-
headerOpateIcon?: React.ReactElement | string
|
|
11
|
+
title?: string;
|
|
12
|
+
TUIChatHeader?: React.ComponentType<TUIChatHeaderDefaultProps>;
|
|
13
|
+
conversation?: Conversation;
|
|
14
|
+
avatar?: React.ReactElement | string;
|
|
15
|
+
headerOpateIcon?: React.ReactElement | string;
|
|
16
|
+
enableCall?: boolean;
|
|
16
17
|
}
|
|
17
18
|
|
|
18
19
|
function UnMemoizedTUIChatHeader<T extends TUIChatHeaderProps>(
|
|
19
20
|
props: PropsWithChildren<T>,
|
|
20
|
-
):React.ReactElement {
|
|
21
|
+
): React.ReactElement {
|
|
21
22
|
const {
|
|
22
23
|
title,
|
|
23
24
|
conversation: propsConversation,
|
|
24
25
|
TUIChatHeader: propTUIChatHeader,
|
|
25
26
|
avatar,
|
|
26
27
|
headerOpateIcon,
|
|
28
|
+
enableCall,
|
|
27
29
|
} = props;
|
|
28
30
|
|
|
29
31
|
const { conversation: contextConversation } = useTUIChatStateContext('TUIChatHeader');
|
|
30
32
|
const { TUIChatHeader: ContextTUIChatHeader } = useComponentContext('TUIChatHeader');
|
|
31
33
|
|
|
32
34
|
const TUIChatHeaderUIComponent = propTUIChatHeader
|
|
33
|
-
|
|
35
|
+
|| ContextTUIChatHeader || TUIChatHeaderDefault;
|
|
34
36
|
const conversation = propsConversation || contextConversation;
|
|
35
37
|
|
|
36
38
|
return (
|
|
@@ -39,6 +41,7 @@ function UnMemoizedTUIChatHeader<T extends TUIChatHeaderProps>(
|
|
|
39
41
|
conversation={conversation}
|
|
40
42
|
avatar={avatar}
|
|
41
43
|
opateIcon={headerOpateIcon}
|
|
44
|
+
enableCall={enableCall}
|
|
42
45
|
/>
|
|
43
46
|
);
|
|
44
47
|
}
|
|
@@ -1,29 +1,32 @@
|
|
|
1
1
|
import React, { PropsWithChildren, useEffect, useState } from 'react';
|
|
2
|
+
import TUICore, { TUIConstants } from '@tencentcloud/tui-core';
|
|
2
3
|
import TencentCloudChat, { Conversation, Group, Profile } from '@tencentcloud/chat';
|
|
3
4
|
import { TUIConversationService } from '@tencentcloud/chat-uikit-engine';
|
|
4
5
|
import { Avatar } from '../Avatar';
|
|
5
|
-
import { handleDisplayAvatar } from '../
|
|
6
|
+
import { handleDisplayAvatar } from '../utils';
|
|
6
7
|
import { isH5 } from '../../utils/env';
|
|
7
8
|
import './styles/index.scss';
|
|
8
9
|
import { Icon, IconTypes } from '../Icon';
|
|
9
|
-
import { useUIManager } from '../../context';
|
|
10
|
+
import { useUIManager, useTUIChatActionContext } from '../../context';
|
|
11
|
+
import { startCall } from '../TUIChat/utils';
|
|
10
12
|
|
|
11
13
|
export interface TUIChatHeaderDefaultProps {
|
|
12
|
-
title?: string
|
|
13
|
-
avatar?: React.ReactElement | string
|
|
14
|
-
isOnline?: boolean
|
|
15
|
-
conversation?: Conversation
|
|
16
|
-
pluginComponentList?:
|
|
14
|
+
title?: string;
|
|
15
|
+
avatar?: React.ReactElement | string;
|
|
16
|
+
isOnline?: boolean;
|
|
17
|
+
conversation?: Conversation;
|
|
18
|
+
pluginComponentList?: React.ComponentType[];
|
|
19
|
+
enableCall?: boolean;
|
|
17
20
|
}
|
|
18
21
|
|
|
19
22
|
export interface TUIChatHeaderBasicProps extends TUIChatHeaderDefaultProps {
|
|
20
|
-
isLive?: boolean
|
|
21
|
-
opateIcon?: React.ReactElement | string
|
|
23
|
+
isLive?: boolean;
|
|
24
|
+
opateIcon?: React.ReactElement | string;
|
|
22
25
|
}
|
|
23
26
|
|
|
24
|
-
function TUIChatHeaderDefaultWithContext
|
|
27
|
+
function TUIChatHeaderDefaultWithContext<T extends TUIChatHeaderBasicProps>(
|
|
25
28
|
props: PropsWithChildren<T>,
|
|
26
|
-
):React.ReactElement {
|
|
29
|
+
): React.ReactElement {
|
|
27
30
|
const {
|
|
28
31
|
title: propTitle = '',
|
|
29
32
|
avatar: propAvatar,
|
|
@@ -31,11 +34,13 @@ function TUIChatHeaderDefaultWithContext <T extends TUIChatHeaderBasicProps>(
|
|
|
31
34
|
conversation,
|
|
32
35
|
isLive,
|
|
33
36
|
opateIcon,
|
|
37
|
+
enableCall: propCallEnabled = false,
|
|
34
38
|
} = props;
|
|
39
|
+
const { callButtonClicked } = useTUIChatActionContext('TUIChat');
|
|
35
40
|
const { setActiveContact } = useUIManager('TUIContact');
|
|
36
41
|
const [title, setTitle] = useState(propTitle);
|
|
37
42
|
const [avatar, setAvatar] = useState<React.ReactElement | string>('');
|
|
38
|
-
|
|
43
|
+
const [isShowCallIcon, setIsShowCallIcon] = useState<boolean>(false);
|
|
39
44
|
useEffect(() => {
|
|
40
45
|
setTitle(propTitle);
|
|
41
46
|
if (propAvatar) {
|
|
@@ -44,6 +49,8 @@ function TUIChatHeaderDefaultWithContext <T extends TUIChatHeaderBasicProps>(
|
|
|
44
49
|
switch (conversation?.type) {
|
|
45
50
|
case TencentCloudChat.TYPES.CONV_C2C:
|
|
46
51
|
handleC2C(conversation.userProfile, conversation?.remark);
|
|
52
|
+
const isCalling = TUICore.getService(TUIConstants.TUICalling.SERVICE.NAME) ? true : false;
|
|
53
|
+
setIsShowCallIcon(isCalling && propCallEnabled);
|
|
47
54
|
break;
|
|
48
55
|
case TencentCloudChat.TYPES.CONV_GROUP:
|
|
49
56
|
handleGroup(conversation.groupProfile);
|
|
@@ -57,26 +64,28 @@ function TUIChatHeaderDefaultWithContext <T extends TUIChatHeaderBasicProps>(
|
|
|
57
64
|
}
|
|
58
65
|
}, [conversation]);
|
|
59
66
|
|
|
60
|
-
|
|
67
|
+
function handleC2C(userProfile: Profile, remark?: string) {
|
|
61
68
|
if (!title) {
|
|
62
69
|
setTitle(remark || userProfile?.nick || userProfile?.userID);
|
|
63
70
|
}
|
|
64
71
|
if (!propAvatar) {
|
|
65
72
|
setAvatar(<Avatar size={32} image={handleDisplayAvatar(userProfile.avatar)} />);
|
|
66
73
|
}
|
|
67
|
-
}
|
|
74
|
+
}
|
|
68
75
|
|
|
69
|
-
|
|
76
|
+
function handleGroup(groupProfile: Group) {
|
|
70
77
|
if (!title) {
|
|
71
78
|
setTitle(groupProfile?.name || groupProfile?.groupID);
|
|
72
79
|
}
|
|
73
80
|
if (!propAvatar) {
|
|
74
|
-
setAvatar(
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
81
|
+
setAvatar(
|
|
82
|
+
<Avatar
|
|
83
|
+
size={32}
|
|
84
|
+
image={handleDisplayAvatar(groupProfile.avatar, TencentCloudChat.TYPES.CONV_GROUP)}
|
|
85
|
+
/>,
|
|
86
|
+
);
|
|
78
87
|
}
|
|
79
|
-
}
|
|
88
|
+
}
|
|
80
89
|
|
|
81
90
|
const back = () => {
|
|
82
91
|
TUIConversationService.switchConversation('');
|
|
@@ -86,29 +95,64 @@ function TUIChatHeaderDefaultWithContext <T extends TUIChatHeaderBasicProps>(
|
|
|
86
95
|
const openTUIManage = () => {
|
|
87
96
|
setTUIManageShow && setTUIManageShow(true);
|
|
88
97
|
};
|
|
89
|
-
|
|
98
|
+
const handleCall = (callMediaType: number) => {
|
|
99
|
+
const userID = conversation?.userProfile?.userID || '';
|
|
100
|
+
const callType = conversation?.type || TencentCloudChat.TYPES.CONV_C2C;
|
|
101
|
+
startCall({ callType, callMediaType, userIDList: [userID], callButtonClicked });
|
|
102
|
+
};
|
|
90
103
|
return (
|
|
91
104
|
<header
|
|
92
105
|
className={`tui-chat-header ${isLive ? 'tui-chat-live-header' : ''}`}
|
|
93
106
|
key={conversation?.conversationID}
|
|
94
107
|
>
|
|
95
|
-
{isH5 && (
|
|
108
|
+
{isH5 && (
|
|
109
|
+
<div style={{ paddingRight: '10px' }}>
|
|
110
|
+
<Icon onClick={back} type={IconTypes.BACK} width={9} height={16} />
|
|
111
|
+
</div>
|
|
112
|
+
)}
|
|
96
113
|
<div
|
|
97
|
-
className={`tui-chat-header-left ${
|
|
114
|
+
className={`tui-chat-header-left ${
|
|
115
|
+
conversation?.type === TencentCloudChat.TYPES.CONV_SYSTEM
|
|
116
|
+
? 'system'
|
|
117
|
+
: ''
|
|
118
|
+
}`}
|
|
98
119
|
>
|
|
99
120
|
{conversation?.type !== TencentCloudChat.TYPES.CONV_SYSTEM && avatar}
|
|
100
121
|
</div>
|
|
101
122
|
<div className="header-content">
|
|
102
123
|
<h3 className="title">{title}</h3>
|
|
103
124
|
</div>
|
|
125
|
+
{isShowCallIcon && (
|
|
126
|
+
<div className="call-btn-container">
|
|
127
|
+
<Icon
|
|
128
|
+
className="call-btn"
|
|
129
|
+
onClick={() =>
|
|
130
|
+
handleCall(2)}
|
|
131
|
+
type={IconTypes.VIDEOCALL}
|
|
132
|
+
width={24}
|
|
133
|
+
/>
|
|
134
|
+
<Icon
|
|
135
|
+
className="call-btn"
|
|
136
|
+
onClick={() =>
|
|
137
|
+
handleCall(1)}
|
|
138
|
+
type={IconTypes.VOICECALL}
|
|
139
|
+
width={20}
|
|
140
|
+
/>
|
|
141
|
+
</div>
|
|
142
|
+
)}
|
|
104
143
|
<div className="tui-chat-header-right">
|
|
105
144
|
<div className="header-handle">
|
|
106
|
-
{
|
|
107
|
-
|
|
108
|
-
|
|
145
|
+
{opateIcon || (
|
|
146
|
+
<Icon
|
|
147
|
+
className="header-handle-more"
|
|
148
|
+
onClick={openTUIManage}
|
|
149
|
+
type={IconTypes.ELLIPSE}
|
|
150
|
+
width={18}
|
|
151
|
+
height={5}
|
|
152
|
+
/>
|
|
153
|
+
)}
|
|
109
154
|
</div>
|
|
110
155
|
</div>
|
|
111
|
-
|
|
112
156
|
</header>
|
|
113
157
|
);
|
|
114
158
|
}
|
|
@@ -116,8 +160,7 @@ function TUIChatHeaderDefaultWithContext <T extends TUIChatHeaderBasicProps>(
|
|
|
116
160
|
const MemoizedTUIChatHeaderDefault = React.memo(TUIChatHeaderDefaultWithContext) as
|
|
117
161
|
typeof TUIChatHeaderDefaultWithContext;
|
|
118
162
|
|
|
119
|
-
export function TUIChatHeaderDefault(props: TUIChatHeaderBasicProps)
|
|
120
|
-
:React.ReactElement {
|
|
163
|
+
export function TUIChatHeaderDefault(props: TUIChatHeaderBasicProps): React.ReactElement {
|
|
121
164
|
const options = { ...props };
|
|
122
165
|
return <MemoizedTUIChatHeaderDefault {...options} />;
|
|
123
166
|
}
|
|
@@ -8,40 +8,47 @@
|
|
|
8
8
|
align-items: center;
|
|
9
9
|
|
|
10
10
|
@include theme() {
|
|
11
|
-
background-color: get(bg-
|
|
11
|
+
background-color: get(bg-color-operate);
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
&-left {
|
|
15
15
|
display: flex;
|
|
16
16
|
align-items: center;
|
|
17
17
|
}
|
|
18
|
+
|
|
18
19
|
.header-content {
|
|
19
20
|
flex: 1;
|
|
20
21
|
padding: 0 8px;
|
|
21
22
|
}
|
|
23
|
+
|
|
24
|
+
.call-btn-container {
|
|
25
|
+
display: flex;
|
|
26
|
+
margin-right: 10px;
|
|
27
|
+
|
|
28
|
+
.call-btn {
|
|
29
|
+
margin-right: 16px;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
22
33
|
&-right {
|
|
23
34
|
.header-handle {
|
|
24
35
|
&-more {
|
|
25
|
-
|
|
36
|
+
padding: 10px 3px;
|
|
26
37
|
}
|
|
27
38
|
}
|
|
28
39
|
}
|
|
40
|
+
|
|
29
41
|
.title {
|
|
30
|
-
font-family: PingFangSC-Medium;
|
|
31
42
|
font-style: normal;
|
|
32
43
|
font-weight: 700;
|
|
33
44
|
font-size: 14px;
|
|
34
45
|
|
|
35
46
|
@include theme() {
|
|
36
|
-
color: get(text-primary);
|
|
47
|
+
color: get(text-color-primary);
|
|
37
48
|
}
|
|
38
|
-
|
|
39
49
|
}
|
|
50
|
+
|
|
40
51
|
.system {
|
|
41
52
|
height: 32px;
|
|
42
53
|
}
|
|
43
54
|
}
|
|
44
|
-
|
|
45
|
-
.tui-chat-live-header {
|
|
46
|
-
|
|
47
|
-
}
|