@droppii-org/chat-mobile 0.2.29 → 0.2.31
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/lib/module/assets/images/index.js +1 -0
- package/lib/module/assets/images/index.js.map +1 -1
- package/lib/module/assets/images/notification-warning.png +0 -0
- package/lib/module/components/ThreadCard/MuteThread.js +71 -31
- package/lib/module/components/ThreadCard/MuteThread.js.map +1 -1
- package/lib/module/components/ThreadCard/ThreadCard.js +9 -4
- package/lib/module/components/ThreadCard/ThreadCard.js.map +1 -1
- package/lib/module/components/flows/inputButtons/index.js +6 -3
- package/lib/module/components/flows/inputButtons/index.js.map +1 -1
- package/lib/module/components/messages/fileMessage/index.js +2 -1
- package/lib/module/components/messages/fileMessage/index.js.map +1 -1
- package/lib/module/config/api-endpoints.js +2 -1
- package/lib/module/config/api-endpoints.js.map +1 -1
- package/lib/module/context/ChatDetailContext.js +35 -2
- package/lib/module/context/ChatDetailContext.js.map +1 -1
- package/lib/module/context/index.js +1 -0
- package/lib/module/context/index.js.map +1 -1
- package/lib/module/hooks/conversation/useGetConversationDetail.js +58 -0
- package/lib/module/hooks/conversation/useGetConversationDetail.js.map +1 -0
- package/lib/module/hooks/flows/useFlow.js +1 -1
- package/lib/module/hooks/flows/useFlow.js.map +1 -1
- package/lib/module/hooks/flows/useGetConversationFlowMainMenu.js +17 -0
- package/lib/module/hooks/flows/useGetConversationFlowMainMenu.js.map +1 -0
- package/lib/module/hooks/message/useSendMessage.js +32 -7
- package/lib/module/hooks/message/useSendMessage.js.map +1 -1
- package/lib/module/hooks/query-keys.js +5 -1
- package/lib/module/hooks/query-keys.js.map +1 -1
- package/lib/module/hooks/useChatCompose.js +0 -1
- package/lib/module/hooks/useChatCompose.js.map +1 -1
- package/lib/module/hooks/useIsJoinedGroup.js +15 -0
- package/lib/module/hooks/useIsJoinedGroup.js.map +1 -0
- package/lib/module/index.js +4 -2
- package/lib/module/index.js.map +1 -1
- package/lib/module/screens/chat-detail/ChatAttachmentPanel.js +4 -14
- package/lib/module/screens/chat-detail/ChatAttachmentPanel.js.map +1 -1
- package/lib/module/screens/chat-detail/ChatComposer.js +26 -15
- package/lib/module/screens/chat-detail/ChatComposer.js.map +1 -1
- package/lib/module/screens/chat-detail/ChatDetail.js +58 -71
- package/lib/module/screens/chat-detail/ChatDetail.js.map +1 -1
- package/lib/module/screens/chat-detail/ChatDetailHeader.js +7 -10
- package/lib/module/screens/chat-detail/ChatDetailHeader.js.map +1 -1
- package/lib/module/screens/chat-detail/ChatListLegend.js +1 -1
- package/lib/module/screens/chat-detail/ChatListLegend.js.map +1 -1
- package/lib/module/screens/chat-detail/ChatLoadEarlier.js.map +1 -1
- package/lib/module/screens/chat-detail/ChatQuickActions.js +2 -1
- package/lib/module/screens/chat-detail/ChatQuickActions.js.map +1 -1
- package/lib/module/screens/chat-detail/constants.js +30 -24
- package/lib/module/screens/chat-detail/constants.js.map +1 -1
- package/lib/module/screens/chat-detail/index.js +2 -2
- package/lib/module/screens/chat-detail/index.js.map +1 -1
- package/lib/module/screens/chat-detail/legend/LegendChatMessage.js +1 -4
- package/lib/module/screens/chat-detail/legend/LegendChatMessage.js.map +1 -1
- package/lib/module/screens/chat-detail/types.js +15 -1
- package/lib/module/screens/chat-detail/types.js.map +1 -1
- package/lib/module/services/attachmentHandlers/imageAttachmentHandler.js +2 -2
- package/lib/module/services/attachmentHandlers/imageAttachmentHandler.js.map +1 -1
- package/lib/module/services/endpoints.js +3 -1
- package/lib/module/services/endpoints.js.map +1 -1
- package/lib/module/translation/resources/i18n.js +8 -2
- package/lib/module/translation/resources/i18n.js.map +1 -1
- package/lib/module/types/chat.js +9 -0
- package/lib/module/types/chat.js.map +1 -1
- package/lib/module/types/flows.js +5 -0
- package/lib/module/types/flows.js.map +1 -1
- package/lib/module/utils/device.js +1 -1
- package/lib/module/utils/device.js.map +1 -1
- package/lib/module/utils/flows.js +5 -0
- package/lib/module/utils/flows.js.map +1 -1
- package/lib/module/utils/imageUtils.js +0 -3
- package/lib/module/utils/imageUtils.js.map +1 -1
- package/lib/module/utils/messageUtils.js +5 -19
- package/lib/module/utils/messageUtils.js.map +1 -1
- package/lib/typescript/src/assets/images/index.d.ts +1 -0
- package/lib/typescript/src/assets/images/index.d.ts.map +1 -1
- package/lib/typescript/src/components/ThreadCard/MuteThread.d.ts.map +1 -1
- package/lib/typescript/src/components/ThreadCard/ThreadCard.d.ts.map +1 -1
- package/lib/typescript/src/components/flows/inputButtons/index.d.ts.map +1 -1
- package/lib/typescript/src/config/api-endpoints.d.ts +1 -0
- package/lib/typescript/src/config/api-endpoints.d.ts.map +1 -1
- package/lib/typescript/src/context/ChatDetailContext.d.ts +1 -1
- package/lib/typescript/src/context/ChatDetailContext.d.ts.map +1 -1
- package/lib/typescript/src/context/index.d.ts +1 -0
- package/lib/typescript/src/context/index.d.ts.map +1 -1
- package/lib/typescript/src/hooks/conversation/useGetConversationDetail.d.ts +17 -0
- package/lib/typescript/src/hooks/conversation/useGetConversationDetail.d.ts.map +1 -0
- package/lib/typescript/src/hooks/flows/useGetConversationFlowMainMenu.d.ts +3 -0
- package/lib/typescript/src/hooks/flows/useGetConversationFlowMainMenu.d.ts.map +1 -0
- package/lib/typescript/src/hooks/message/useSendMessage.d.ts +5 -4
- package/lib/typescript/src/hooks/message/useSendMessage.d.ts.map +1 -1
- package/lib/typescript/src/hooks/query-keys.d.ts +4 -0
- package/lib/typescript/src/hooks/query-keys.d.ts.map +1 -1
- package/lib/typescript/src/hooks/useIsJoinedGroup.d.ts +2 -0
- package/lib/typescript/src/hooks/useIsJoinedGroup.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +6 -4
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/screens/chat-detail/ChatAttachmentPanel.d.ts +2 -2
- package/lib/typescript/src/screens/chat-detail/ChatAttachmentPanel.d.ts.map +1 -1
- package/lib/typescript/src/screens/chat-detail/ChatComposer.d.ts +3 -1
- package/lib/typescript/src/screens/chat-detail/ChatComposer.d.ts.map +1 -1
- package/lib/typescript/src/screens/chat-detail/ChatDetail.d.ts +1 -1
- package/lib/typescript/src/screens/chat-detail/ChatDetail.d.ts.map +1 -1
- package/lib/typescript/src/screens/chat-detail/ChatDetailHeader.d.ts +1 -1
- package/lib/typescript/src/screens/chat-detail/ChatDetailHeader.d.ts.map +1 -1
- package/lib/typescript/src/screens/chat-detail/ChatLoadEarlier.d.ts +3 -2
- package/lib/typescript/src/screens/chat-detail/ChatLoadEarlier.d.ts.map +1 -1
- package/lib/typescript/src/screens/chat-detail/ChatQuickActions.d.ts +1 -1
- package/lib/typescript/src/screens/chat-detail/ChatQuickActions.d.ts.map +1 -1
- package/lib/typescript/src/screens/chat-detail/constants.d.ts +3 -3
- package/lib/typescript/src/screens/chat-detail/constants.d.ts.map +1 -1
- package/lib/typescript/src/screens/chat-detail/index.d.ts +3 -3
- package/lib/typescript/src/screens/chat-detail/index.d.ts.map +1 -1
- package/lib/typescript/src/screens/chat-detail/legend/LegendChatMessage.d.ts +1 -1
- package/lib/typescript/src/screens/chat-detail/legend/LegendChatMessage.d.ts.map +1 -1
- package/lib/typescript/src/screens/chat-detail/types.d.ts +28 -19
- package/lib/typescript/src/screens/chat-detail/types.d.ts.map +1 -1
- package/lib/typescript/src/services/endpoints.d.ts +2 -0
- package/lib/typescript/src/services/endpoints.d.ts.map +1 -1
- package/lib/typescript/src/store/conversation.d.ts +1 -1
- package/lib/typescript/src/store/conversation.d.ts.map +1 -1
- package/lib/typescript/src/translation/resources/i18n.d.ts.map +1 -1
- package/lib/typescript/src/types/chat.d.ts +26 -2
- package/lib/typescript/src/types/chat.d.ts.map +1 -1
- package/lib/typescript/src/types/flows.d.ts +3 -0
- package/lib/typescript/src/types/flows.d.ts.map +1 -1
- package/lib/typescript/src/utils/flows.d.ts +2 -0
- package/lib/typescript/src/utils/flows.d.ts.map +1 -1
- package/lib/typescript/src/utils/imageUtils.d.ts +0 -1
- package/lib/typescript/src/utils/imageUtils.d.ts.map +1 -1
- package/lib/typescript/src/utils/messageUtils.d.ts +1 -1
- package/lib/typescript/src/utils/messageUtils.d.ts.map +1 -1
- package/package.json +4 -6
- package/src/assets/images/index.ts +1 -0
- package/src/assets/images/notification-warning.png +0 -0
- package/src/components/ThreadCard/MuteThread.tsx +70 -36
- package/src/components/ThreadCard/ThreadCard.tsx +7 -3
- package/src/components/flows/inputButtons/index.tsx +11 -3
- package/src/components/messages/fileMessage/index.tsx +1 -0
- package/src/config/api-endpoints.ts +2 -0
- package/src/context/ChatDetailContext.tsx +57 -4
- package/src/context/index.ts +1 -0
- package/src/hooks/conversation/useGetConversationDetail.ts +78 -0
- package/src/hooks/flows/useFlow.ts +1 -1
- package/src/hooks/flows/useGetConversationFlowMainMenu.ts +19 -0
- package/src/hooks/message/useSendMessage.ts +43 -14
- package/src/hooks/query-keys.ts +7 -0
- package/src/hooks/useChatCompose.ts +1 -1
- package/src/hooks/useIsJoinedGroup.ts +13 -0
- package/src/index.tsx +15 -6
- package/src/screens/chat-detail/ChatAttachmentPanel.tsx +8 -25
- package/src/screens/chat-detail/ChatComposer.tsx +26 -21
- package/src/screens/chat-detail/ChatDetail.tsx +61 -77
- package/src/screens/chat-detail/ChatDetailHeader.tsx +7 -18
- package/src/screens/chat-detail/ChatListLegend.tsx +1 -1
- package/src/screens/chat-detail/ChatLoadEarlier.tsx +1 -2
- package/src/screens/chat-detail/ChatQuickActions.tsx +6 -2
- package/src/screens/chat-detail/constants.ts +33 -27
- package/src/screens/chat-detail/index.ts +5 -8
- package/src/screens/chat-detail/legend/LegendChatMessage.tsx +1 -5
- package/src/screens/chat-detail/types.ts +30 -28
- package/src/services/attachmentHandlers/imageAttachmentHandler.ts +2 -2
- package/src/services/endpoints.ts +4 -0
- package/src/store/conversation.ts +1 -1
- package/src/translation/resources/i18n.ts +7 -1
- package/src/types/chat.ts +31 -1
- package/src/types/flows.ts +4 -0
- package/src/utils/device.ts +1 -1
- package/src/utils/flows.ts +7 -0
- package/src/utils/imageUtils.ts +0 -4
- package/src/utils/messageUtils.ts +7 -22
- package/lib/module/screens/chat-detail/ChatDay.js +0 -65
- package/lib/module/screens/chat-detail/ChatDay.js.map +0 -1
- package/lib/module/types/message.js +0 -17
- package/lib/module/types/message.js.map +0 -1
- package/lib/module/utils/resolveMessageType.js +0 -47
- package/lib/module/utils/resolveMessageType.js.map +0 -1
- package/lib/typescript/src/screens/chat-detail/ChatDay.d.ts +0 -3
- package/lib/typescript/src/screens/chat-detail/ChatDay.d.ts.map +0 -1
- package/lib/typescript/src/types/message.d.ts +0 -16
- package/lib/typescript/src/types/message.d.ts.map +0 -1
- package/lib/typescript/src/utils/resolveMessageType.d.ts +0 -4
- package/lib/typescript/src/utils/resolveMessageType.d.ts.map +0 -1
- package/src/screens/chat-detail/ChatDay.tsx +0 -73
- package/src/types/message.ts +0 -18
- package/src/utils/resolveMessageType.ts +0 -51
|
@@ -14,30 +14,22 @@ import { useConversation, useConversationStore } from '../../store';
|
|
|
14
14
|
import ChatDetailHeader from './ChatDetailHeader';
|
|
15
15
|
import { ChatListLegend } from './ChatListLegend';
|
|
16
16
|
import { ChatComposer } from './ChatComposer';
|
|
17
|
-
import {
|
|
18
|
-
getConversationAvatarUri,
|
|
19
|
-
getConversationSubtitle,
|
|
20
|
-
getConversationTitle,
|
|
21
|
-
shouldShowAddMember,
|
|
22
|
-
} from './conversationHeader.utils';
|
|
17
|
+
import { shouldShowAddMember } from './conversationHeader.utils';
|
|
23
18
|
import type { ChatDetailProps } from './types';
|
|
24
|
-
import { ChatDetailProvider } from '../../context/ChatDetailContext';
|
|
25
19
|
import { normalizeUrl } from '../../utils/url';
|
|
26
|
-
// import { ChatMessageAPI } from '../../services/message';
|
|
27
20
|
import { MessageToolboxOverlay } from './messageToolbox/MessageToolboxOverlay';
|
|
28
21
|
import type { MeasuredRect, MessageToolboxRef } from './messageToolbox/types';
|
|
29
22
|
import type { DMessageItem } from '../../types/chat';
|
|
23
|
+
import { useGetConversationDetail } from '../../hooks/conversation/useGetConversationDetail';
|
|
30
24
|
|
|
31
25
|
const ChatDetail = memo(
|
|
32
26
|
({
|
|
33
|
-
|
|
27
|
+
targetConversationId = '',
|
|
28
|
+
targetUserId = '',
|
|
29
|
+
targetGroupId = '',
|
|
30
|
+
targetBotId = '',
|
|
34
31
|
enabled = true,
|
|
35
|
-
title,
|
|
36
|
-
subtitle,
|
|
37
|
-
avatarUri,
|
|
38
|
-
avatarFullName,
|
|
39
32
|
showAddMember,
|
|
40
|
-
getSubtitle,
|
|
41
33
|
onBack,
|
|
42
34
|
onPressSearch,
|
|
43
35
|
onPressAddMember,
|
|
@@ -45,10 +37,20 @@ const ChatDetail = memo(
|
|
|
45
37
|
onPressAvatar,
|
|
46
38
|
onPressUrl,
|
|
47
39
|
customMessageItemFactory,
|
|
40
|
+
pannelActions,
|
|
48
41
|
}: ChatDetailProps) => {
|
|
49
42
|
const navigation = useNavigation();
|
|
50
43
|
const mediaViewerRef = useRef<MediaViewerModalHandle>(null);
|
|
51
44
|
const messageToolboxRef = useRef<MessageToolboxRef>(null);
|
|
45
|
+
|
|
46
|
+
const { conversationId, isLoading: isLoadingConversation } =
|
|
47
|
+
useGetConversationDetail({
|
|
48
|
+
targetConversationId,
|
|
49
|
+
targetUserId,
|
|
50
|
+
targetGroupId,
|
|
51
|
+
targetBotId,
|
|
52
|
+
});
|
|
53
|
+
|
|
52
54
|
const conversation = useConversation(conversationId);
|
|
53
55
|
|
|
54
56
|
const handleBackDefault = useCallback(() => {
|
|
@@ -75,31 +77,16 @@ const ChatDetail = memo(
|
|
|
75
77
|
} = useChatMessages({ conversationId, enabled });
|
|
76
78
|
|
|
77
79
|
useEffect(() => {
|
|
78
|
-
|
|
80
|
+
if (conversationId) {
|
|
81
|
+
useConversationStore.getState().setCurrentConversation(conversationId);
|
|
82
|
+
}
|
|
83
|
+
return () => {
|
|
84
|
+
useConversationStore.getState().setCurrentConversation(undefined);
|
|
85
|
+
};
|
|
79
86
|
}, [conversationId]);
|
|
80
87
|
|
|
81
|
-
// useEffect(() => {
|
|
82
|
-
// if (!conversationId) return;
|
|
83
|
-
// ChatMessageAPI.searchLocalMessages(conversationId, { count: 20 })
|
|
84
|
-
// .then((result) => {
|
|
85
|
-
// console.log('[TEST searchLocalMessages] success:', result);
|
|
86
|
-
// })
|
|
87
|
-
// .catch((err) => {
|
|
88
|
-
// console.log('[TEST searchLocalMessages] error:', err);
|
|
89
|
-
// });
|
|
90
|
-
// }, [conversationId]);
|
|
91
|
-
|
|
92
|
-
const resolvedTitle = title ?? getConversationTitle(conversation);
|
|
93
|
-
const resolvedAvatarUri =
|
|
94
|
-
avatarUri ?? getConversationAvatarUri(conversation);
|
|
95
|
-
const resolvedAvatarFullName = avatarFullName ?? resolvedTitle;
|
|
96
88
|
const resolvedShowAddMember =
|
|
97
89
|
showAddMember ?? shouldShowAddMember(conversation);
|
|
98
|
-
const resolvedSubtitle = useMemo(() => {
|
|
99
|
-
if (subtitle !== undefined) return subtitle;
|
|
100
|
-
if (getSubtitle && conversation) return getSubtitle(conversation);
|
|
101
|
-
return getConversationSubtitle(conversation);
|
|
102
|
-
}, [conversation, getSubtitle, subtitle]);
|
|
103
90
|
|
|
104
91
|
const insets = useSafeAreaInsets();
|
|
105
92
|
|
|
@@ -123,51 +110,48 @@ const ChatDetail = memo(
|
|
|
123
110
|
);
|
|
124
111
|
|
|
125
112
|
return (
|
|
126
|
-
<
|
|
127
|
-
<
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
<
|
|
143
|
-
|
|
144
|
-
behavior="padding"
|
|
145
|
-
keyboardVerticalOffset={keyboardVerticalOffset}
|
|
146
|
-
>
|
|
147
|
-
<ChatListLegend
|
|
148
|
-
messages={messages}
|
|
149
|
-
currentUserId={currentUserId}
|
|
150
|
-
customMessageItemFactory={customMessageItemFactory}
|
|
151
|
-
onLoadEarlier={onLoadEarlier}
|
|
152
|
-
isLoading={isLoading}
|
|
153
|
-
isLoadingEarlier={isLoadingEarlier}
|
|
154
|
-
hasMoreEarlier={hasMoreEarlier}
|
|
155
|
-
onMediaPress={handleMediaPress}
|
|
156
|
-
onPressUrl={handlePressUrl}
|
|
157
|
-
onLongPress={handleMessageLongPress}
|
|
158
|
-
/>
|
|
159
|
-
|
|
160
|
-
<ChatComposer isEmptyMessage={messages?.length === 0} />
|
|
161
|
-
</KeyboardAvoidingView>
|
|
162
|
-
|
|
163
|
-
<MediaViewerModal ref={mediaViewerRef} />
|
|
164
|
-
<MessageToolboxOverlay
|
|
165
|
-
ref={messageToolboxRef}
|
|
113
|
+
<KContainer.Page flex edges={['bottom']}>
|
|
114
|
+
<ChatDetailHeader
|
|
115
|
+
conversationId={conversationId}
|
|
116
|
+
showAddMember={resolvedShowAddMember}
|
|
117
|
+
onBack={onBack ?? handleBackDefault}
|
|
118
|
+
onPressSearch={onPressSearch}
|
|
119
|
+
onPressAddMember={onPressAddMember}
|
|
120
|
+
onPressMenu={onPressMenu}
|
|
121
|
+
onPressAvatar={onPressAvatar}
|
|
122
|
+
/>
|
|
123
|
+
|
|
124
|
+
<KeyboardAvoidingView
|
|
125
|
+
style={styles.keyboardAvoiding}
|
|
126
|
+
behavior="padding"
|
|
127
|
+
keyboardVerticalOffset={keyboardVerticalOffset}
|
|
128
|
+
>
|
|
129
|
+
<ChatListLegend
|
|
130
|
+
messages={messages}
|
|
166
131
|
currentUserId={currentUserId}
|
|
167
132
|
customMessageItemFactory={customMessageItemFactory}
|
|
133
|
+
onLoadEarlier={onLoadEarlier}
|
|
134
|
+
isLoading={isLoading || isLoadingConversation}
|
|
135
|
+
isLoadingEarlier={isLoadingEarlier}
|
|
136
|
+
hasMoreEarlier={hasMoreEarlier}
|
|
137
|
+
onMediaPress={handleMediaPress}
|
|
138
|
+
onPressUrl={handlePressUrl}
|
|
139
|
+
onLongPress={handleMessageLongPress}
|
|
140
|
+
/>
|
|
141
|
+
|
|
142
|
+
<ChatComposer
|
|
143
|
+
isEmptyMessage={messages?.length === 0}
|
|
144
|
+
pannelActions={pannelActions}
|
|
168
145
|
/>
|
|
169
|
-
</
|
|
170
|
-
|
|
146
|
+
</KeyboardAvoidingView>
|
|
147
|
+
|
|
148
|
+
<MediaViewerModal ref={mediaViewerRef} />
|
|
149
|
+
<MessageToolboxOverlay
|
|
150
|
+
ref={messageToolboxRef}
|
|
151
|
+
currentUserId={currentUserId}
|
|
152
|
+
customMessageItemFactory={customMessageItemFactory}
|
|
153
|
+
/>
|
|
154
|
+
</KContainer.Page>
|
|
171
155
|
);
|
|
172
156
|
}
|
|
173
157
|
);
|
|
@@ -10,13 +10,10 @@ import { AvatarSection } from '../../components/ThreadCard/AvatarSection';
|
|
|
10
10
|
import { NamePrefixIcon } from '../../components/ThreadCard/NamePrefixIcon';
|
|
11
11
|
import type { ChatDetailHeaderProps } from './types';
|
|
12
12
|
import { useConversation } from '../../store';
|
|
13
|
+
import { getConversationSubtitle } from './conversationHeader.utils';
|
|
13
14
|
|
|
14
15
|
const ChatDetailHeader = memo(
|
|
15
16
|
({
|
|
16
|
-
title,
|
|
17
|
-
subtitle,
|
|
18
|
-
avatarUri,
|
|
19
|
-
avatarFullName,
|
|
20
17
|
showAddMember = false,
|
|
21
18
|
conversationId,
|
|
22
19
|
onBack,
|
|
@@ -79,8 +76,8 @@ const ChatDetailHeader = memo(
|
|
|
79
76
|
activeOpacity={0.7}
|
|
80
77
|
>
|
|
81
78
|
<AvatarSection
|
|
82
|
-
avatar={
|
|
83
|
-
fullName={
|
|
79
|
+
avatar={conversation?.faceURL ?? null}
|
|
80
|
+
fullName={conversation?.showName || ''}
|
|
84
81
|
peerType={conversation?.peerType}
|
|
85
82
|
/>
|
|
86
83
|
|
|
@@ -93,31 +90,23 @@ const ChatDetailHeader = memo(
|
|
|
93
90
|
numberOfLines={1}
|
|
94
91
|
flex
|
|
95
92
|
>
|
|
96
|
-
{
|
|
93
|
+
{conversation?.showName || ''}
|
|
97
94
|
</KLabel.Text>
|
|
98
95
|
</KContainer.View>
|
|
99
|
-
{!!
|
|
96
|
+
{!!conversation && (
|
|
100
97
|
<KLabel.Text
|
|
101
98
|
typo="TextSmNormal"
|
|
102
99
|
color={KColors.palette.gray.w500}
|
|
103
100
|
numberOfLines={1}
|
|
104
101
|
>
|
|
105
|
-
{
|
|
102
|
+
{getConversationSubtitle(conversation)}
|
|
106
103
|
</KLabel.Text>
|
|
107
104
|
)}
|
|
108
105
|
</KContainer.View>
|
|
109
106
|
</KContainer.Touchable>
|
|
110
107
|
</KContainer.View>
|
|
111
108
|
),
|
|
112
|
-
[
|
|
113
|
-
avatarFullName,
|
|
114
|
-
avatarUri,
|
|
115
|
-
onBack,
|
|
116
|
-
onPressAvatar,
|
|
117
|
-
subtitle,
|
|
118
|
-
title,
|
|
119
|
-
conversation?.peerType,
|
|
120
|
-
]
|
|
109
|
+
[onBack, onPressAvatar, conversation]
|
|
121
110
|
);
|
|
122
111
|
|
|
123
112
|
return (
|
|
@@ -374,7 +374,7 @@ export const ChatListLegend = memo(
|
|
|
374
374
|
renderItem={renderItem}
|
|
375
375
|
estimatedItemSize={avgItemHeightRef.current}
|
|
376
376
|
keyExtractor={(item) => String(item.clientMsgID || item.serverMsgID)}
|
|
377
|
-
recycleItems={
|
|
377
|
+
recycleItems={false}
|
|
378
378
|
extraData={`${conversationFlow?.flowCurrentStep?.id ?? ''}-${lastMessageId ?? ''}`}
|
|
379
379
|
alignItemsAtEnd
|
|
380
380
|
maintainVisibleContentPosition={maintainVisiblePositionConfig}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { memo } from 'react';
|
|
2
2
|
import { ActivityIndicator } from 'react-native';
|
|
3
3
|
import { KContainer, KColors } from '@droppii/libs';
|
|
4
|
-
import type { LoadEarlierMessagesProps } from 'react-native-gifted-chat';
|
|
5
4
|
|
|
6
5
|
export const ChatLoadEarlier = memo(
|
|
7
|
-
({ isLoading = false }:
|
|
6
|
+
({ isLoading = false }: { isLoading: boolean }) => {
|
|
8
7
|
if (!isLoading) {
|
|
9
8
|
return null;
|
|
10
9
|
}
|
|
@@ -8,7 +8,11 @@ import {
|
|
|
8
8
|
KSpacingValue,
|
|
9
9
|
} from '@droppii/libs';
|
|
10
10
|
import { useChatActionPress } from './useChatActionPress';
|
|
11
|
-
import
|
|
11
|
+
import {
|
|
12
|
+
type DChatQuickAction,
|
|
13
|
+
type ChatQuickActionsProps,
|
|
14
|
+
DChatQuickActionItemType,
|
|
15
|
+
} from './types';
|
|
12
16
|
import { useResetFlow } from '../../hooks/flows/useFlow';
|
|
13
17
|
|
|
14
18
|
const QuickActionItem = memo(
|
|
@@ -76,7 +80,7 @@ export const ChatQuickActions = memo(
|
|
|
76
80
|
({ item }) => {
|
|
77
81
|
const onPress = () => {
|
|
78
82
|
handleActionPress(item);
|
|
79
|
-
if (item.id ===
|
|
83
|
+
if (item.id === DChatQuickActionItemType.Restart) {
|
|
80
84
|
resetFlow?.();
|
|
81
85
|
}
|
|
82
86
|
};
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import { KColors } from '@droppii/libs';
|
|
2
|
-
import
|
|
2
|
+
import {
|
|
3
|
+
type DChatQuickAction,
|
|
4
|
+
type DChatPannelAction,
|
|
5
|
+
DChatQuickActionItemType,
|
|
6
|
+
DChatPannelActionItemType,
|
|
7
|
+
} from './types';
|
|
8
|
+
import { trans } from '../../translation';
|
|
3
9
|
import { opacityToSolid } from '../../utils/ui';
|
|
4
10
|
|
|
5
11
|
export const CHAT_BUBBLE_COLORS = {
|
|
@@ -10,19 +16,19 @@ export const CHAT_BUBBLE_COLORS = {
|
|
|
10
16
|
dayLabel: KColors.gray.light,
|
|
11
17
|
} as const;
|
|
12
18
|
|
|
13
|
-
export const
|
|
19
|
+
export const DEFAULT_QUICK_ACTIONS: DChatQuickAction[] = [
|
|
14
20
|
{
|
|
15
|
-
id:
|
|
21
|
+
id: DChatQuickActionItemType.Restart,
|
|
16
22
|
label: 'Bắt đầu lại',
|
|
17
23
|
iconName: 'refresh',
|
|
18
24
|
},
|
|
19
25
|
{
|
|
20
|
-
id:
|
|
26
|
+
id: DChatQuickActionItemType.SendOrder,
|
|
21
27
|
label: 'Gửi đơn hàng',
|
|
22
28
|
iconName: 'file-document-outline',
|
|
23
29
|
},
|
|
24
30
|
{
|
|
25
|
-
id:
|
|
31
|
+
id: DChatQuickActionItemType.ScamWarning,
|
|
26
32
|
label: 'Cảnh báo lừa đảo/g...',
|
|
27
33
|
iconName: 'alert-outline',
|
|
28
34
|
},
|
|
@@ -43,35 +49,35 @@ export const getAttachmentPanelHeight = (
|
|
|
43
49
|
/** @deprecated use getAttachmentPanelHeight */
|
|
44
50
|
export const DEFAULT_ATTACHMENT_PANEL_HEIGHT = getAttachmentPanelHeight(6);
|
|
45
51
|
|
|
46
|
-
export const
|
|
52
|
+
export const DEFAULT_PANNEL_ACTIONS: DChatPannelAction[] = [
|
|
47
53
|
{
|
|
48
|
-
id:
|
|
49
|
-
label: '
|
|
54
|
+
id: DChatPannelActionItemType.Gallery,
|
|
55
|
+
label: trans('gallery'),
|
|
50
56
|
iconName: 'image-02-o',
|
|
51
57
|
},
|
|
52
58
|
{
|
|
53
|
-
id:
|
|
54
|
-
label: '
|
|
59
|
+
id: DChatPannelActionItemType.Camera,
|
|
60
|
+
label: trans('camera'),
|
|
55
61
|
iconName: 'camera-o',
|
|
56
62
|
},
|
|
57
63
|
{
|
|
58
|
-
id:
|
|
59
|
-
label: '
|
|
64
|
+
id: DChatPannelActionItemType.Documents,
|
|
65
|
+
label: trans('documents'),
|
|
60
66
|
iconName: 'paperclip-o',
|
|
61
67
|
},
|
|
62
|
-
{
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
},
|
|
67
|
-
{
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
},
|
|
72
|
-
{
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
},
|
|
68
|
+
// {
|
|
69
|
+
// id: DChatPannelActionItemType.SendOrder,
|
|
70
|
+
// label: trans('send_order'),
|
|
71
|
+
// iconName: 'receipt-o',
|
|
72
|
+
// },
|
|
73
|
+
// {
|
|
74
|
+
// id: DChatPannelActionItemType.SendProduct,
|
|
75
|
+
// label: trans('send_product'),
|
|
76
|
+
// iconName: 'shopping-basket-o',
|
|
77
|
+
// },
|
|
78
|
+
// {
|
|
79
|
+
// id: DChatPannelActionItemType.CreateAppointment,
|
|
80
|
+
// label: trans('create_appointment'),
|
|
81
|
+
// iconName: 'calendar-active-o',
|
|
82
|
+
// },
|
|
77
83
|
];
|
|
@@ -4,8 +4,8 @@ export { ChatComposer } from './ChatComposer';
|
|
|
4
4
|
export { ChatQuickActions } from './ChatQuickActions';
|
|
5
5
|
export { ChatAttachmentPanel } from './ChatAttachmentPanel';
|
|
6
6
|
export {
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
DEFAULT_QUICK_ACTIONS,
|
|
8
|
+
DEFAULT_PANNEL_ACTIONS,
|
|
9
9
|
DEFAULT_ATTACHMENT_PANEL_HEIGHT,
|
|
10
10
|
} from './constants';
|
|
11
11
|
export {
|
|
@@ -18,17 +18,14 @@ export type {
|
|
|
18
18
|
DChatActionItem,
|
|
19
19
|
DChatActionIconProvider,
|
|
20
20
|
DChatQuickAction,
|
|
21
|
-
|
|
21
|
+
DChatPannelAction,
|
|
22
22
|
ChatDetailProps,
|
|
23
23
|
ChatDetailHeaderProps,
|
|
24
24
|
ChatListProps,
|
|
25
25
|
ChatComposerProps,
|
|
26
26
|
ChatQuickActionsProps,
|
|
27
27
|
ChatQuickActionsRenderParams,
|
|
28
|
-
|
|
28
|
+
ChatPanelProps,
|
|
29
29
|
} from './types';
|
|
30
30
|
|
|
31
|
-
export {
|
|
32
|
-
DChatMessageType,
|
|
33
|
-
CUSTOM_MESSAGE_DATA_TYPE,
|
|
34
|
-
} from '../../types/message';
|
|
31
|
+
export { DChatPannelActionItemType, DChatQuickActionItemType } from './types';
|
|
@@ -71,11 +71,7 @@ export const LegendChatMessage = memo(
|
|
|
71
71
|
const customNode = customMessageItemFactory?.(message);
|
|
72
72
|
|
|
73
73
|
if (customNode) {
|
|
74
|
-
return
|
|
75
|
-
<LongPressWrapper onLongPress={onLongPress}>
|
|
76
|
-
{customNode}
|
|
77
|
-
</LongPressWrapper>
|
|
78
|
-
);
|
|
74
|
+
return customNode;
|
|
79
75
|
}
|
|
80
76
|
|
|
81
77
|
const MessageComponent: ComponentType<MessageProps> =
|
|
@@ -1,13 +1,27 @@
|
|
|
1
1
|
import type { ReactNode } from 'react';
|
|
2
2
|
import type { MediaItem } from '../../hooks/useMediaViewer';
|
|
3
3
|
import type { DMessageItem } from '../../types/chat';
|
|
4
|
-
import type { ConversationItem } from '@droppii/openim-rn-client-sdk';
|
|
5
4
|
import type { MeasuredRect } from './messageToolbox/types';
|
|
6
5
|
|
|
7
6
|
export type DChatActionIconProvider = 'MaterialCommunityIcons' | 'DroppiiNew';
|
|
8
7
|
|
|
8
|
+
export enum DChatPannelActionItemType {
|
|
9
|
+
Gallery = 'Gallery',
|
|
10
|
+
Camera = 'Camera',
|
|
11
|
+
Documents = 'Documents',
|
|
12
|
+
SendOrder = 'SendOrder',
|
|
13
|
+
SendProduct = 'SendProduct',
|
|
14
|
+
CreateAppointment = 'CreateAppointment',
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export enum DChatQuickActionItemType {
|
|
18
|
+
Restart = 'Restart',
|
|
19
|
+
SendOrder = 'SendOrder',
|
|
20
|
+
ScamWarning = 'ScamWarning',
|
|
21
|
+
}
|
|
22
|
+
|
|
9
23
|
export interface DChatActionItem {
|
|
10
|
-
id:
|
|
24
|
+
id: DChatQuickActionItemType | DChatPannelActionItemType;
|
|
11
25
|
label: string;
|
|
12
26
|
iconName: string;
|
|
13
27
|
iconProvider?: DChatActionIconProvider;
|
|
@@ -16,14 +30,14 @@ export interface DChatActionItem {
|
|
|
16
30
|
meta?: Record<string, unknown>;
|
|
17
31
|
}
|
|
18
32
|
|
|
19
|
-
export
|
|
20
|
-
|
|
33
|
+
export interface DChatQuickAction extends DChatActionItem {
|
|
34
|
+
id: DChatQuickActionItemType;
|
|
35
|
+
}
|
|
36
|
+
export interface DChatPannelAction extends DChatActionItem {
|
|
37
|
+
id: DChatPannelActionItemType;
|
|
38
|
+
}
|
|
21
39
|
|
|
22
40
|
export interface ChatDetailHeaderProps {
|
|
23
|
-
title: string;
|
|
24
|
-
subtitle?: string;
|
|
25
|
-
avatarUri?: string | null;
|
|
26
|
-
avatarFullName?: string;
|
|
27
41
|
showAddMember?: boolean;
|
|
28
42
|
onBack?: () => void;
|
|
29
43
|
onPressSearch?: () => void;
|
|
@@ -46,14 +60,9 @@ export interface ChatQuickActionsProps {
|
|
|
46
60
|
renderQuickActions?: (params: ChatQuickActionsRenderParams) => ReactNode;
|
|
47
61
|
}
|
|
48
62
|
|
|
49
|
-
export interface
|
|
50
|
-
actions?:
|
|
63
|
+
export interface ChatPanelProps {
|
|
64
|
+
actions?: DChatPannelAction[];
|
|
51
65
|
columns?: number;
|
|
52
|
-
onActionPress?: (action: DChatAttachmentAction) => void;
|
|
53
|
-
renderAction?: (
|
|
54
|
-
action: DChatAttachmentAction,
|
|
55
|
-
onPress: () => void
|
|
56
|
-
) => ReactNode;
|
|
57
66
|
}
|
|
58
67
|
|
|
59
68
|
export interface ChatComposerProps {
|
|
@@ -78,22 +87,15 @@ export interface ChatListProps {
|
|
|
78
87
|
|
|
79
88
|
export interface ChatDetailProps extends Omit<
|
|
80
89
|
ChatDetailHeaderProps,
|
|
81
|
-
| '
|
|
82
|
-
| 'subtitle'
|
|
83
|
-
| 'avatarUri'
|
|
84
|
-
| 'avatarFullName'
|
|
85
|
-
| 'applicationType'
|
|
86
|
-
| 'showAddMember'
|
|
87
|
-
| 'conversationId'
|
|
90
|
+
'showAddMember' | 'conversationId'
|
|
88
91
|
> {
|
|
89
|
-
|
|
92
|
+
targetConversationId?: string;
|
|
93
|
+
targetUserId?: string;
|
|
94
|
+
targetGroupId?: string;
|
|
95
|
+
targetBotId?: string;
|
|
90
96
|
enabled?: boolean;
|
|
91
|
-
title?: string;
|
|
92
|
-
subtitle?: string;
|
|
93
|
-
avatarUri?: string | null;
|
|
94
|
-
avatarFullName?: string;
|
|
95
97
|
showAddMember?: boolean;
|
|
96
|
-
getSubtitle?: (conversation: ConversationItem) => string | undefined;
|
|
97
98
|
onPressUrl?: (url: string) => void;
|
|
98
99
|
customMessageItemFactory?: (item: DMessageItem) => ReactNode;
|
|
100
|
+
pannelActions?: DChatPannelAction[];
|
|
99
101
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ImageAttachment } from '../../types/attachment';
|
|
2
2
|
import type { IAttachmentHandler } from '../../types/attachmentHandler';
|
|
3
|
-
import { generateUUID } from '../../utils/imageUtils';
|
|
4
3
|
import { UPLOAD_LIMITS } from '../../config/uploadLimits';
|
|
4
|
+
import uuid from 'react-native-uuid';
|
|
5
5
|
|
|
6
6
|
export const ImageAttachmentHandler: IAttachmentHandler = {
|
|
7
7
|
validate(attachment: ImageAttachment) {
|
|
@@ -42,7 +42,7 @@ export const ImageAttachmentHandler: IAttachmentHandler = {
|
|
|
42
42
|
});
|
|
43
43
|
|
|
44
44
|
const picInfo = {
|
|
45
|
-
uuid:
|
|
45
|
+
uuid: uuid.v4(),
|
|
46
46
|
type: attachment.sourceFile.mimeType,
|
|
47
47
|
size: attachment.sourceFile.size,
|
|
48
48
|
width: attachment.metadata.width,
|
|
@@ -22,6 +22,10 @@ export const ENDPOINTS = {
|
|
|
22
22
|
`${getApiEndpoint('conversationFlow')}/${id}/bot-flows/reset`,
|
|
23
23
|
runConversationFlow: (id: string) =>
|
|
24
24
|
`${getApiEndpoint('conversationFlow')}/${id}/bot-flows/run`,
|
|
25
|
+
getConversationByBotId: (botId: string) =>
|
|
26
|
+
`${getApiEndpoint('bot')}/${botId}/conversation`,
|
|
27
|
+
conversationFlowMainMenu: (id: string) =>
|
|
28
|
+
`${getApiEndpoint('conversationFlow')}/${id}/bot-flows/main-menu`,
|
|
25
29
|
},
|
|
26
30
|
uploaderService: {
|
|
27
31
|
get uploadImage() {
|
|
@@ -6,7 +6,7 @@ type ConversationID = string;
|
|
|
6
6
|
|
|
7
7
|
export interface ConversationStore {
|
|
8
8
|
currentConversationId?: ConversationID;
|
|
9
|
-
setCurrentConversation(id
|
|
9
|
+
setCurrentConversation(id?: ConversationID): void;
|
|
10
10
|
getCurrentConversation(): ConversationItem | undefined;
|
|
11
11
|
list: ConversationID[];
|
|
12
12
|
map: Record<ConversationID, ConversationItem>;
|
|
@@ -45,13 +45,19 @@ const i18nKey: Record<string, string> = {
|
|
|
45
45
|
'chat:unmute_action': 'Bật thông báo',
|
|
46
46
|
'chat:mute_confirm_title': 'Tắt thông báo',
|
|
47
47
|
'chat:mute_confirm_desc':
|
|
48
|
-
'Bạn có thể bỏ lỡ tin nhắn quan trọng nếu tắt thông báo! Bạn có chắc chắn muốn tắt thông báo
|
|
48
|
+
'Bạn có thể bỏ lỡ tin nhắn quan trọng nếu tắt thông báo! Bạn có chắc chắn muốn <b>tắt thông báo</b>?',
|
|
49
49
|
'chat:mute_confirm_primary': 'Tắt thông báo',
|
|
50
50
|
'chat:mute_confirm_secondary': 'Quay lại',
|
|
51
51
|
'chat:mute_toast_success': 'Đã tắt thông báo',
|
|
52
52
|
'chat:unmute_toast_success': 'Đã bật thông báo',
|
|
53
53
|
'start': 'Bắt đầu',
|
|
54
54
|
'restart': 'Bắt đầu lại',
|
|
55
|
+
'gallery': 'Ảnh/Video',
|
|
56
|
+
'camera': 'Chụp ảnh',
|
|
57
|
+
'documents': 'Tài liệu',
|
|
58
|
+
'send_order': 'Gửi đơn hàng',
|
|
59
|
+
'send_product': 'Gửi sản phẩm',
|
|
60
|
+
'create_appointment': 'Tạo lịch hẹn',
|
|
55
61
|
};
|
|
56
62
|
|
|
57
63
|
export default {
|
package/src/types/chat.ts
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
type ConversationItem,
|
|
3
|
+
type MessageItem,
|
|
4
|
+
} from '@droppii/openim-rn-client-sdk';
|
|
2
5
|
import type { PropsWithChildren } from 'react';
|
|
3
6
|
import type { IUrlMetadata } from './common';
|
|
4
7
|
import type {
|
|
8
|
+
DFlowContext,
|
|
5
9
|
IConversationFlow,
|
|
6
10
|
IConversationFlowStep,
|
|
7
11
|
IRunConversationFlowPayload,
|
|
@@ -55,6 +59,11 @@ export enum DMemberRole {
|
|
|
55
59
|
MEMBER = 'MEMBER',
|
|
56
60
|
}
|
|
57
61
|
|
|
62
|
+
export enum DFlowState {
|
|
63
|
+
BOT = 1,
|
|
64
|
+
CS = 2,
|
|
65
|
+
}
|
|
66
|
+
|
|
58
67
|
export interface DConversationPeerUser {
|
|
59
68
|
id: string;
|
|
60
69
|
username?: string;
|
|
@@ -139,6 +148,9 @@ export interface ChatDetailContextType {
|
|
|
139
148
|
refetchConversationFlow: () => void;
|
|
140
149
|
isBotConversation: boolean;
|
|
141
150
|
setConverationFlowStep: (step?: IConversationFlowStep) => void;
|
|
151
|
+
flowState?: DFlowState;
|
|
152
|
+
runButtonContext: (stringContext: DFlowContext) => Promise<boolean>;
|
|
153
|
+
conversation?: ConversationItem;
|
|
142
154
|
}
|
|
143
155
|
|
|
144
156
|
export interface ChatDetailProviderProps extends PropsWithChildren {}
|
|
@@ -154,3 +166,21 @@ export interface IConversationItemEx {
|
|
|
154
166
|
};
|
|
155
167
|
chatCategory: DChatCategory;
|
|
156
168
|
}
|
|
169
|
+
|
|
170
|
+
export const CustomMessageType = {
|
|
171
|
+
Order: 'Order',
|
|
172
|
+
Product: 'Product',
|
|
173
|
+
} as const;
|
|
174
|
+
|
|
175
|
+
export type CustomMessageType =
|
|
176
|
+
(typeof CustomMessageType)[keyof typeof CustomMessageType];
|
|
177
|
+
|
|
178
|
+
export type CustomElemOrderData = {
|
|
179
|
+
id: string;
|
|
180
|
+
orderCode: string;
|
|
181
|
+
timestamp: number;
|
|
182
|
+
};
|
|
183
|
+
|
|
184
|
+
export type CustomMessagePayload =
|
|
185
|
+
| { type: typeof CustomMessageType.Order; data: CustomElemOrderData }
|
|
186
|
+
| { type: typeof CustomMessageType.Product; data: Record<string, unknown> };
|
package/src/types/flows.ts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import type { PeerType } from '@droppii/openim-rn-client-sdk';
|
|
2
2
|
import type { DChatApplicationType, DChatCategory } from './chat';
|
|
3
3
|
|
|
4
|
+
export enum DFlowContext {
|
|
5
|
+
CHAT_WITH_CS = 'chat_with_cs',
|
|
6
|
+
}
|
|
7
|
+
|
|
4
8
|
/** START NODE TYPE */
|
|
5
9
|
export const NodeTypes = {
|
|
6
10
|
BubbleText: 'bubble-text',
|
package/src/utils/device.ts
CHANGED