@droppii-org/chat-mobile 0.2.4 → 0.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/lib/module/components/ThreadCard/AvatarSection.js +4 -4
- package/lib/module/components/ThreadCard/AvatarSection.js.map +1 -1
- package/lib/module/components/ThreadCard/NamePrefixIcon.js +13 -16
- package/lib/module/components/ThreadCard/NamePrefixIcon.js.map +1 -1
- package/lib/module/components/ThreadCard/ThreadCard.js +13 -33
- package/lib/module/components/ThreadCard/ThreadCard.js.map +1 -1
- package/lib/module/config/feature-flags.js +38 -0
- package/lib/module/config/feature-flags.js.map +1 -0
- package/lib/module/context/ChatContext.js +7 -6
- package/lib/module/context/ChatContext.js.map +1 -1
- package/lib/module/hooks/message/useSendMessage.js +101 -0
- package/lib/module/hooks/message/useSendMessage.js.map +1 -0
- package/lib/module/hooks/query-keys.js +4 -0
- package/lib/module/hooks/query-keys.js.map +1 -1
- package/lib/module/hooks/useChatMessages.js +54 -91
- package/lib/module/hooks/useChatMessages.js.map +1 -1
- package/lib/module/hooks/useConversationList.js +29 -17
- package/lib/module/hooks/useConversationList.js.map +1 -1
- package/lib/module/hooks/useLinkPreview/useFetchUrlMetadata.js +17 -0
- package/lib/module/hooks/useLinkPreview/useFetchUrlMetadata.js.map +1 -0
- package/lib/module/hooks/useLinkPreview/useLinkPreview.js +35 -0
- package/lib/module/hooks/useLinkPreview/useLinkPreview.js.map +1 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/screens/chat-detail/ChatComposer.js +20 -4
- package/lib/module/screens/chat-detail/ChatComposer.js.map +1 -1
- package/lib/module/screens/chat-detail/ChatDetail.js +116 -22
- package/lib/module/screens/chat-detail/ChatDetail.js.map +1 -1
- package/lib/module/screens/chat-detail/ChatDetailHeader.js +5 -8
- package/lib/module/screens/chat-detail/ChatDetailHeader.js.map +1 -1
- package/lib/module/screens/chat-detail/ChatLinkPreview.js +79 -0
- package/lib/module/screens/chat-detail/ChatLinkPreview.js.map +1 -0
- package/lib/module/screens/chat-detail/ChatList.js +2 -0
- package/lib/module/screens/chat-detail/ChatList.js.map +1 -1
- package/lib/module/screens/chat-detail/ChatListLegend.js +350 -0
- package/lib/module/screens/chat-detail/ChatListLegend.js.map +1 -0
- package/lib/module/screens/chat-detail/ChatQuickActions.js +12 -2
- package/lib/module/screens/chat-detail/ChatQuickActions.js.map +1 -1
- package/lib/module/screens/chat-detail/conversationHeader.utils.js +29 -0
- package/lib/module/screens/chat-detail/conversationHeader.utils.js.map +1 -0
- package/lib/module/screens/chat-detail/index.js +1 -0
- package/lib/module/screens/chat-detail/index.js.map +1 -1
- package/lib/module/screens/chat-detail/legend/LegendChatDay.js +57 -0
- package/lib/module/screens/chat-detail/legend/LegendChatDay.js.map +1 -0
- package/lib/module/screens/chat-detail/legend/LegendChatLoadEarlier.js +21 -0
- package/lib/module/screens/chat-detail/legend/LegendChatLoadEarlier.js.map +1 -0
- package/lib/module/screens/chat-detail/legend/LegendChatMessage.js +34 -0
- package/lib/module/screens/chat-detail/legend/LegendChatMessage.js.map +1 -0
- package/lib/module/screens/chat-detail/legend/LegendChatScrollToBottom.js +58 -0
- package/lib/module/screens/chat-detail/legend/LegendChatScrollToBottom.js.map +1 -0
- package/lib/module/screens/chat-detail/legend/message-types.js +244 -0
- package/lib/module/screens/chat-detail/legend/message-types.js.map +1 -0
- package/lib/module/screens/chat-detail/messages/ChatMessageBubble.js.map +1 -1
- package/lib/module/services/apis.js +1 -1
- package/lib/module/services/apis.js.map +1 -1
- package/lib/module/services/endpoints.js +8 -0
- package/lib/module/services/endpoints.js.map +1 -0
- package/lib/module/store/conversation.js +1 -1
- package/lib/module/store/conversation.js.map +1 -1
- package/lib/module/store/message.js +45 -0
- package/lib/module/store/message.js.map +1 -0
- package/lib/module/translation/resources/i18n.js +7 -1
- package/lib/module/translation/resources/i18n.js.map +1 -1
- package/lib/module/types/chat.js +2 -7
- package/lib/module/types/chat.js.map +1 -1
- package/lib/module/types/common.js +2 -0
- package/lib/module/types/common.js.map +1 -0
- package/lib/module/utils/conversation.js +34 -13
- package/lib/module/utils/conversation.js.map +1 -1
- package/lib/module/utils/legendListMessage.js +77 -0
- package/lib/module/utils/legendListMessage.js.map +1 -0
- package/lib/module/utils/message.js +5 -8
- package/lib/module/utils/message.js.map +1 -1
- package/lib/module/utils/url.js +7 -0
- package/lib/module/utils/url.js.map +1 -0
- package/lib/typescript/src/components/Avatar/Avatar.d.ts +1 -1
- package/lib/typescript/src/components/Avatar/Avatar.d.ts.map +1 -1
- package/lib/typescript/src/components/Avatar/AvatarBadge.d.ts +1 -1
- package/lib/typescript/src/components/Avatar/AvatarBadge.d.ts.map +1 -1
- package/lib/typescript/src/components/Avatar/DoubleAvatar.d.ts +1 -1
- package/lib/typescript/src/components/Avatar/DoubleAvatar.d.ts.map +1 -1
- package/lib/typescript/src/components/Avatar/SingleAvatar.d.ts +1 -1
- package/lib/typescript/src/components/Avatar/SingleAvatar.d.ts.map +1 -1
- package/lib/typescript/src/components/ThreadCard/AvatarSection.d.ts +2 -2
- package/lib/typescript/src/components/ThreadCard/AvatarSection.d.ts.map +1 -1
- package/lib/typescript/src/components/ThreadCard/NamePrefixIcon.d.ts +3 -4
- package/lib/typescript/src/components/ThreadCard/NamePrefixIcon.d.ts.map +1 -1
- package/lib/typescript/src/components/ThreadCard/ThreadCard.d.ts +1 -1
- package/lib/typescript/src/components/ThreadCard/ThreadCard.d.ts.map +1 -1
- package/lib/typescript/src/components/ThreadCard/UnreadBadge.d.ts +1 -1
- package/lib/typescript/src/components/ThreadCard/UnreadBadge.d.ts.map +1 -1
- package/lib/typescript/src/config/feature-flags.d.ts +12 -0
- package/lib/typescript/src/config/feature-flags.d.ts.map +1 -0
- package/lib/typescript/src/context/ChatContext.d.ts +1 -1
- package/lib/typescript/src/context/ChatContext.d.ts.map +1 -1
- package/lib/typescript/src/hooks/message/useSendMessage.d.ts +12 -0
- package/lib/typescript/src/hooks/message/useSendMessage.d.ts.map +1 -0
- 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/useChatMessages.d.ts +3 -1
- package/lib/typescript/src/hooks/useChatMessages.d.ts.map +1 -1
- package/lib/typescript/src/hooks/useConversationList.d.ts +2 -1
- package/lib/typescript/src/hooks/useConversationList.d.ts.map +1 -1
- package/lib/typescript/src/hooks/useLinkPreview/useFetchUrlMetadata.d.ts +3 -0
- package/lib/typescript/src/hooks/useLinkPreview/useFetchUrlMetadata.d.ts.map +1 -0
- package/lib/typescript/src/hooks/useLinkPreview/useLinkPreview.d.ts +7 -0
- package/lib/typescript/src/hooks/useLinkPreview/useLinkPreview.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +1 -1
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/screens/chat-detail/ChatAttachmentPanel.d.ts +1 -1
- package/lib/typescript/src/screens/chat-detail/ChatAttachmentPanel.d.ts.map +1 -1
- package/lib/typescript/src/screens/chat-detail/ChatComposer.d.ts +1 -1
- package/lib/typescript/src/screens/chat-detail/ChatComposer.d.ts.map +1 -1
- package/lib/typescript/src/screens/chat-detail/ChatDay.d.ts +1 -1
- package/lib/typescript/src/screens/chat-detail/ChatDay.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/ChatLinkPreview.d.ts +9 -0
- package/lib/typescript/src/screens/chat-detail/ChatLinkPreview.d.ts.map +1 -0
- package/lib/typescript/src/screens/chat-detail/ChatList.d.ts +1 -1
- package/lib/typescript/src/screens/chat-detail/ChatList.d.ts.map +1 -1
- package/lib/typescript/src/screens/chat-detail/ChatListLegend.d.ts +3 -0
- package/lib/typescript/src/screens/chat-detail/ChatListLegend.d.ts.map +1 -0
- package/lib/typescript/src/screens/chat-detail/ChatLoadEarlier.d.ts +1 -1
- 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/ChatScrollToBottom.d.ts +1 -1
- package/lib/typescript/src/screens/chat-detail/ChatScrollToBottom.d.ts.map +1 -1
- package/lib/typescript/src/screens/chat-detail/ChatTextBubble.d.ts +1 -1
- package/lib/typescript/src/screens/chat-detail/ChatTextBubble.d.ts.map +1 -1
- package/lib/typescript/src/screens/chat-detail/conversationHeader.utils.d.ts +6 -0
- package/lib/typescript/src/screens/chat-detail/conversationHeader.utils.d.ts.map +1 -0
- package/lib/typescript/src/screens/chat-detail/index.d.ts +2 -1
- package/lib/typescript/src/screens/chat-detail/index.d.ts.map +1 -1
- package/lib/typescript/src/screens/chat-detail/legend/LegendChatDay.d.ts +6 -0
- package/lib/typescript/src/screens/chat-detail/legend/LegendChatDay.d.ts.map +1 -0
- package/lib/typescript/src/screens/chat-detail/legend/LegendChatLoadEarlier.d.ts +6 -0
- package/lib/typescript/src/screens/chat-detail/legend/LegendChatLoadEarlier.d.ts.map +1 -0
- package/lib/typescript/src/screens/chat-detail/legend/LegendChatMessage.d.ts +13 -0
- package/lib/typescript/src/screens/chat-detail/legend/LegendChatMessage.d.ts.map +1 -0
- package/lib/typescript/src/screens/chat-detail/legend/LegendChatScrollToBottom.d.ts +6 -0
- package/lib/typescript/src/screens/chat-detail/legend/LegendChatScrollToBottom.d.ts.map +1 -0
- package/lib/typescript/src/screens/chat-detail/legend/message-types.d.ts +13 -0
- package/lib/typescript/src/screens/chat-detail/legend/message-types.d.ts.map +1 -0
- package/lib/typescript/src/screens/chat-detail/messages/ChatMessageBubble.d.ts +1 -1
- package/lib/typescript/src/screens/chat-detail/messages/ChatMessageBubble.d.ts.map +1 -1
- package/lib/typescript/src/screens/chat-detail/types.d.ts +33 -7
- package/lib/typescript/src/screens/chat-detail/types.d.ts.map +1 -1
- package/lib/typescript/src/screens/inbox/Inbox.d.ts +1 -1
- package/lib/typescript/src/screens/inbox/Inbox.d.ts.map +1 -1
- package/lib/typescript/src/screens/inbox/MessagesTab.d.ts +1 -1
- package/lib/typescript/src/screens/inbox/MessagesTab.d.ts.map +1 -1
- package/lib/typescript/src/services/apis.d.ts +1 -0
- package/lib/typescript/src/services/apis.d.ts.map +1 -1
- package/lib/typescript/src/services/endpoints.d.ts +6 -0
- package/lib/typescript/src/services/endpoints.d.ts.map +1 -0
- package/lib/typescript/src/store/message.d.ts +3 -0
- package/lib/typescript/src/store/message.d.ts.map +1 -0
- package/lib/typescript/src/translation/resources/i18n.d.ts.map +1 -1
- package/lib/typescript/src/types/chat.d.ts +28 -27
- package/lib/typescript/src/types/chat.d.ts.map +1 -1
- package/lib/typescript/src/types/common.d.ts +7 -0
- package/lib/typescript/src/types/common.d.ts.map +1 -0
- package/lib/typescript/src/utils/conversation.d.ts +3 -2
- package/lib/typescript/src/utils/conversation.d.ts.map +1 -1
- package/lib/typescript/src/utils/legendListMessage.d.ts +23 -0
- package/lib/typescript/src/utils/legendListMessage.d.ts.map +1 -0
- package/lib/typescript/src/utils/message.d.ts.map +1 -1
- package/lib/typescript/src/utils/url.d.ts +2 -0
- package/lib/typescript/src/utils/url.d.ts.map +1 -0
- package/package.json +5 -3
- package/src/components/ThreadCard/AvatarSection.tsx +5 -8
- package/src/components/ThreadCard/NamePrefixIcon.tsx +27 -38
- package/src/components/ThreadCard/ThreadCard.tsx +16 -30
- package/src/config/feature-flags.ts +49 -0
- package/src/context/ChatContext.tsx +12 -4
- package/src/hooks/message/useSendMessage.ts +136 -0
- package/src/hooks/query-keys.ts +5 -0
- package/src/hooks/useChatMessages.ts +90 -118
- package/src/hooks/useConversationList.ts +34 -16
- package/src/hooks/useLinkPreview/useFetchUrlMetadata.ts +18 -0
- package/src/hooks/useLinkPreview/useLinkPreview.ts +31 -0
- package/src/index.tsx +1 -0
- package/src/screens/chat-detail/ChatComposer.tsx +23 -2
- package/src/screens/chat-detail/ChatDetail.tsx +163 -30
- package/src/screens/chat-detail/ChatDetailHeader.tsx +4 -10
- package/src/screens/chat-detail/ChatLinkPreview.tsx +86 -0
- package/src/screens/chat-detail/ChatList.tsx +3 -0
- package/src/screens/chat-detail/ChatListLegend.tsx +403 -0
- package/src/screens/chat-detail/ChatQuickActions.tsx +19 -2
- package/src/screens/chat-detail/conversationHeader.utils.ts +49 -0
- package/src/screens/chat-detail/index.ts +7 -0
- package/src/screens/chat-detail/legend/LegendChatDay.tsx +70 -0
- package/src/screens/chat-detail/legend/LegendChatLoadEarlier.tsx +21 -0
- package/src/screens/chat-detail/legend/LegendChatMessage.tsx +48 -0
- package/src/screens/chat-detail/legend/LegendChatScrollToBottom.tsx +56 -0
- package/src/screens/chat-detail/legend/message-types.tsx +304 -0
- package/src/screens/chat-detail/messages/ChatMessageBubble.tsx +0 -1
- package/src/screens/chat-detail/types.ts +45 -7
- package/src/services/apis.ts +1 -1
- package/src/services/endpoints.ts +5 -0
- package/src/store/conversation.ts +1 -1
- package/src/store/message.ts +44 -0
- package/src/translation/resources/i18n.ts +6 -0
- package/src/types/chat.ts +31 -30
- package/src/types/common.ts +6 -0
- package/src/utils/conversation.ts +44 -17
- package/src/utils/legendListMessage.ts +97 -0
- package/src/utils/message.ts +10 -12
- package/src/utils/url.ts +5 -0
|
@@ -1,50 +1,143 @@
|
|
|
1
|
-
import { memo, useState, useCallback } from 'react';
|
|
1
|
+
import { memo, useState, useCallback, useEffect, useMemo } from 'react';
|
|
2
2
|
import { Platform, StyleSheet } from 'react-native';
|
|
3
|
+
|
|
3
4
|
import { KeyboardAvoidingView } from 'react-native-keyboard-controller';
|
|
4
5
|
import { useSafeAreaInsets } from 'react-native-safe-area-context';
|
|
5
6
|
import { KContainer } from '@droppii/libs';
|
|
7
|
+
import { useChatMessages } from '../../hooks/useChatMessages';
|
|
8
|
+
import { useConversation, useConversationStore } from '../../store';
|
|
6
9
|
import ChatDetailHeader from './ChatDetailHeader';
|
|
7
10
|
import { ChatList } from './ChatList';
|
|
11
|
+
import { ChatListLegend } from './ChatListLegend';
|
|
8
12
|
import { ChatComposer } from './ChatComposer';
|
|
13
|
+
import {
|
|
14
|
+
DEFAULT_ATTACHMENT_ACTIONS,
|
|
15
|
+
DEFAULT_Chat_QUICK_ACTIONS,
|
|
16
|
+
} from './constants';
|
|
17
|
+
import {
|
|
18
|
+
getConversationAvatarUri,
|
|
19
|
+
getConversationSubtitle,
|
|
20
|
+
getConversationTitle,
|
|
21
|
+
shouldShowAddMember,
|
|
22
|
+
} from './conversationHeader.utils';
|
|
23
|
+
import { getFeatureFlag, onFlagsChange } from '../../config/feature-flags';
|
|
9
24
|
import type { ChatDetailProps } from './types';
|
|
25
|
+
import { useSendMessage } from '../../hooks/message/useSendMessage';
|
|
26
|
+
import type { IUrlMetadata } from '../../types/common';
|
|
10
27
|
|
|
11
28
|
const ChatDetail = memo(
|
|
12
29
|
({
|
|
30
|
+
conversationId,
|
|
31
|
+
enabled = true,
|
|
13
32
|
title,
|
|
14
33
|
subtitle,
|
|
15
34
|
avatarUri,
|
|
16
35
|
avatarFullName,
|
|
17
|
-
|
|
18
|
-
chatCategory,
|
|
36
|
+
peerType,
|
|
19
37
|
applicationType,
|
|
20
38
|
showAddMember,
|
|
39
|
+
getSubtitle,
|
|
21
40
|
onBack,
|
|
22
41
|
onPressSearch,
|
|
23
42
|
onPressAddMember,
|
|
24
43
|
onPressMenu,
|
|
25
44
|
onPressAvatar,
|
|
26
|
-
messages = [],
|
|
27
|
-
currentUserId,
|
|
28
45
|
renderChat,
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
isLoadingEarlier,
|
|
32
|
-
hasMoreEarlier,
|
|
46
|
+
showQuickActions = true,
|
|
47
|
+
showAttachmentActions = true,
|
|
33
48
|
quickActions,
|
|
49
|
+
getQuickActions,
|
|
34
50
|
inputValue,
|
|
35
51
|
inputPlaceholder,
|
|
36
52
|
onChangeInput,
|
|
37
|
-
onSend,
|
|
38
53
|
onPressAttach,
|
|
39
54
|
onPressEmoji,
|
|
40
55
|
attachmentActions,
|
|
41
56
|
onQuickActionPress,
|
|
42
57
|
onAttachmentAction,
|
|
43
58
|
renderQuickAction,
|
|
59
|
+
renderQuickActions,
|
|
44
60
|
renderAttachmentAction,
|
|
45
61
|
attachmentColumns,
|
|
46
62
|
}: ChatDetailProps) => {
|
|
47
63
|
const [internalInput, setInternalInput] = useState('');
|
|
64
|
+
const conversation = useConversation(conversationId);
|
|
65
|
+
|
|
66
|
+
const { sendMessage } = useSendMessage();
|
|
67
|
+
|
|
68
|
+
const {
|
|
69
|
+
messages,
|
|
70
|
+
currentUserId,
|
|
71
|
+
onLoadEarlier,
|
|
72
|
+
isLoading,
|
|
73
|
+
isLoadingEarlier,
|
|
74
|
+
hasMoreEarlier,
|
|
75
|
+
} = useChatMessages({
|
|
76
|
+
conversationId,
|
|
77
|
+
enabled,
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
useEffect(() => {
|
|
81
|
+
useConversationStore.getState().setCurrentConversation(conversationId);
|
|
82
|
+
}, [conversationId]);
|
|
83
|
+
|
|
84
|
+
const resolvedTitle = title ?? getConversationTitle(conversation);
|
|
85
|
+
const resolvedAvatarUri =
|
|
86
|
+
avatarUri ?? getConversationAvatarUri(conversation);
|
|
87
|
+
const resolvedAvatarFullName = avatarFullName ?? resolvedTitle;
|
|
88
|
+
const resolvedPeerType = peerType ?? conversation?.peerType;
|
|
89
|
+
const resolvedApplicationType =
|
|
90
|
+
applicationType ?? conversation?.applicationType;
|
|
91
|
+
const resolvedShowAddMember =
|
|
92
|
+
showAddMember ?? shouldShowAddMember(conversation);
|
|
93
|
+
const resolvedSubtitle = useMemo(() => {
|
|
94
|
+
if (subtitle !== undefined) {
|
|
95
|
+
return subtitle;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
if (getSubtitle && conversation) {
|
|
99
|
+
return getSubtitle(conversation);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
return getConversationSubtitle(conversation);
|
|
103
|
+
}, [conversation, getSubtitle, subtitle]);
|
|
104
|
+
|
|
105
|
+
const resolvedQuickActions = useMemo(() => {
|
|
106
|
+
if (!showQuickActions) {
|
|
107
|
+
return undefined;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
if (quickActions) {
|
|
111
|
+
return quickActions;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
if (getQuickActions && conversation) {
|
|
115
|
+
return getQuickActions(conversation);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
return DEFAULT_Chat_QUICK_ACTIONS;
|
|
119
|
+
}, [conversation, getQuickActions, quickActions, showQuickActions]);
|
|
120
|
+
|
|
121
|
+
const resolvedAttachmentActions = useMemo(() => {
|
|
122
|
+
if (!showAttachmentActions) {
|
|
123
|
+
return undefined;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
return attachmentActions ?? DEFAULT_ATTACHMENT_ACTIONS;
|
|
127
|
+
}, [attachmentActions, showAttachmentActions]);
|
|
128
|
+
const [variant, setVariant] = useState<'gifted' | 'legend'>(
|
|
129
|
+
() => getFeatureFlag('CHAT_LIST_VARIANT') as 'gifted' | 'legend'
|
|
130
|
+
);
|
|
131
|
+
|
|
132
|
+
useEffect(() => {
|
|
133
|
+
const unsubscribe = onFlagsChange(() => {
|
|
134
|
+
const newVariant = getFeatureFlag('CHAT_LIST_VARIANT') as
|
|
135
|
+
| 'gifted'
|
|
136
|
+
| 'legend';
|
|
137
|
+
setVariant(newVariant);
|
|
138
|
+
});
|
|
139
|
+
return unsubscribe;
|
|
140
|
+
}, []);
|
|
48
141
|
|
|
49
142
|
const handleChangeInput = useCallback(
|
|
50
143
|
(text: string) => {
|
|
@@ -58,19 +151,45 @@ const ChatDetail = memo(
|
|
|
58
151
|
);
|
|
59
152
|
|
|
60
153
|
const currentInput = inputValue ?? internalInput;
|
|
154
|
+
|
|
155
|
+
const handleSend = useCallback(
|
|
156
|
+
async (urlMetadata?: IUrlMetadata) => {
|
|
157
|
+
const text = currentInput.trim();
|
|
158
|
+
if (!text) {
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
try {
|
|
163
|
+
await sendMessage({
|
|
164
|
+
files: [],
|
|
165
|
+
plainText: text,
|
|
166
|
+
urlMetadata,
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
if (onChangeInput) {
|
|
170
|
+
onChangeInput('');
|
|
171
|
+
} else {
|
|
172
|
+
setInternalInput('');
|
|
173
|
+
}
|
|
174
|
+
} catch (error) {
|
|
175
|
+
console.error('[send-message]', error);
|
|
176
|
+
}
|
|
177
|
+
},
|
|
178
|
+
[currentInput, onChangeInput, sendMessage]
|
|
179
|
+
);
|
|
180
|
+
|
|
61
181
|
const insets = useSafeAreaInsets();
|
|
62
182
|
|
|
63
183
|
return (
|
|
64
184
|
<KContainer.Page flex edges={['bottom']}>
|
|
65
185
|
<ChatDetailHeader
|
|
66
|
-
title={
|
|
67
|
-
subtitle={
|
|
68
|
-
avatarUri={
|
|
69
|
-
avatarFullName={
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
showAddMember={showAddMember}
|
|
186
|
+
title={resolvedTitle}
|
|
187
|
+
subtitle={resolvedSubtitle}
|
|
188
|
+
avatarUri={resolvedAvatarUri}
|
|
189
|
+
avatarFullName={resolvedAvatarFullName}
|
|
190
|
+
peerType={resolvedPeerType}
|
|
191
|
+
applicationType={resolvedApplicationType}
|
|
192
|
+
showAddMember={resolvedShowAddMember}
|
|
74
193
|
onBack={onBack}
|
|
75
194
|
onPressSearch={onPressSearch}
|
|
76
195
|
onPressAddMember={onPressAddMember}
|
|
@@ -86,28 +205,42 @@ const ChatDetail = memo(
|
|
|
86
205
|
default: 0,
|
|
87
206
|
})}
|
|
88
207
|
>
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
208
|
+
{variant === 'legend' ? (
|
|
209
|
+
<ChatListLegend
|
|
210
|
+
messages={messages}
|
|
211
|
+
currentUserId={currentUserId}
|
|
212
|
+
renderChat={renderChat}
|
|
213
|
+
onLoadEarlier={onLoadEarlier}
|
|
214
|
+
isLoading={isLoading}
|
|
215
|
+
isLoadingEarlier={isLoadingEarlier}
|
|
216
|
+
hasMoreEarlier={hasMoreEarlier}
|
|
217
|
+
/>
|
|
218
|
+
) : (
|
|
219
|
+
<ChatList
|
|
220
|
+
messages={messages}
|
|
221
|
+
currentUserId={currentUserId}
|
|
222
|
+
renderChat={renderChat}
|
|
223
|
+
onLoadEarlier={onLoadEarlier}
|
|
224
|
+
isLoading={isLoading}
|
|
225
|
+
isLoadingEarlier={isLoadingEarlier}
|
|
226
|
+
hasMoreEarlier={hasMoreEarlier}
|
|
227
|
+
/>
|
|
228
|
+
)}
|
|
98
229
|
|
|
99
230
|
<ChatComposer
|
|
100
231
|
value={currentInput}
|
|
101
232
|
placeholder={inputPlaceholder}
|
|
102
233
|
onChangeText={handleChangeInput}
|
|
103
|
-
onSend={
|
|
234
|
+
onSend={handleSend}
|
|
104
235
|
onPressAttach={onPressAttach}
|
|
105
236
|
onPressEmoji={onPressEmoji}
|
|
106
|
-
|
|
107
|
-
|
|
237
|
+
showQuickActions={showQuickActions}
|
|
238
|
+
quickActions={resolvedQuickActions}
|
|
239
|
+
attachmentActions={resolvedAttachmentActions}
|
|
108
240
|
onQuickActionPress={onQuickActionPress}
|
|
109
241
|
onAttachmentAction={onAttachmentAction}
|
|
110
242
|
renderQuickAction={renderQuickAction}
|
|
243
|
+
renderQuickActions={renderQuickActions}
|
|
111
244
|
renderAttachmentAction={renderAttachmentAction}
|
|
112
245
|
attachmentColumns={attachmentColumns}
|
|
113
246
|
/>
|
|
@@ -16,8 +16,7 @@ const ChatDetailHeader = memo(
|
|
|
16
16
|
subtitle,
|
|
17
17
|
avatarUri,
|
|
18
18
|
avatarFullName,
|
|
19
|
-
|
|
20
|
-
chatCategory,
|
|
19
|
+
peerType,
|
|
21
20
|
applicationType,
|
|
22
21
|
showAddMember = false,
|
|
23
22
|
onBack,
|
|
@@ -81,17 +80,13 @@ const ChatDetailHeader = memo(
|
|
|
81
80
|
<AvatarSection
|
|
82
81
|
avatar={avatarUri ?? null}
|
|
83
82
|
fullName={avatarFullName ?? title}
|
|
84
|
-
|
|
83
|
+
peerType={peerType}
|
|
85
84
|
applicationType={applicationType}
|
|
86
|
-
chatType={chatType}
|
|
87
85
|
/>
|
|
88
86
|
|
|
89
87
|
<KContainer.View flex marginL="0.5rem">
|
|
90
88
|
<KContainer.View row alignItems>
|
|
91
|
-
<NamePrefixIcon
|
|
92
|
-
chatCategory={chatCategory}
|
|
93
|
-
chatType={chatType}
|
|
94
|
-
/>
|
|
89
|
+
<NamePrefixIcon peerType={peerType} />
|
|
95
90
|
<KLabel.Text
|
|
96
91
|
typo="TextLgBold"
|
|
97
92
|
color={KColors.gray.dark}
|
|
@@ -117,9 +112,8 @@ const ChatDetailHeader = memo(
|
|
|
117
112
|
[
|
|
118
113
|
avatarFullName,
|
|
119
114
|
avatarUri,
|
|
120
|
-
|
|
115
|
+
peerType,
|
|
121
116
|
applicationType,
|
|
122
|
-
chatType,
|
|
123
117
|
onBack,
|
|
124
118
|
onPressAvatar,
|
|
125
119
|
subtitle,
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { memo } from 'react';
|
|
2
|
+
import { ActivityIndicator, StyleSheet } from 'react-native';
|
|
3
|
+
import {
|
|
4
|
+
KContainer,
|
|
5
|
+
KImage,
|
|
6
|
+
KLabel,
|
|
7
|
+
KColors,
|
|
8
|
+
KSpacingValue,
|
|
9
|
+
KDims,
|
|
10
|
+
} from '@droppii/libs';
|
|
11
|
+
import type { IUrlMetadata } from '../../types/common';
|
|
12
|
+
|
|
13
|
+
interface ChatLinkPreviewProps {
|
|
14
|
+
metadata?: IUrlMetadata;
|
|
15
|
+
isLoading?: boolean;
|
|
16
|
+
onDismiss?: () => void;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const HEIGHT = 51;
|
|
20
|
+
|
|
21
|
+
export const ChatLinkPreview = memo(
|
|
22
|
+
({ metadata, isLoading, onDismiss }: ChatLinkPreviewProps) => {
|
|
23
|
+
return (
|
|
24
|
+
<KContainer.View style={styles.container}>
|
|
25
|
+
<KContainer.View style={styles.left}>
|
|
26
|
+
{isLoading ? (
|
|
27
|
+
<ActivityIndicator color={KColors.primary.normal} size={16} />
|
|
28
|
+
) : metadata?.image ? (
|
|
29
|
+
<KImage.Base uri={metadata?.image} width={HEIGHT} height={HEIGHT} />
|
|
30
|
+
) : (
|
|
31
|
+
<KImage.VectorIcons
|
|
32
|
+
name="link-alt-o"
|
|
33
|
+
color={KColors.primary.normal}
|
|
34
|
+
/>
|
|
35
|
+
)}
|
|
36
|
+
</KContainer.View>
|
|
37
|
+
<KContainer.View style={styles.center}>
|
|
38
|
+
<KLabel.Text typo="TextNmMedium" numberOfLines={1}>
|
|
39
|
+
{metadata?.title}
|
|
40
|
+
</KLabel.Text>
|
|
41
|
+
<KLabel.Text
|
|
42
|
+
typo="TextSmNormal"
|
|
43
|
+
color={KColors.gray.light}
|
|
44
|
+
numberOfLines={1}
|
|
45
|
+
>
|
|
46
|
+
{metadata?.description}
|
|
47
|
+
</KLabel.Text>
|
|
48
|
+
</KContainer.View>
|
|
49
|
+
<KContainer.Touchable onPress={onDismiss} style={styles.right}>
|
|
50
|
+
<KImage.VectorIcons name="close-o" size={16} />
|
|
51
|
+
</KContainer.Touchable>
|
|
52
|
+
</KContainer.View>
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
);
|
|
56
|
+
|
|
57
|
+
ChatLinkPreview.displayName = 'ChatLinkPreview';
|
|
58
|
+
|
|
59
|
+
const styles = StyleSheet.create({
|
|
60
|
+
container: {
|
|
61
|
+
position: 'absolute',
|
|
62
|
+
flexDirection: 'row',
|
|
63
|
+
flex: 1,
|
|
64
|
+
width: KDims.width,
|
|
65
|
+
alignItems: 'center',
|
|
66
|
+
gap: KSpacingValue['0.5rem'],
|
|
67
|
+
backgroundColor: KColors.palette.blue.w25,
|
|
68
|
+
height: HEIGHT,
|
|
69
|
+
top: -HEIGHT,
|
|
70
|
+
zIndex: 10000,
|
|
71
|
+
},
|
|
72
|
+
left: {
|
|
73
|
+
width: HEIGHT,
|
|
74
|
+
height: HEIGHT,
|
|
75
|
+
justifyContent: 'center',
|
|
76
|
+
alignItems: 'center',
|
|
77
|
+
},
|
|
78
|
+
center: {
|
|
79
|
+
flex: 1,
|
|
80
|
+
},
|
|
81
|
+
right: {
|
|
82
|
+
paddingRight: KSpacingValue['0.5rem'],
|
|
83
|
+
justifyContent: 'center',
|
|
84
|
+
alignItems: 'center',
|
|
85
|
+
},
|
|
86
|
+
});
|
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
import { KContainer, KColors, KSpacingValue } from '@droppii/libs';
|
|
10
10
|
import { mapOpenIMMessagesToGiftedChat } from '../../utils/giftedChatMessage';
|
|
11
11
|
import type { DGiftedChatMessage } from '../../utils/giftedChatMessage';
|
|
12
|
+
|
|
12
13
|
import type { ChatListProps } from './types';
|
|
13
14
|
import { ChatDay } from './ChatDay';
|
|
14
15
|
import { ChatLoadEarlier } from './ChatLoadEarlier';
|
|
@@ -24,6 +25,8 @@ export const ChatList = memo(
|
|
|
24
25
|
isLoading,
|
|
25
26
|
isLoadingEarlier,
|
|
26
27
|
hasMoreEarlier,
|
|
28
|
+
// Note: onLoadNewer, isLoadingNewer, hasMoreNewer are not used in GiftedChat
|
|
29
|
+
// as it has its own pagination mechanism. They're kept for API compatibility.
|
|
27
30
|
}: ChatListProps) => {
|
|
28
31
|
const giftedMessages = useMemo(
|
|
29
32
|
() => mapOpenIMMessagesToGiftedChat(messages),
|