@tencentcloud/chat-uikit-react 2.1.2 → 2.1.4
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/.eslintrc.js +0 -1
- package/CHANGELOG.md +10 -0
- package/dist/cjs/components/Avatar/Avatar.js +1 -1
- package/dist/cjs/components/Checkbox/index.d.ts +2 -1
- package/dist/cjs/components/ConversationCreate/ConversationCreatGroupDetail.js +1 -1
- package/dist/cjs/components/ConversationCreate/ConversationCreate.js +1 -1
- package/dist/cjs/components/ConversationCreate/hooks/useConversationCreate.js +1 -1
- package/dist/cjs/components/ConversationPreview/ConversationPreview.js +1 -1
- package/dist/cjs/components/ConversationPreview/ConversationPreviewContent.d.ts +4 -1
- package/dist/cjs/components/ConversationPreview/ConversationPreviewContent.js +1 -1
- package/dist/cjs/components/ConversationPreview/utils.js +1 -1
- package/dist/cjs/components/ConversationSearch/ConversationSearchInput.d.ts +2 -1
- package/dist/cjs/components/ConversationSearch/ConversationSearchResult.js +1 -1
- package/dist/cjs/components/DivWithEdit/DivWithEdit.d.ts +3 -2
- package/dist/cjs/components/DivWithEdit/DivWithEdit.js +1 -1
- package/dist/cjs/components/DivWithEdit/WithText.js +1 -1
- package/dist/cjs/components/EmptyStateIndicator/EmptyStateIndicator.d.ts +2 -1
- package/dist/cjs/components/Icon/Icon.d.ts +2 -1
- package/dist/cjs/components/Icon/Icon.js +1 -1
- package/dist/cjs/components/Input/Input.js +1 -1
- package/dist/cjs/components/Model/index.d.ts +1 -1
- package/dist/cjs/components/Model/index.js +1 -1
- package/dist/cjs/components/Plugins/index.js +1 -1
- package/dist/cjs/components/Popup/index.d.ts +1 -1
- package/dist/cjs/components/Popup/index.js +1 -1
- package/dist/cjs/components/Switch/Switch.d.ts +2 -6
- package/dist/cjs/components/Switch/Switch.js +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/useHandleMessage.js +1 -1
- package/dist/cjs/components/TUIChat/hooks/useHandleMessageList.js +1 -1
- package/dist/cjs/components/TUIChat/unitls.js +1 -1
- package/dist/cjs/components/TUIChatHeader/TUIChatHeaderDefault.js +1 -1
- package/dist/cjs/components/TUIContact/TUIContactInfo/addFriendInfo.js +1 -1
- package/dist/cjs/components/TUIContact/TUIContactInfo/friendInfo.js +1 -1
- package/dist/cjs/components/TUIContact/TUIContactList/TUIContactList.js +1 -1
- package/dist/cjs/components/TUIContactSearch/TUIContactSearch.js +1 -1
- package/dist/cjs/components/TUIContactSearch/hooks/useContactSearch.js +1 -1
- package/dist/cjs/components/TUIConversation/TUIConversation.js +1 -1
- package/dist/cjs/components/TUIConversationList/hooks/useConversationList.js +1 -1
- package/dist/cjs/components/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 +7 -7
- package/dist/cjs/components/TUIKit/hooks/useTUIKit.d.ts +2 -2
- package/dist/cjs/components/TUIKit/hooks/useTUIKit.js +1 -1
- package/dist/cjs/components/TUIManage/TUIManage.d.ts +4 -1
- package/dist/cjs/components/TUIManage/TUIManage.js +1 -1
- package/dist/cjs/components/TUIMessage/MessageAudio.js +1 -1
- package/dist/cjs/components/TUIMessage/MessageAvatar.js +1 -1
- package/dist/cjs/components/TUIMessage/MessageBubble.js +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/MessageFace.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/MessageLocation.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.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/MessageVideo.js +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/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/EmojiPicker.js +1 -1
- package/dist/cjs/components/TUIMessageInput/InputPluginsDefalut.js +1 -1
- package/dist/cjs/components/TUIMessageInput/InputQuoteDefalut.js +1 -1
- package/dist/cjs/components/TUIMessageInput/TUIForward.js +1 -1
- package/dist/cjs/components/TUIMessageInput/TUIMessageInputDefault.js +1 -1
- package/dist/cjs/components/TUIMessageInput/hooks/useEmojiPicker.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/useMessageInputState.d.ts +2 -2
- package/dist/cjs/components/TUIMessageInput/hooks/useMessageInputText.js +1 -1
- package/dist/cjs/components/TUIMessageInput/hooks/useUploadElement.js +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/TUIProfile.js +1 -1
- package/dist/cjs/components/TUIProfile/TUIProfileDefault.d.ts +2 -2
- package/dist/cjs/components/TUIProfile/TUIProfileDefault.js +1 -1
- package/dist/cjs/components/TUIProfile/hooks/useMyProfile.js +1 -1
- package/dist/cjs/components/Toast/index.js +1 -1
- package/dist/cjs/context/ComponentContext.d.ts +3 -2
- package/dist/cjs/context/TUIChatActionContext.d.ts +1 -1
- package/dist/cjs/context/TUIChatStateContext.d.ts +4 -4
- package/dist/cjs/context/TUIContactContext.js +1 -1
- package/dist/cjs/context/TUIConversationContext.js +1 -1
- package/dist/cjs/context/TUIKitContext.d.ts +1 -1
- package/dist/cjs/context/TUIMessageContext.js +1 -1
- package/dist/cjs/context/TUIMessageInputContext.js +1 -1
- package/dist/cjs/hooks/useProfile.d.ts +1 -1
- package/dist/cjs/index.css +1 -1
- package/dist/cjs/index.d.css +3 -3
- package/dist/cjs/index.d.ts +1 -1
- package/dist/cjs/index.js +1 -1
- package/dist/esm/components/Avatar/Avatar.js +1 -1
- package/dist/esm/components/Checkbox/index.d.ts +2 -1
- package/dist/esm/components/ConversationCreate/ConversationCreatGroupDetail.js +1 -1
- package/dist/esm/components/ConversationCreate/ConversationCreate.js +1 -1
- package/dist/esm/components/ConversationCreate/hooks/useConversationCreate.js +1 -1
- package/dist/esm/components/ConversationPreview/ConversationPreview.js +1 -1
- package/dist/esm/components/ConversationPreview/ConversationPreviewContent.d.ts +4 -1
- package/dist/esm/components/ConversationPreview/ConversationPreviewContent.js +1 -1
- package/dist/esm/components/ConversationPreview/utils.js +1 -1
- package/dist/esm/components/ConversationSearch/ConversationSearchInput.d.ts +2 -1
- package/dist/esm/components/ConversationSearch/ConversationSearchResult.js +1 -1
- package/dist/esm/components/DivWithEdit/DivWithEdit.d.ts +3 -2
- package/dist/esm/components/DivWithEdit/DivWithEdit.js +1 -1
- package/dist/esm/components/DivWithEdit/WithText.js +1 -1
- package/dist/esm/components/EmptyStateIndicator/EmptyStateIndicator.d.ts +2 -1
- package/dist/esm/components/Icon/Icon.d.ts +2 -1
- package/dist/esm/components/Icon/Icon.js +1 -1
- package/dist/esm/components/Input/Input.js +1 -1
- package/dist/esm/components/Model/index.d.ts +1 -1
- package/dist/esm/components/Model/index.js +1 -1
- package/dist/esm/components/Plugins/index.js +1 -1
- package/dist/esm/components/Popup/index.d.ts +1 -1
- package/dist/esm/components/Popup/index.js +1 -1
- package/dist/esm/components/Switch/Switch.d.ts +2 -6
- package/dist/esm/components/Switch/Switch.js +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/useHandleMessage.js +1 -1
- package/dist/esm/components/TUIChat/hooks/useHandleMessageList.js +1 -1
- package/dist/esm/components/TUIChat/unitls.js +1 -1
- package/dist/esm/components/TUIChatHeader/TUIChatHeaderDefault.js +1 -1
- package/dist/esm/components/TUIContact/TUIContactInfo/addFriendInfo.js +1 -1
- package/dist/esm/components/TUIContact/TUIContactInfo/friendInfo.js +1 -1
- package/dist/esm/components/TUIContact/TUIContactList/TUIContactList.js +1 -1
- package/dist/esm/components/TUIContactSearch/TUIContactSearch.js +1 -1
- package/dist/esm/components/TUIContactSearch/hooks/useContactSearch.js +1 -1
- package/dist/esm/components/TUIConversation/TUIConversation.js +1 -1
- package/dist/esm/components/TUIConversationList/hooks/useConversationList.js +1 -1
- package/dist/esm/components/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 +7 -7
- package/dist/esm/components/TUIKit/hooks/useTUIKit.d.ts +2 -2
- package/dist/esm/components/TUIKit/hooks/useTUIKit.js +1 -1
- package/dist/esm/components/TUIManage/TUIManage.d.ts +4 -1
- package/dist/esm/components/TUIManage/TUIManage.js +1 -1
- package/dist/esm/components/TUIMessage/MessageAudio.js +1 -1
- package/dist/esm/components/TUIMessage/MessageAvatar.js +1 -1
- package/dist/esm/components/TUIMessage/MessageBubble.js +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/MessageFace.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/MessageLocation.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.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/MessageVideo.js +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/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/EmojiPicker.js +1 -1
- package/dist/esm/components/TUIMessageInput/InputPluginsDefalut.js +1 -1
- package/dist/esm/components/TUIMessageInput/InputQuoteDefalut.js +1 -1
- package/dist/esm/components/TUIMessageInput/TUIForward.js +1 -1
- package/dist/esm/components/TUIMessageInput/TUIMessageInputDefault.js +1 -1
- package/dist/esm/components/TUIMessageInput/hooks/useEmojiPicker.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/useMessageInputState.d.ts +2 -2
- package/dist/esm/components/TUIMessageInput/hooks/useMessageInputText.js +1 -1
- package/dist/esm/components/TUIMessageInput/hooks/useUploadElement.js +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/TUIProfile.js +1 -1
- package/dist/esm/components/TUIProfile/TUIProfileDefault.d.ts +2 -2
- package/dist/esm/components/TUIProfile/TUIProfileDefault.js +1 -1
- package/dist/esm/components/TUIProfile/hooks/useMyProfile.js +1 -1
- package/dist/esm/components/Toast/index.js +1 -1
- package/dist/esm/context/ComponentContext.d.ts +3 -2
- package/dist/esm/context/TUIChatActionContext.d.ts +1 -1
- package/dist/esm/context/TUIChatStateContext.d.ts +4 -4
- package/dist/esm/context/TUIContactContext.js +1 -1
- package/dist/esm/context/TUIConversationContext.js +1 -1
- package/dist/esm/context/TUIKitContext.d.ts +1 -1
- package/dist/esm/context/TUIMessageContext.js +1 -1
- package/dist/esm/context/TUIMessageInputContext.js +1 -1
- package/dist/esm/hooks/useProfile.d.ts +1 -1
- package/dist/esm/index.css +1 -1
- package/dist/esm/index.d.css +3 -3
- package/dist/esm/index.d.ts +1 -1
- package/dist/esm/index.js +1 -1
- package/index.ts +1 -0
- package/package.json +7 -6
- package/rollup.config.js +2 -1
- package/src/components/Avatar/Avatar.tsx +7 -3
- package/src/components/Avatar/styles/index.scss +1 -1
- package/src/components/Checkbox/index.tsx +1 -1
- package/src/components/ConversationCreate/ConversationCreatGroupDetail.tsx +14 -7
- package/src/components/ConversationCreate/ConversationCreate.tsx +5 -1
- package/src/components/ConversationCreate/ConversationCreateSelectView.tsx +2 -2
- package/src/components/ConversationCreate/ConversationCreateUserSelectList.tsx +11 -10
- package/src/components/ConversationCreate/hooks/useConversationCreate.tsx +14 -12
- package/src/components/ConversationPreview/ConversationPreview.tsx +3 -3
- package/src/components/ConversationPreview/ConversationPreviewContent.tsx +9 -5
- package/src/components/ConversationPreview/utils.tsx +6 -3
- package/src/components/DivWithEdit/DivWithEdit.tsx +6 -5
- package/src/components/DivWithEdit/WithText.tsx +3 -1
- package/src/components/DivWithEdit/styles/index.scss +1 -1
- package/src/components/Icon/Icon.tsx +2 -2
- package/src/components/Input/Input.tsx +15 -12
- package/src/components/Model/index.tsx +2 -2
- package/src/components/Plugins/index.tsx +15 -12
- package/src/components/Popup/index.tsx +13 -9
- package/src/components/Profile/index.ts +1 -2
- package/src/components/Switch/Switch.tsx +5 -7
- package/src/components/TUIChat/TUIChat.tsx +20 -5
- package/src/components/TUIChat/TUIChatState.tsx +3 -3
- package/src/components/TUIChat/hooks/useHandleMessage.tsx +5 -5
- package/src/components/TUIChat/hooks/useHandleMessageList.tsx +2 -2
- package/src/components/TUIChat/unitls.ts +2 -2
- package/src/components/TUIChatHeader/TUIChatHeaderDefault.tsx +1 -1
- package/src/components/TUIContact/TUIContactInfo/addFriendInfo.tsx +2 -2
- package/src/components/TUIContact/TUIContactInfo/friendInfo.tsx +1 -2
- package/src/components/TUIContact/TUIContactInfo/hooks/useContactInfo.tsx +0 -10
- package/src/components/TUIContact/TUIContactList/TUIContactList.tsx +5 -3
- package/src/components/TUIContact/hooks/useTUIContact.tsx +3 -4
- package/src/components/TUIContactSearch/TUIContactSearch.tsx +6 -7
- package/src/components/TUIContactSearch/hooks/useContactSearch.tsx +1 -3
- package/src/components/TUIConversationList/TUIConversationList.tsx +1 -1
- package/src/components/TUIConversationList/hooks/useConversationList.tsx +19 -24
- package/src/components/TUIConversationList/hooks/useConversationUpdate.tsx +2 -2
- package/src/components/TUIKit/TUIKit.tsx +31 -12
- package/src/components/TUIKit/hooks/useTUIKit.tsx +14 -10
- package/src/components/TUIManage/TUIManage.tsx +20 -13
- package/src/components/TUIMessage/MessageAudio.tsx +8 -6
- package/src/components/TUIMessage/MessageAvatar.tsx +2 -2
- package/src/components/TUIMessage/MessageBubble.tsx +7 -5
- package/src/components/TUIMessage/MessageContext.tsx +3 -3
- package/src/components/TUIMessage/MessageCustom.tsx +5 -3
- package/src/components/TUIMessage/MessageFace.tsx +2 -2
- package/src/components/TUIMessage/MessageFile.tsx +5 -5
- package/src/components/TUIMessage/MessageImage.tsx +4 -2
- package/src/components/TUIMessage/MessageLocation.tsx +3 -3
- package/src/components/TUIMessage/MessageMerger.tsx +3 -3
- package/src/components/TUIMessage/MessageName.tsx +1 -1
- package/src/components/TUIMessage/MessagePlugins.tsx +12 -10
- package/src/components/TUIMessage/MessageProgress.tsx +5 -4
- package/src/components/TUIMessage/MessageRevoke.tsx +1 -1
- package/src/components/TUIMessage/MessageText.tsx +4 -4
- package/src/components/TUIMessage/MessageVideo.tsx +3 -3
- package/src/components/TUIMessage/TUIMessage.tsx +1 -1
- package/src/components/TUIMessage/TUIMessageDefault.tsx +3 -1
- package/src/components/TUIMessage/hooks/useMessageHandler.ts +13 -13
- package/src/components/TUIMessage/hooks/useMessageReply.ts +6 -4
- package/src/components/TUIMessage/utils/decodeText.ts +2 -3
- package/src/components/TUIMessage/utils/index.ts +1 -2
- package/src/components/TUIMessageInput/EmojiPicker.tsx +4 -4
- package/src/components/TUIMessageInput/InputPluginsDefalut.tsx +8 -8
- package/src/components/TUIMessageInput/InputQuoteDefalut.tsx +4 -2
- package/src/components/TUIMessageInput/TUIForward.tsx +22 -15
- package/src/components/TUIMessageInput/TUIMessageInputDefault.tsx +15 -9
- package/src/components/TUIMessageInput/hooks/useEmojiPicker.tsx +2 -2
- package/src/components/TUIMessageInput/hooks/useHandleForwardMessage.tsx +4 -4
- package/src/components/TUIMessageInput/hooks/useHandleQuoteMessage.tsx +5 -5
- package/src/components/TUIMessageInput/hooks/useMessageInputState.tsx +3 -3
- package/src/components/TUIMessageInput/hooks/useMessageInputText.tsx +12 -9
- package/src/components/TUIMessageInput/hooks/useUploadElement.tsx +2 -2
- package/src/components/TUIMessageInput/hooks/useUploadPicker.tsx +1 -1
- package/src/components/TUIMessageList/TUIMessageList.tsx +5 -6
- package/src/components/TUIMessageList/hooks/useMessageListElement.tsx +5 -2
- package/src/components/TUIProfile/TUIProfile.tsx +3 -1
- package/src/components/TUIProfile/TUIProfileDefault.tsx +17 -17
- package/src/components/TUIProfile/hooks/useMyProfile.tsx +19 -37
- package/src/components/Toast/index.tsx +3 -3
- package/src/components/Toast/styles/layout.scss +1 -1
- package/src/components/untils.ts +1 -1
- package/src/context/TUIChatStateContext.tsx +4 -4
- package/src/context/TUIContactContext.tsx +1 -1
- package/src/context/TUIConversationContext.tsx +2 -2
- package/src/context/TUIMessageContext.tsx +1 -1
- package/src/context/TUIMessageInputContext.tsx +1 -1
- package/src/hooks/useConversation.tsx +1 -1
- package/src/hooks/useProfile.tsx +2 -2
- package/tsconfig.json +1 -0
- package/dist/cjs/components/TUIProfile/hooks/useMyProfile.d.ts +0 -17
- package/dist/esm/components/TUIProfile/hooks/useMyProfile.d.ts +0 -17
- package/src/components/Profile/hooks/useProfile.tsx +0 -28
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import React, { useState, useEffect } from 'react';
|
|
2
|
-
import TencentCloudChat from '@tencentcloud/chat';
|
|
2
|
+
import TencentCloudChat, { Conversation, Friend, Profile } from '@tencentcloud/chat';
|
|
3
3
|
import { strChineseFirstPy } from '../static/word';
|
|
4
4
|
import { useProfile } from '../../../hooks';
|
|
5
5
|
|
|
6
6
|
export const useConversationCreate = (
|
|
7
|
-
chat,
|
|
8
|
-
conversationList
|
|
7
|
+
chat: any,
|
|
8
|
+
conversationList: Array<Conversation>,
|
|
9
9
|
setFriendListResultHandler?:(
|
|
10
10
|
newFriendListResult: object,
|
|
11
11
|
setFriendListResult: React.Dispatch<React.SetStateAction<{string:Array<object>}>>
|
|
12
12
|
) => void,
|
|
13
13
|
) => {
|
|
14
|
-
const [friendListSortResult, setFriendListSortResult] = useState(
|
|
14
|
+
const [friendListSortResult, setFriendListSortResult] = useState<any>();
|
|
15
15
|
const getFirstLetter = (str: string) => {
|
|
16
16
|
const temp = str.trim();
|
|
17
17
|
const uni = temp.charCodeAt(0);
|
|
@@ -22,12 +22,12 @@ export const useConversationCreate = (
|
|
|
22
22
|
};
|
|
23
23
|
const queryFriendList = async () => {
|
|
24
24
|
const frequentlyConversationProfile = conversationList.filter(
|
|
25
|
-
(item) => item
|
|
26
|
-
).slice(0, 5).map((item) => item
|
|
25
|
+
(item: Conversation) => item?.type === TencentCloudChat.TYPES.CONV_C2C,
|
|
26
|
+
).slice(0, 5).map((item: Conversation) => item?.userProfile);
|
|
27
27
|
const { code, data } = await chat.getFriendList();
|
|
28
28
|
if (code === 0) {
|
|
29
29
|
const sortResult = handleData(
|
|
30
|
-
data.map((item) => item.profile),
|
|
30
|
+
data.map((item: Friend) => item.profile),
|
|
31
31
|
frequentlyConversationProfile,
|
|
32
32
|
);
|
|
33
33
|
setFriendListSortResult(sortResult);
|
|
@@ -36,8 +36,8 @@ export const useConversationCreate = (
|
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
38
|
};
|
|
39
|
-
const handleData = (profileList
|
|
40
|
-
const sortResult = {
|
|
39
|
+
const handleData = (profileList: Array<Profile>, frequentlyConversationProfile?: any) => {
|
|
40
|
+
const sortResult: any = {
|
|
41
41
|
'#': [],
|
|
42
42
|
};
|
|
43
43
|
for (let i = 65; i <= 90; i += 1) {
|
|
@@ -55,7 +55,7 @@ export const useConversationCreate = (
|
|
|
55
55
|
}
|
|
56
56
|
});
|
|
57
57
|
Object.keys(sortResult).forEach((key) => {
|
|
58
|
-
sortResult[key].sort((a, b) => {
|
|
58
|
+
sortResult[key].sort((a: any, b: any) => {
|
|
59
59
|
const { nick: aNick, userID: aUserID } = a;
|
|
60
60
|
const { nick: bNick, userID: bUserID } = b;
|
|
61
61
|
if (aNick || aUserID < bNick || bUserID) {
|
|
@@ -73,12 +73,14 @@ export const useConversationCreate = (
|
|
|
73
73
|
if (!searchValue) return friendListSortResult;
|
|
74
74
|
const { data: profileList } = await getUserProfile([searchValue]);
|
|
75
75
|
|
|
76
|
-
const result = {};
|
|
76
|
+
const result: any = {};
|
|
77
77
|
let isIncludes = false;
|
|
78
78
|
Object.keys(friendListSortResult).forEach((key) => {
|
|
79
79
|
result[key] = friendListSortResult[key].filter(
|
|
80
|
+
// eslint-disable-next-line
|
|
81
|
+
// @ts-ignore
|
|
80
82
|
({ nick, userID }) => {
|
|
81
|
-
const tempNick = nick
|
|
83
|
+
const tempNick = nick?.toLocaleLowerCase();
|
|
82
84
|
const tempSearchValue = searchValue.toLocaleLowerCase();
|
|
83
85
|
const userIDValue = userID.toLocaleLowerCase();
|
|
84
86
|
let includes;
|
|
@@ -50,14 +50,14 @@ export function ConversationPreview<T extends ConversationPreviewProps>(
|
|
|
50
50
|
} = useTUIKitContext('ConversationPreview');
|
|
51
51
|
const [displayImage, setDisplayImage] = useState(getDisplayImage(conversation));
|
|
52
52
|
const [displayTitle, setDisplayTitle] = useState(getDisplayTitle(conversation, searchValue));
|
|
53
|
-
const [displayMessage, setDisplayMessage] = useState(getDisplayMessage(conversation, myProfile, language));
|
|
53
|
+
const [displayMessage, setDisplayMessage] = useState(myProfile && getDisplayMessage(conversation, myProfile, language));
|
|
54
54
|
const [displayTime, setDisplayTime] = useState(getDisplayTime(conversation, language));
|
|
55
55
|
const [unread, setUnread] = useState(conversation.unreadCount);
|
|
56
56
|
const isActive = activeConversation?.conversationID === conversation?.conversationID;
|
|
57
|
-
if (!Preview) return
|
|
57
|
+
if (!Preview) return <></>;
|
|
58
58
|
useEffect(() => {
|
|
59
59
|
setDisplayTitle(getDisplayTitle(conversation, searchValue));
|
|
60
|
-
setDisplayMessage(getDisplayMessage(conversation, myProfile, language));
|
|
60
|
+
myProfile && setDisplayMessage(getDisplayMessage(conversation, myProfile, language));
|
|
61
61
|
setDisplayImage(getDisplayImage(conversation));
|
|
62
62
|
setDisplayTime(getDisplayTime(conversation, language));
|
|
63
63
|
setUnread(conversation.unreadCount);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/* eslint-disable react/jsx-key */
|
|
1
2
|
import React, { useRef, useState, useEffect } from 'react';
|
|
2
3
|
import { useTranslation } from 'react-i18next';
|
|
3
4
|
import { TUIConversationService } from '@tencentcloud/chat-uikit-engine';
|
|
@@ -11,6 +12,9 @@ import { Plugins } from '../Plugins';
|
|
|
11
12
|
import { useConversation } from '../../hooks';
|
|
12
13
|
import { useTUIKitContext } from '../../context';
|
|
13
14
|
|
|
15
|
+
export interface IPluginsRef {
|
|
16
|
+
closeMore?: () => void,
|
|
17
|
+
}
|
|
14
18
|
export function unMemoConversationPreviewContent<T extends ConversationPreviewUIComponentProps>(
|
|
15
19
|
props: T,
|
|
16
20
|
):React.ReactElement {
|
|
@@ -36,7 +40,7 @@ export function unMemoConversationPreviewContent<T extends ConversationPreviewUI
|
|
|
36
40
|
const unreadClass = unread && unread >= 1 ? 'conversation-preview-content--unread' : '';
|
|
37
41
|
const pinClass = conversation.isPinned ? 'conversation-preview-content--pin' : '';
|
|
38
42
|
const [isHover, setIsHover] = useState(false);
|
|
39
|
-
const pluginsRef = useRef(null);
|
|
43
|
+
const pluginsRef = useRef<IPluginsRef>(null);
|
|
40
44
|
|
|
41
45
|
const onSelectConversation = () => {
|
|
42
46
|
TUIConversationService.switchConversation(conversation?.conversationID);
|
|
@@ -63,7 +67,7 @@ export function unMemoConversationPreviewContent<T extends ConversationPreviewUI
|
|
|
63
67
|
const handleH5LongPress = (type: string) => {
|
|
64
68
|
if (isPC) return;
|
|
65
69
|
const { conversationID } = conversation;
|
|
66
|
-
setActiveConversationID(conversationID);
|
|
70
|
+
setActiveConversationID && setActiveConversationID(conversationID);
|
|
67
71
|
function longPressHandler() {
|
|
68
72
|
clearTimeout(timer);
|
|
69
73
|
setIsHover(true);
|
|
@@ -92,15 +96,15 @@ export function unMemoConversationPreviewContent<T extends ConversationPreviewUI
|
|
|
92
96
|
const { conversationID, isPinned } = conversation;
|
|
93
97
|
e.stopPropagation();
|
|
94
98
|
setIsHover(false);
|
|
95
|
-
pluginsRef.current.closeMore();
|
|
99
|
+
pluginsRef?.current?.closeMore && pluginsRef.current.closeMore();
|
|
96
100
|
switch (type) {
|
|
97
101
|
case 'pin':
|
|
98
102
|
pinConversation({ conversationID, isPinned: !isPinned });
|
|
99
103
|
break;
|
|
100
104
|
case 'delete':
|
|
101
105
|
deleteConversation(conversationID);
|
|
102
|
-
if (conversation === activeConversation) {
|
|
103
|
-
setActiveConversation(
|
|
106
|
+
if (setActiveConversation && conversation === activeConversation) {
|
|
107
|
+
setActiveConversation(undefined);
|
|
104
108
|
}
|
|
105
109
|
break;
|
|
106
110
|
default:
|
|
@@ -27,12 +27,13 @@ export const getDisplayTitle = (
|
|
|
27
27
|
}
|
|
28
28
|
const handleTitle = (str:string) => {
|
|
29
29
|
const tempStr = str.toLocaleLowerCase();
|
|
30
|
-
const pos = tempStr.indexOf(searchValue.toLocaleLowerCase());
|
|
30
|
+
const pos = searchValue && tempStr.indexOf(searchValue.toLocaleLowerCase());
|
|
31
|
+
if (pos === '') return <></>
|
|
31
32
|
return (
|
|
32
33
|
<div>
|
|
33
34
|
<span>{str.slice(0, pos)}</span>
|
|
34
|
-
<span style={{ color: highlightColor }}>{str.slice(pos, pos + searchValue.length)}</span>
|
|
35
|
-
<span>{str.slice(pos + searchValue.length)}</span>
|
|
35
|
+
<span style={{ color: highlightColor }}>{pos && str.slice(pos, pos + searchValue.length)}</span>
|
|
36
|
+
<span>{pos && str.slice(pos + searchValue.length)}</span>
|
|
36
37
|
</div>
|
|
37
38
|
);
|
|
38
39
|
};
|
|
@@ -94,6 +95,8 @@ export const getDisplayMessage = (
|
|
|
94
95
|
};
|
|
95
96
|
interface TProfile extends Profile, Group {}
|
|
96
97
|
export const getMessageProfile = (conversation: Conversation):TProfile => {
|
|
98
|
+
// eslint-disable-next-line
|
|
99
|
+
// @ts-ignore
|
|
97
100
|
if (!conversation) return null;
|
|
98
101
|
let result = {};
|
|
99
102
|
const { type, groupProfile, userProfile } = conversation;
|
|
@@ -22,7 +22,7 @@ interface DivWithEditProps {
|
|
|
22
22
|
type?: string,
|
|
23
23
|
isEdit?: boolean,
|
|
24
24
|
toggle?: (name:string) => void,
|
|
25
|
-
close
|
|
25
|
+
close: () => void,
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
export function DivWithEdit<T extends DivWithEditProps>(props:PropsWithChildren<T>) {
|
|
@@ -40,15 +40,16 @@ export function DivWithEdit<T extends DivWithEditProps>(props:PropsWithChildren<
|
|
|
40
40
|
} = props;
|
|
41
41
|
|
|
42
42
|
const [value, setValue] = useState(propsValue);
|
|
43
|
-
|
|
43
|
+
// eslint-disable-next-line
|
|
44
|
+
// @ts-ignore
|
|
44
45
|
const WithEditElements = elements[type] || WithText;
|
|
45
46
|
|
|
46
47
|
useLayoutEffect(() => {
|
|
47
48
|
setValue(propsValue);
|
|
48
49
|
}, [propsValue]);
|
|
49
50
|
|
|
50
|
-
const handleConfirm = (data) => {
|
|
51
|
-
confirm({
|
|
51
|
+
const handleConfirm = (data: any) => {
|
|
52
|
+
confirm && confirm({
|
|
52
53
|
name,
|
|
53
54
|
value: data,
|
|
54
55
|
});
|
|
@@ -66,7 +67,7 @@ export function DivWithEdit<T extends DivWithEditProps>(props:PropsWithChildren<
|
|
|
66
67
|
<div className="show">
|
|
67
68
|
<p>{value || '-'}</p>
|
|
68
69
|
<div className="icon">
|
|
69
|
-
<Icon className="icon-edit" width={12} height={12} type={IconTypes.EDIT} onClick={() => { toggle(name); }} />
|
|
70
|
+
<Icon className="icon-edit" width={12} height={12} type={IconTypes.EDIT} onClick={() => { toggle && name && toggle(name); }} />
|
|
70
71
|
</div>
|
|
71
72
|
</div>
|
|
72
73
|
)
|
|
@@ -31,10 +31,12 @@ export function WithText<T extends WithEditProps>(props:PropsWithChildren<T>) {
|
|
|
31
31
|
};
|
|
32
32
|
|
|
33
33
|
const handleConfirm = () => {
|
|
34
|
-
confirm(value);
|
|
34
|
+
confirm && confirm(value);
|
|
35
35
|
};
|
|
36
36
|
return (
|
|
37
37
|
<div className={`edit ${className}`}>
|
|
38
|
+
{/* // eslint-disable-next-line
|
|
39
|
+
// @ts-ignore */}
|
|
38
40
|
<input ref={inputRef} type="text" value={value} onChange={handleChange} />
|
|
39
41
|
<Icon className="icon" width={15} height={10.5} type={IconTypes.CONFIRM} onClick={handleConfirm} />
|
|
40
42
|
</div>
|
|
@@ -28,13 +28,13 @@ export function Icon(props: React.PropsWithChildren<IconProps>) {
|
|
|
28
28
|
};
|
|
29
29
|
return (
|
|
30
30
|
<div
|
|
31
|
-
className={`tui-kit-icon ${changeTypeToIconClassName(type)} ${className}`}
|
|
31
|
+
className={`tui-kit-icon ${type && changeTypeToIconClassName(type)} ${className}`}
|
|
32
32
|
role="button"
|
|
33
33
|
tabIndex={0}
|
|
34
34
|
style={iconStyle}
|
|
35
35
|
onClick={onClick}
|
|
36
36
|
>
|
|
37
|
-
{children || changeTypeToIconComponent(type)}
|
|
37
|
+
{children || (type && changeTypeToIconComponent(type))}
|
|
38
38
|
</div>
|
|
39
39
|
);
|
|
40
40
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/* eslint-disable react/display-name */
|
|
1
2
|
import React, {
|
|
2
3
|
useRef, useState, useImperativeHandle, InputHTMLAttributes,
|
|
3
4
|
} from 'react';
|
|
@@ -25,10 +26,10 @@ export interface InputRef {
|
|
|
25
26
|
input: HTMLInputElement | null;
|
|
26
27
|
}
|
|
27
28
|
export const Input = React.forwardRef<InputRef, InputProps>(
|
|
28
|
-
(props:InputProps, ref):React.ReactElement => {
|
|
29
|
+
(props: InputProps, ref): React.ReactElement => {
|
|
29
30
|
const {
|
|
30
|
-
className =
|
|
31
|
-
customClassName =
|
|
31
|
+
className = "",
|
|
32
|
+
customClassName = "",
|
|
32
33
|
placeholder,
|
|
33
34
|
clearable = false,
|
|
34
35
|
prefix,
|
|
@@ -37,25 +38,25 @@ export const Input = React.forwardRef<InputRef, InputProps>(
|
|
|
37
38
|
onBlur,
|
|
38
39
|
onFocus,
|
|
39
40
|
onKeyDown,
|
|
40
|
-
value: propsValue =
|
|
41
|
-
border =
|
|
41
|
+
value: propsValue = "",
|
|
42
|
+
border = "",
|
|
42
43
|
disabled = false,
|
|
43
44
|
maxLength = undefined,
|
|
44
45
|
} = props;
|
|
45
46
|
|
|
46
47
|
const [focused, setFocused] = useState<boolean>(false);
|
|
47
|
-
const enterCodeList = [
|
|
48
|
+
const enterCodeList = ["Enter", "NumpadEnter"];
|
|
48
49
|
const [value, setValue] = useState(propsValue);
|
|
49
50
|
const inputRef = useRef<HTMLInputElement>(null);
|
|
50
|
-
const handleFocus = (e) => {
|
|
51
|
+
const handleFocus = (e: any) => {
|
|
51
52
|
setFocused(true);
|
|
52
53
|
onFocus?.(e);
|
|
53
54
|
};
|
|
54
|
-
const handleBlur = (e) => {
|
|
55
|
+
const handleBlur = (e: any) => {
|
|
55
56
|
setFocused(false);
|
|
56
57
|
onBlur?.(e);
|
|
57
58
|
};
|
|
58
|
-
const handleEnterKeyDown = (e) => {
|
|
59
|
+
const handleEnterKeyDown = (e: any) => {
|
|
59
60
|
if (enterCodeList.indexOf(e?.key) > -1 && onKeyDown) {
|
|
60
61
|
e?.preventDefault();
|
|
61
62
|
onKeyDown(e);
|
|
@@ -64,7 +65,9 @@ export const Input = React.forwardRef<InputRef, InputProps>(
|
|
|
64
65
|
const clearInput = (e: React.MouseEvent<HTMLElement, MouseEvent>) => {
|
|
65
66
|
setValue('');
|
|
66
67
|
focus();
|
|
67
|
-
const currentTarget = inputRef
|
|
68
|
+
const currentTarget = inputRef?.current?.cloneNode(
|
|
69
|
+
true
|
|
70
|
+
) as HTMLInputElement;
|
|
68
71
|
const event = Object.create(e, {
|
|
69
72
|
target: { value: currentTarget },
|
|
70
73
|
currentTarget: { value: currentTarget },
|
|
@@ -109,9 +112,9 @@ export const Input = React.forwardRef<InputRef, InputProps>(
|
|
|
109
112
|
/>
|
|
110
113
|
{suffix}
|
|
111
114
|
{(clearable && value)
|
|
112
|
-
&& <Icon type={IconTypes.CLEAR} height={13} width={13} onClick={clearInput} />}
|
|
115
|
+
&& <Icon type={IconTypes.CLEAR} height={13} width={13} onClick={(e: any) => {clearInput(e)}} />}
|
|
113
116
|
</div>
|
|
114
117
|
</div>
|
|
115
118
|
);
|
|
116
|
-
}
|
|
119
|
+
}
|
|
117
120
|
);
|
|
@@ -4,7 +4,7 @@ import './styles/index.scss';
|
|
|
4
4
|
|
|
5
5
|
interface PopupProps {
|
|
6
6
|
className?: string,
|
|
7
|
-
onClick?: (e
|
|
7
|
+
onClick?: (e: Event) => void,
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
export function Model<
|
|
@@ -17,7 +17,7 @@ T extends PopupProps
|
|
|
17
17
|
} = props;
|
|
18
18
|
|
|
19
19
|
return (
|
|
20
|
-
<div role="button" tabIndex={0} className={`model ${className}`} onClick={onClick}>
|
|
20
|
+
<div role="button" tabIndex={0} className={`model ${className}`} onClick={(e: any) => onClick && onClick(e)}>
|
|
21
21
|
{children}
|
|
22
22
|
</div>
|
|
23
23
|
);
|
|
@@ -22,6 +22,8 @@ export interface PluginsProps {
|
|
|
22
22
|
|
|
23
23
|
function PluginsWithContext<T extends PluginsProps>(
|
|
24
24
|
props:PropsWithChildren<T>,
|
|
25
|
+
// eslint-disable-next-line
|
|
26
|
+
// @ts-ignore
|
|
25
27
|
ref,
|
|
26
28
|
):React.ReactElement {
|
|
27
29
|
const {
|
|
@@ -36,31 +38,31 @@ function PluginsWithContext<T extends PluginsProps>(
|
|
|
36
38
|
} = props;
|
|
37
39
|
|
|
38
40
|
useImperativeHandle(ref, () => ({
|
|
39
|
-
closeMore: (newVal) => {
|
|
41
|
+
closeMore: (newVal: boolean) => {
|
|
40
42
|
setShow(false);
|
|
41
43
|
},
|
|
42
44
|
}));
|
|
43
45
|
|
|
44
46
|
const { showPicker, elements } = usePluginsElement({ plugins, showNumber });
|
|
45
|
-
const pluginRef = useRef(null);
|
|
47
|
+
const pluginRef = useRef<HTMLDivElement>(null);
|
|
46
48
|
|
|
47
49
|
const [show, setShow] = useState(false);
|
|
48
50
|
|
|
49
|
-
const handleShow = (e) => {
|
|
51
|
+
const handleShow = (e: any) => {
|
|
50
52
|
e.stopPropagation();
|
|
51
53
|
setShow(!show);
|
|
52
54
|
if (!show) {
|
|
53
|
-
pluginRef
|
|
55
|
+
pluginRef?.current?.offsetParent?.removeEventListener('scroll', handleShow);
|
|
54
56
|
}
|
|
55
57
|
};
|
|
56
58
|
|
|
57
|
-
const pluginHandleVisible = (data) => {
|
|
59
|
+
const pluginHandleVisible = (data: any) => {
|
|
58
60
|
if (handleVisible) {
|
|
59
61
|
const {
|
|
60
62
|
width, height,
|
|
61
|
-
} = pluginRef
|
|
62
|
-
const { x = 0, y = 0 } = pluginRef
|
|
63
|
-
pluginRef.current
|
|
63
|
+
} = pluginRef?.current?.children[1].getBoundingClientRect() || {};
|
|
64
|
+
const { x = 0, y = 0 } = pluginRef?.current?.getBoundingClientRect() || {};
|
|
65
|
+
pluginRef.current?.offsetParent?.addEventListener('scroll', handleShow);
|
|
64
66
|
handleVisible({
|
|
65
67
|
...data,
|
|
66
68
|
width,
|
|
@@ -70,11 +72,12 @@ function PluginsWithContext<T extends PluginsProps>(
|
|
|
70
72
|
});
|
|
71
73
|
}
|
|
72
74
|
};
|
|
73
|
-
|
|
75
|
+
// eslint-disable-next-line
|
|
76
|
+
// @ts-ignore
|
|
74
77
|
return (
|
|
75
|
-
(showPicker.length > 0 || elements?.length > 0) && (
|
|
78
|
+
((showPicker && showPicker.length > 0) || (elements && elements?.length > 0)) && (
|
|
76
79
|
<ul className={`plugin ${className}`}>
|
|
77
|
-
{showPicker?.length > 0 && showPicker.map((Item, index:number) => {
|
|
80
|
+
{showPicker && showPicker?.length > 0 && showPicker.map((Item, index:number) => {
|
|
78
81
|
const key = `${Item}${index}`;
|
|
79
82
|
return (
|
|
80
83
|
<li className="plugin-item" key={key}>
|
|
@@ -83,7 +86,7 @@ function PluginsWithContext<T extends PluginsProps>(
|
|
|
83
86
|
);
|
|
84
87
|
})}
|
|
85
88
|
{
|
|
86
|
-
elements?.length > 0 && (
|
|
89
|
+
elements && elements?.length > 0 && (
|
|
87
90
|
<div className="plugin-popup" ref={pluginRef}>
|
|
88
91
|
<div role="menuitem" tabIndex={0} className="more" onClick={handleShow}>
|
|
89
92
|
{
|
|
@@ -6,7 +6,7 @@ interface PopupProps {
|
|
|
6
6
|
className?: string,
|
|
7
7
|
style?: any,
|
|
8
8
|
show?: boolean,
|
|
9
|
-
close
|
|
9
|
+
close: (e: any) => void,
|
|
10
10
|
root?: any,
|
|
11
11
|
handleVisible?: (isVisible:any) => void,
|
|
12
12
|
}
|
|
@@ -49,7 +49,7 @@ T extends PopupProps
|
|
|
49
49
|
rootBounds: changeRootBounds,
|
|
50
50
|
intersectionRatio,
|
|
51
51
|
} = change;
|
|
52
|
-
const popupBoundingClientRect = popup.current
|
|
52
|
+
const popupBoundingClientRect = popup.current?.getBoundingClientRect() || {};
|
|
53
53
|
const rootRootBounds = root?.getBoundingClientRect() || {};
|
|
54
54
|
const boundingClientRect = {
|
|
55
55
|
...changeBoundingClientRec,
|
|
@@ -73,7 +73,7 @@ T extends PopupProps
|
|
|
73
73
|
threshold: [1],
|
|
74
74
|
});
|
|
75
75
|
|
|
76
|
-
if (popup && show) {
|
|
76
|
+
if (popup?.current && show) {
|
|
77
77
|
io.observe(popup?.current);
|
|
78
78
|
}
|
|
79
79
|
return () => {
|
|
@@ -82,13 +82,17 @@ T extends PopupProps
|
|
|
82
82
|
};
|
|
83
83
|
}, [popup, show]);
|
|
84
84
|
|
|
85
|
-
const stopImmediatePropagation = (e) => {
|
|
85
|
+
const stopImmediatePropagation = (e: Event) => {
|
|
86
86
|
e.stopPropagation();
|
|
87
87
|
};
|
|
88
88
|
|
|
89
|
-
return
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
89
|
+
return (
|
|
90
|
+
<>{show && (
|
|
91
|
+
// eslint-disable-next-line
|
|
92
|
+
// @ts-ignore
|
|
93
|
+
<div role="button" tabIndex={0} style={style} className={`popup ${className} ${isSetPos && 'popup-show'}`} ref={popup}>
|
|
94
|
+
{children}
|
|
95
|
+
</div>)}
|
|
96
|
+
</>
|
|
97
|
+
)
|
|
94
98
|
}
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
export * from './Profile';
|
|
2
|
-
export * from './hooks/useProfile';
|
|
1
|
+
export * from './Profile';
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import React, { useEffect, useRef } from 'react';
|
|
2
|
-
// Switch
|
|
3
|
-
//
|
|
4
|
-
//
|
|
2
|
+
// The general logic of Switch style:
|
|
3
|
+
// Hide the input, then control the style through the label label and the span in the label, and add styles to the selected situation through
|
|
4
|
+
// the pseudo-element selector: checked
|
|
5
|
+
// Note: After setting the display: inline; attribute, it is best to add vertical-align:top;, otherwise some inexplicable bugs will appear
|
|
5
6
|
import './Switch.scss';
|
|
6
7
|
import { creteNewId } from './utils/newId';
|
|
7
8
|
|
|
@@ -14,7 +15,7 @@ interface Props {
|
|
|
14
15
|
// : React.FunctionComponent<Props>
|
|
15
16
|
export function Switch(props:Props) {
|
|
16
17
|
const {
|
|
17
|
-
checked, onChange, checkedColor, className,
|
|
18
|
+
checked, onChange, checkedColor = '#34C759', className,
|
|
18
19
|
} = props;
|
|
19
20
|
const idRef = useRef<string>(creteNewId());
|
|
20
21
|
return (
|
|
@@ -36,6 +37,3 @@ export function Switch(props:Props) {
|
|
|
36
37
|
</div>
|
|
37
38
|
);
|
|
38
39
|
}
|
|
39
|
-
Switch.defaultProps = {
|
|
40
|
-
checkedColor: '#34C759',
|
|
41
|
-
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/* eslint-disable react/display-name */
|
|
1
2
|
import React, {
|
|
2
3
|
PropsWithChildren, useEffect, useMemo, useReducer, useRef, useState,
|
|
3
4
|
} from 'react';
|
|
@@ -122,14 +123,14 @@ function TUIChatInner <T extends TUIChatInnerProps>(
|
|
|
122
123
|
TUIMessageListConfig,
|
|
123
124
|
} = props;
|
|
124
125
|
|
|
125
|
-
const [state, dispatch] = useReducer<
|
|
126
|
+
const [state, dispatch] = useReducer<any>(chatReducer, {
|
|
126
127
|
...initialState,
|
|
127
128
|
conversation,
|
|
128
129
|
});
|
|
129
130
|
|
|
130
131
|
const messageListRef = useRef(null);
|
|
131
132
|
const textareaRef = useRef<HTMLTextAreaElement>();
|
|
132
|
-
const chatStateContextValue = useCreateTUIChatStateContext({
|
|
133
|
+
const chatStateContextValue = state && useCreateTUIChatStateContext({
|
|
133
134
|
chat,
|
|
134
135
|
conversation,
|
|
135
136
|
messageListRef,
|
|
@@ -147,6 +148,8 @@ function TUIChatInner <T extends TUIChatInnerProps>(
|
|
|
147
148
|
} = useHandleMessageList({
|
|
148
149
|
chat,
|
|
149
150
|
conversation,
|
|
151
|
+
// eslint-disable-next-line
|
|
152
|
+
// @ts-ignore
|
|
150
153
|
state,
|
|
151
154
|
dispatch,
|
|
152
155
|
filterMessage,
|
|
@@ -159,11 +162,12 @@ function TUIChatInner <T extends TUIChatInnerProps>(
|
|
|
159
162
|
setHighlightedMessageId,
|
|
160
163
|
setActiveMessageID,
|
|
161
164
|
} = useHandleMessage({
|
|
165
|
+
// eslint-disable-next-line
|
|
166
|
+
// @ts-ignore
|
|
162
167
|
state,
|
|
163
168
|
dispatch,
|
|
164
169
|
});
|
|
165
170
|
|
|
166
|
-
// 消息 messageList
|
|
167
171
|
useEffect(() => {
|
|
168
172
|
TUIStore.watch(StoreName.CHAT, {
|
|
169
173
|
messageList: onMessageListUpdated,
|
|
@@ -179,6 +183,8 @@ function TUIChatInner <T extends TUIChatInnerProps>(
|
|
|
179
183
|
|
|
180
184
|
const onMessageListUpdated = (list: IMessageModel[]) => {
|
|
181
185
|
const messageList = list.filter((message) => !message.isDeleted);
|
|
186
|
+
// eslint-disable-next-line
|
|
187
|
+
// @ts-ignore
|
|
182
188
|
dispatch({
|
|
183
189
|
type: CONSTANT_DISPATCH_TYPE.SET_MESSAGELIST,
|
|
184
190
|
value: filterMessage ? filterMessage(messageList) : messageList,
|
|
@@ -187,6 +193,8 @@ function TUIChatInner <T extends TUIChatInnerProps>(
|
|
|
187
193
|
|
|
188
194
|
const isCompletedUpdated = (flag: boolean) => {
|
|
189
195
|
if (flag) {
|
|
196
|
+
// eslint-disable-next-line
|
|
197
|
+
// @ts-ignore
|
|
190
198
|
dispatch({
|
|
191
199
|
type: CONSTANT_DISPATCH_TYPE.SET_NO_MORE,
|
|
192
200
|
value: flag,
|
|
@@ -194,7 +202,7 @@ function TUIChatInner <T extends TUIChatInnerProps>(
|
|
|
194
202
|
}
|
|
195
203
|
};
|
|
196
204
|
|
|
197
|
-
//
|
|
205
|
+
// Load historical messages
|
|
198
206
|
const loadMore = async () => {
|
|
199
207
|
TUIChatService.getMessageList();
|
|
200
208
|
};
|
|
@@ -202,15 +210,20 @@ function TUIChatInner <T extends TUIChatInnerProps>(
|
|
|
202
210
|
const setFirstSendMessage = async (message: any) => {
|
|
203
211
|
if (
|
|
204
212
|
!(message.type === 'TIMCustomElem' && JSONStringToParse(message.payload.data)?.src === 7)
|
|
213
|
+
// eslint-disable-next-line
|
|
214
|
+
// @ts-ignore
|
|
205
215
|
&& !state.firstSendMessage
|
|
206
216
|
) {
|
|
217
|
+
// eslint-disable-next-line
|
|
218
|
+
// @ts-ignore
|
|
207
219
|
dispatch({
|
|
208
220
|
type: CONSTANT_DISPATCH_TYPE.SET_FIRST_SEND_MESSAGE,
|
|
209
221
|
value: message,
|
|
210
222
|
});
|
|
211
223
|
}
|
|
212
224
|
};
|
|
213
|
-
|
|
225
|
+
// eslint-disable-next-line
|
|
226
|
+
// @ts-ignore
|
|
214
227
|
const chatActionContextValue: TUIChatActionContextValue = useMemo(
|
|
215
228
|
() => ({
|
|
216
229
|
editLocalMessage,
|
|
@@ -255,6 +268,8 @@ function TUIChatInner <T extends TUIChatInnerProps>(
|
|
|
255
268
|
|
|
256
269
|
return (
|
|
257
270
|
<div className={`chat ${className}`}>
|
|
271
|
+
{/* // eslint-disable-next-line
|
|
272
|
+
// @ts-ignore */}
|
|
258
273
|
<TUIChatStateContextProvider value={chatStateContextValue}>
|
|
259
274
|
<TUIChatActionProvider value={chatActionContextValue}>
|
|
260
275
|
<ComponentProvider value={componentContextValue}>
|
|
@@ -71,14 +71,14 @@ export const chatReducer = (
|
|
|
71
71
|
switch (action?.type) {
|
|
72
72
|
case CONSTANT_DISPATCH_TYPE.SET_CONVERSATION_PRPFILE:
|
|
73
73
|
return { ...state, conversation: action.value };
|
|
74
|
-
// messageList
|
|
74
|
+
// messageList set
|
|
75
75
|
case CONSTANT_DISPATCH_TYPE.SET_MESSAGELIST:
|
|
76
76
|
return {
|
|
77
77
|
...state,
|
|
78
78
|
messageList: action.value,
|
|
79
79
|
};
|
|
80
80
|
case CONSTANT_DISPATCH_TYPE.SET_EDIT_MESSAGE:
|
|
81
|
-
return {
|
|
81
|
+
return state.messageList && action.value && {
|
|
82
82
|
...state,
|
|
83
83
|
messageList: [...handleEditMessage(state.messageList, action.value)],
|
|
84
84
|
};
|
|
@@ -97,7 +97,7 @@ export const chatReducer = (
|
|
|
97
97
|
case CONSTANT_DISPATCH_TYPE.SET_VIDEO_SOURCE:
|
|
98
98
|
return { ...state, vidoeSource: action.value };
|
|
99
99
|
case CONSTANT_DISPATCH_TYPE.UPDATE_UPLOAD_PENDING_MESSAGE_LIST:
|
|
100
|
-
return {
|
|
100
|
+
return state?.uploadPendingMessageList && action.value && {
|
|
101
101
|
...state,
|
|
102
102
|
uploadPendingMessageList: [
|
|
103
103
|
...handleUploadPendingMessage(state.uploadPendingMessageList, action.value),
|
|
@@ -21,35 +21,35 @@ export function useHandleMessage<T extends CreateMessageProps>(props:T) {
|
|
|
21
21
|
} = props;
|
|
22
22
|
|
|
23
23
|
const operateMessage = useCallback((data: OperateMessageParams) => {
|
|
24
|
-
dispatch({
|
|
24
|
+
dispatch && dispatch({
|
|
25
25
|
type: CONSTANT_DISPATCH_TYPE.OPERATE_MESSAGE,
|
|
26
26
|
value: data,
|
|
27
27
|
});
|
|
28
28
|
}, [dispatch]);
|
|
29
29
|
|
|
30
30
|
const setAudioSource = useCallback((data: HTMLAudioElement | null) => {
|
|
31
|
-
dispatch({
|
|
31
|
+
dispatch && dispatch({
|
|
32
32
|
type: CONSTANT_DISPATCH_TYPE.SET_AUDIO_SOURCE,
|
|
33
33
|
value: data,
|
|
34
34
|
});
|
|
35
35
|
}, [dispatch]);
|
|
36
36
|
|
|
37
37
|
const setVideoSource = useCallback((data: HTMLVideoElement | null) => {
|
|
38
|
-
dispatch({
|
|
38
|
+
dispatch && dispatch({
|
|
39
39
|
type: CONSTANT_DISPATCH_TYPE.SET_VIDEO_SOURCE,
|
|
40
40
|
value: data,
|
|
41
41
|
});
|
|
42
42
|
}, [dispatch]);
|
|
43
43
|
|
|
44
44
|
const setHighlightedMessageId = useCallback((highlightedMessageId: string) => {
|
|
45
|
-
dispatch({
|
|
45
|
+
dispatch && dispatch({
|
|
46
46
|
type: CONSTANT_DISPATCH_TYPE.SET_HIGH_LIGHTED_MESSAGE_ID,
|
|
47
47
|
value: highlightedMessageId,
|
|
48
48
|
});
|
|
49
49
|
}, [dispatch]);
|
|
50
50
|
|
|
51
51
|
const setActiveMessageID = useCallback((messageID: string) => {
|
|
52
|
-
dispatch({
|
|
52
|
+
dispatch && dispatch({
|
|
53
53
|
type: CONSTANT_DISPATCH_TYPE.SET_ACTIVE_MESSAGE_ID,
|
|
54
54
|
value: messageID,
|
|
55
55
|
});
|