@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,8 +1,8 @@
|
|
|
1
1
|
import { memo } from 'react';
|
|
2
2
|
import { Image, StyleSheet } from 'react-native';
|
|
3
3
|
import { KContainer, KImage, KColors } from '@droppii/libs';
|
|
4
|
-
import { DChatCategory, DChatType } from '../../types/chat';
|
|
5
4
|
import Images from '../../assets/images';
|
|
5
|
+
import { PeerType } from '@droppii/openim-rn-client-sdk';
|
|
6
6
|
|
|
7
7
|
const styles = StyleSheet.create({
|
|
8
8
|
icon: {
|
|
@@ -12,46 +12,35 @@ const styles = StyleSheet.create({
|
|
|
12
12
|
});
|
|
13
13
|
|
|
14
14
|
interface NamePrefixIconProps {
|
|
15
|
-
|
|
16
|
-
chatType?: DChatType;
|
|
15
|
+
peerType?: PeerType | string;
|
|
17
16
|
}
|
|
18
17
|
|
|
19
|
-
export const NamePrefixIcon = memo(
|
|
20
|
-
(
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
<
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}
|
|
28
|
-
if (chatCategory === DChatCategory.BIZ_BOT_PDP) {
|
|
29
|
-
return (
|
|
30
|
-
<KContainer.View marginR="0.25rem">
|
|
31
|
-
<KImage.VectorIcons
|
|
32
|
-
name="robot-outline"
|
|
33
|
-
provider="MaterialCommunityIcons"
|
|
34
|
-
size={14}
|
|
35
|
-
color={KColors.palette.primary.w400}
|
|
36
|
-
/>
|
|
37
|
-
</KContainer.View>
|
|
38
|
-
);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
if (chatType === DChatType.GROUP) {
|
|
42
|
-
return (
|
|
43
|
-
<KContainer.View marginR="0.25rem">
|
|
44
|
-
<KImage.VectorIcons
|
|
45
|
-
name="user-two-b"
|
|
46
|
-
size={14}
|
|
47
|
-
color={KColors.black}
|
|
48
|
-
/>
|
|
49
|
-
</KContainer.View>
|
|
50
|
-
);
|
|
51
|
-
}
|
|
18
|
+
export const NamePrefixIcon = memo(({ peerType }: NamePrefixIconProps) => {
|
|
19
|
+
if (peerType === PeerType.Bot) {
|
|
20
|
+
return (
|
|
21
|
+
<KContainer.View marginR="0.25rem">
|
|
22
|
+
<Image source={Images.ICON_DROPPII} style={styles.icon} />
|
|
23
|
+
</KContainer.View>
|
|
24
|
+
);
|
|
25
|
+
}
|
|
52
26
|
|
|
53
|
-
|
|
27
|
+
if (peerType === PeerType.Group) {
|
|
28
|
+
return (
|
|
29
|
+
<KContainer.View marginR="0.25rem">
|
|
30
|
+
<KImage.VectorIcons name="user-two-b" size={14} color={KColors.black} />
|
|
31
|
+
</KContainer.View>
|
|
32
|
+
);
|
|
54
33
|
}
|
|
55
|
-
|
|
34
|
+
|
|
35
|
+
// if (peerType === DChatPeerType.CUSTOMER) {
|
|
36
|
+
// return (
|
|
37
|
+
// <KContainer.View marginR="0.25rem">
|
|
38
|
+
// <Image source={Images.ICON_DROPPII} style={styles.icon} />
|
|
39
|
+
// </KContainer.View>
|
|
40
|
+
// );
|
|
41
|
+
// }
|
|
42
|
+
|
|
43
|
+
return null;
|
|
44
|
+
});
|
|
56
45
|
|
|
57
46
|
NamePrefixIcon.displayName = 'NamePrefixIcon';
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import { memo, useCallback } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { type GestureResponderEvent } from 'react-native';
|
|
3
3
|
import { KContainer, KImage, KLabel, KColors } from '@droppii/libs';
|
|
4
|
-
import { DChatCategory } from '../../types/chat';
|
|
5
4
|
import { AvatarSection } from './AvatarSection';
|
|
6
5
|
import { NamePrefixIcon } from './NamePrefixIcon';
|
|
7
6
|
import { UnreadBadge } from './UnreadBadge';
|
|
8
7
|
import { formatTimestamp, getLastMessageText } from './thread-card.utils';
|
|
9
|
-
import Images from '../../assets/images';
|
|
10
8
|
import { useConversation, useUserStore } from '../../store';
|
|
11
9
|
|
|
12
10
|
interface ThreadCardProps {
|
|
@@ -16,19 +14,20 @@ interface ThreadCardProps {
|
|
|
16
14
|
|
|
17
15
|
const ThreadCard = memo(({ item, onPress }: ThreadCardProps) => {
|
|
18
16
|
const {
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
peerType,
|
|
18
|
+
showName,
|
|
19
|
+
faceURL,
|
|
21
20
|
lastMessage,
|
|
22
21
|
unreadCount = 0,
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
recvMsgOpt,
|
|
23
|
+
isPinned,
|
|
25
24
|
applicationType,
|
|
26
|
-
chatType,
|
|
27
25
|
latestMsgSendTime,
|
|
28
26
|
} = useConversation(item) ?? {};
|
|
29
27
|
|
|
30
|
-
const fullName =
|
|
28
|
+
const fullName = showName ?? '';
|
|
31
29
|
const hasUnread = unreadCount > 0;
|
|
30
|
+
const isMuted = (recvMsgOpt ?? 0) !== 0;
|
|
32
31
|
const timestamp = formatTimestamp(
|
|
33
32
|
latestMsgSendTime ?? lastMessage?.sendTime ?? null
|
|
34
33
|
);
|
|
@@ -52,30 +51,25 @@ const ThreadCard = memo(({ item, onPress }: ThreadCardProps) => {
|
|
|
52
51
|
activeOpacity={0.7}
|
|
53
52
|
>
|
|
54
53
|
<AvatarSection
|
|
55
|
-
avatar={
|
|
54
|
+
avatar={faceURL ?? null}
|
|
56
55
|
fullName={fullName}
|
|
57
|
-
|
|
56
|
+
peerType={peerType}
|
|
58
57
|
applicationType={applicationType}
|
|
59
|
-
chatType={chatType}
|
|
60
58
|
/>
|
|
61
59
|
|
|
62
60
|
{/* Chat-Content */}
|
|
63
61
|
<KContainer.View flex marginL="0.5rem" paddingB={2}>
|
|
64
62
|
{/* Row-Title */}
|
|
65
63
|
<KContainer.View row alignItems="center">
|
|
66
|
-
<NamePrefixIcon
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
// chatCategory === DChatCategory.BIZ_BOT_CRM ||
|
|
70
|
-
chatCategory === DChatCategory.BIZ_BOT_PDP
|
|
71
|
-
}
|
|
72
|
-
>
|
|
64
|
+
<NamePrefixIcon peerType={peerType} />
|
|
65
|
+
{/* For verified PDP (configuration details to be defined later) */}
|
|
66
|
+
{/* <KContainer.VisibleView visible={peerType === DChatPeerType.BOT}>
|
|
73
67
|
<KImage.Base
|
|
74
68
|
uri={Images.ICON_BOT}
|
|
75
69
|
size={14}
|
|
76
70
|
style={styles.botIcon}
|
|
77
71
|
/>
|
|
78
|
-
</KContainer.VisibleView>
|
|
72
|
+
</KContainer.VisibleView> */}
|
|
79
73
|
<KLabel.Text
|
|
80
74
|
typo={hasUnread ? 'TextMdBold' : 'TextMdNormal'}
|
|
81
75
|
numberOfLines={1}
|
|
@@ -84,7 +78,7 @@ const ThreadCard = memo(({ item, onPress }: ThreadCardProps) => {
|
|
|
84
78
|
>
|
|
85
79
|
{fullName}
|
|
86
80
|
</KLabel.Text>
|
|
87
|
-
<KContainer.VisibleView visible={
|
|
81
|
+
<KContainer.VisibleView visible={isMuted}>
|
|
88
82
|
<KContainer.View marginL="0.25rem">
|
|
89
83
|
<KImage.VectorIcons
|
|
90
84
|
name="bell-off"
|
|
@@ -115,7 +109,7 @@ const ThreadCard = memo(({ item, onPress }: ThreadCardProps) => {
|
|
|
115
109
|
>
|
|
116
110
|
{lastMessageText}
|
|
117
111
|
</KLabel.Text>
|
|
118
|
-
<KContainer.VisibleView visible={Boolean(
|
|
112
|
+
<KContainer.VisibleView visible={Boolean(isPinned)}>
|
|
119
113
|
<KContainer.View marginL="0.5rem">
|
|
120
114
|
<KImage.VectorIcons
|
|
121
115
|
name="pin-outline"
|
|
@@ -135,11 +129,3 @@ const ThreadCard = memo(({ item, onPress }: ThreadCardProps) => {
|
|
|
135
129
|
ThreadCard.displayName = 'ThreadCard';
|
|
136
130
|
|
|
137
131
|
export default ThreadCard;
|
|
138
|
-
|
|
139
|
-
const styles = StyleSheet.create({
|
|
140
|
-
botIcon: {
|
|
141
|
-
width: 16,
|
|
142
|
-
height: 16,
|
|
143
|
-
marginRight: 4,
|
|
144
|
-
},
|
|
145
|
-
});
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
export interface FeatureFlags {
|
|
2
|
+
USE_LEGEND_LIST_CHAT: boolean;
|
|
3
|
+
CHAT_LIST_VARIANT: 'gifted' | 'legend';
|
|
4
|
+
ENABLE_PERFORMANCE_METRICS: boolean;
|
|
5
|
+
METRICS_SAMPLE_RATE: number;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
const DEFAULT_FLAGS: FeatureFlags = {
|
|
9
|
+
USE_LEGEND_LIST_CHAT: false,
|
|
10
|
+
CHAT_LIST_VARIANT: 'legend',
|
|
11
|
+
ENABLE_PERFORMANCE_METRICS: true,
|
|
12
|
+
METRICS_SAMPLE_RATE: 1.0,
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
let flags: FeatureFlags = { ...DEFAULT_FLAGS };
|
|
16
|
+
|
|
17
|
+
export const getFeatureFlag = <K extends keyof FeatureFlags>(
|
|
18
|
+
flag: K
|
|
19
|
+
): FeatureFlags[K] => {
|
|
20
|
+
return flags[flag];
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export const setFeatureFlag = <K extends keyof FeatureFlags>(
|
|
24
|
+
flag: K,
|
|
25
|
+
value: FeatureFlags[K]
|
|
26
|
+
) => {
|
|
27
|
+
flags[flag] = value;
|
|
28
|
+
notifyListeners();
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export const resetFlags = () => {
|
|
32
|
+
flags = { ...DEFAULT_FLAGS };
|
|
33
|
+
notifyListeners();
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
const listeners = new Set<() => void>();
|
|
37
|
+
|
|
38
|
+
export const onFlagsChange = (callback: () => void) => {
|
|
39
|
+
listeners.add(callback);
|
|
40
|
+
return () => {
|
|
41
|
+
listeners.delete(callback);
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
const notifyListeners = () => {
|
|
46
|
+
listeners.forEach((cb) => cb());
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
export const getAllFlags = (): FeatureFlags => ({ ...flags });
|
|
@@ -13,11 +13,19 @@ export const useChatContext = (): ChatContextType => {
|
|
|
13
13
|
return context;
|
|
14
14
|
};
|
|
15
15
|
|
|
16
|
-
const ChatProviderInner = ({
|
|
17
|
-
|
|
16
|
+
const ChatProviderInner = ({
|
|
17
|
+
logGA,
|
|
18
|
+
children,
|
|
19
|
+
applicationType,
|
|
20
|
+
}: ChatProviderProps) => {
|
|
21
|
+
const value = useMemo(
|
|
22
|
+
() => ({ logGA, applicationType }),
|
|
23
|
+
[logGA, applicationType]
|
|
24
|
+
);
|
|
18
25
|
|
|
19
26
|
return <ChatContext.Provider value={value}>{children}</ChatContext.Provider>;
|
|
20
27
|
};
|
|
21
28
|
|
|
22
|
-
export const ChatProvider = ({
|
|
23
|
-
|
|
29
|
+
export const ChatProvider = ({ ...props }: ChatProviderProps) => (
|
|
30
|
+
<ChatProviderInner {...props} />
|
|
31
|
+
);
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { useCallback } from 'react';
|
|
2
|
+
import type { UploadFileItem } from 'react-native-fs';
|
|
3
|
+
import { useConversationStore } from '../../store';
|
|
4
|
+
import type {
|
|
5
|
+
MessageItem,
|
|
6
|
+
MessageType,
|
|
7
|
+
OfflinePush,
|
|
8
|
+
} from '@droppii/openim-rn-client-sdk';
|
|
9
|
+
import { extractUrls } from '../../utils/url';
|
|
10
|
+
import OpenIMSDK from '@droppii/openim-rn-client-sdk';
|
|
11
|
+
import type { IMessageItemEx } from '../../types/chat';
|
|
12
|
+
import { useChatContext } from '../../context';
|
|
13
|
+
import { generateContentBasedOnMessageType } from '../../utils/conversation';
|
|
14
|
+
import { useMessageStore } from '../../store/message';
|
|
15
|
+
import type { IUrlMetadata } from '../../types/common';
|
|
16
|
+
|
|
17
|
+
export const useSendMessage = () => {
|
|
18
|
+
const applicationType = useChatContext().applicationType;
|
|
19
|
+
const pushNewMessage = useMessageStore((state) => state.pushNewMessage);
|
|
20
|
+
|
|
21
|
+
const sendMessage = useCallback(
|
|
22
|
+
async ({
|
|
23
|
+
plainText,
|
|
24
|
+
files,
|
|
25
|
+
urlMetadata,
|
|
26
|
+
}: {
|
|
27
|
+
plainText?: string;
|
|
28
|
+
files?: UploadFileItem[]; //TODO
|
|
29
|
+
urlMetadata?: IUrlMetadata;
|
|
30
|
+
}) => {
|
|
31
|
+
const { userID: recvID, groupID } =
|
|
32
|
+
useConversationStore.getState().getCurrentConversation() || {};
|
|
33
|
+
if (!recvID && !groupID) return;
|
|
34
|
+
|
|
35
|
+
const messageList: MessageItem[] = [];
|
|
36
|
+
|
|
37
|
+
for (const file of files || []) {
|
|
38
|
+
if (!file) continue;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
if (!!plainText && plainText.trim() !== '') {
|
|
42
|
+
const urls = extractUrls(plainText);
|
|
43
|
+
const isUrlMessage = urls.length > 0;
|
|
44
|
+
let message: MessageItem | null = null;
|
|
45
|
+
if (isUrlMessage) {
|
|
46
|
+
message = await createUrlTextMessage(plainText, urls);
|
|
47
|
+
} else {
|
|
48
|
+
message = await createTextMessage(plainText);
|
|
49
|
+
}
|
|
50
|
+
if (!message) return;
|
|
51
|
+
messageList.push(message);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
for (const message of messageList) {
|
|
55
|
+
const extendMessageInfo: IMessageItemEx = {
|
|
56
|
+
applicationType,
|
|
57
|
+
urlMetadata,
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
const successMessage = await OpenIMSDK.sendMessage({
|
|
61
|
+
groupID: groupID || '',
|
|
62
|
+
recvID: recvID || '',
|
|
63
|
+
message: {
|
|
64
|
+
...message,
|
|
65
|
+
ex: JSON.stringify(extendMessageInfo) || '{}',
|
|
66
|
+
},
|
|
67
|
+
offlinePushInfo: generateOfflinePushInfo(
|
|
68
|
+
message.contentType,
|
|
69
|
+
plainText || ''
|
|
70
|
+
),
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
pushNewMessage(successMessage);
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
[applicationType, pushNewMessage]
|
|
77
|
+
);
|
|
78
|
+
|
|
79
|
+
return {
|
|
80
|
+
sendMessage,
|
|
81
|
+
};
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
const generateOfflinePushInfo = (
|
|
85
|
+
contentType: MessageType,
|
|
86
|
+
plainText: string
|
|
87
|
+
) => {
|
|
88
|
+
const conversationData = useConversationStore
|
|
89
|
+
?.getState?.()
|
|
90
|
+
?.getCurrentConversation();
|
|
91
|
+
const title = conversationData?.showName || 'Droppii';
|
|
92
|
+
const desc = generateContentBasedOnMessageType(contentType, plainText);
|
|
93
|
+
return {
|
|
94
|
+
title,
|
|
95
|
+
desc,
|
|
96
|
+
ex: JSON.stringify({
|
|
97
|
+
icon: conversationData?.faceURL || '',
|
|
98
|
+
conversationId: conversationData?.conversationId || '',
|
|
99
|
+
title,
|
|
100
|
+
desc,
|
|
101
|
+
}),
|
|
102
|
+
iOSPushSound: 'default',
|
|
103
|
+
iOSBadgeCount: true,
|
|
104
|
+
} as OfflinePush;
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
export const createTextMessage = async (text: string) => {
|
|
108
|
+
let textMessage = await OpenIMSDK.createTextMessage(
|
|
109
|
+
text,
|
|
110
|
+
new Date().getTime().toString()
|
|
111
|
+
)
|
|
112
|
+
.then((data) => {
|
|
113
|
+
return data;
|
|
114
|
+
})
|
|
115
|
+
.catch(({ errCode, errMsg }) => {
|
|
116
|
+
console.error('createTextMessage', errCode, errMsg);
|
|
117
|
+
return null;
|
|
118
|
+
});
|
|
119
|
+
return textMessage;
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
export const createUrlTextMessage = async (text: string, urls: string[]) => {
|
|
123
|
+
let urlTextMessage = await OpenIMSDK.createUrlTextMessage(
|
|
124
|
+
text,
|
|
125
|
+
urls,
|
|
126
|
+
new Date().getTime().toString()
|
|
127
|
+
)
|
|
128
|
+
.then((data) => {
|
|
129
|
+
return data;
|
|
130
|
+
})
|
|
131
|
+
.catch(({ errCode, errMsg }) => {
|
|
132
|
+
console.error('createUrlTextMessage', errCode, errMsg);
|
|
133
|
+
return null;
|
|
134
|
+
});
|
|
135
|
+
return urlTextMessage;
|
|
136
|
+
};
|
package/src/hooks/query-keys.ts
CHANGED