@droppii-org/chat-mobile 0.2.6 → 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/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/useChatMessages.js +37 -119
- 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/useLinkPreview.js +3 -2
- package/lib/module/hooks/useLinkPreview/useLinkPreview.js.map +1 -1
- package/lib/module/screens/chat-detail/ChatComposer.js +2 -2
- package/lib/module/screens/chat-detail/ChatComposer.js.map +1 -1
- package/lib/module/screens/chat-detail/ChatDetail.js +14 -10
- 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 +1 -1
- package/lib/module/screens/chat-detail/ChatLinkPreview.js.map +1 -1
- package/lib/module/screens/chat-detail/ChatListLegend.js +0 -2
- package/lib/module/screens/chat-detail/ChatListLegend.js.map +1 -1
- package/lib/module/screens/chat-detail/conversationHeader.utils.js +7 -9
- package/lib/module/screens/chat-detail/conversationHeader.utils.js.map +1 -1
- package/lib/module/screens/chat-detail/legend/LegendChatMessage.js +10 -23
- package/lib/module/screens/chat-detail/legend/LegendChatMessage.js.map +1 -1
- package/lib/module/screens/chat-detail/legend/message-types.js +128 -6
- package/lib/module/screens/chat-detail/legend/message-types.js.map +1 -1
- 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/utils/conversation.js +34 -13
- package/lib/module/utils/conversation.js.map +1 -1
- package/lib/module/utils/legendListMessage.js +0 -3
- package/lib/module/utils/legendListMessage.js.map +1 -1
- package/lib/module/utils/message.js +5 -8
- package/lib/module/utils/message.js.map +1 -1
- package/lib/module/utils/url.js +3 -3
- package/lib/module/utils/url.js.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.map +1 -1
- 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/useChatMessages.d.ts +0 -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/useLinkPreview.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/ChatListLegend.d.ts.map +1 -1
- package/lib/typescript/src/screens/chat-detail/conversationHeader.utils.d.ts +1 -1
- package/lib/typescript/src/screens/chat-detail/conversationHeader.utils.d.ts.map +1 -1
- package/lib/typescript/src/screens/chat-detail/legend/LegendChatMessage.d.ts +1 -3
- package/lib/typescript/src/screens/chat-detail/legend/LegendChatMessage.d.ts.map +1 -1
- package/lib/typescript/src/screens/chat-detail/legend/message-types.d.ts +1 -0
- package/lib/typescript/src/screens/chat-detail/legend/message-types.d.ts.map +1 -1
- package/lib/typescript/src/screens/chat-detail/types.d.ts +6 -7
- package/lib/typescript/src/screens/chat-detail/types.d.ts.map +1 -1
- 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 +1 -0
- package/lib/typescript/src/types/common.d.ts.map +1 -1
- 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 +0 -2
- package/lib/typescript/src/utils/legendListMessage.d.ts.map +1 -1
- package/lib/typescript/src/utils/message.d.ts.map +1 -1
- package/lib/typescript/src/utils/url.d.ts +1 -1
- package/lib/typescript/src/utils/url.d.ts.map +1 -1
- package/package.json +3 -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/context/ChatContext.tsx +12 -4
- package/src/hooks/message/useSendMessage.ts +136 -0
- package/src/hooks/useChatMessages.ts +70 -158
- package/src/hooks/useConversationList.ts +34 -16
- package/src/hooks/useLinkPreview/useLinkPreview.ts +3 -2
- package/src/screens/chat-detail/ChatComposer.tsx +2 -2
- package/src/screens/chat-detail/ChatDetail.tsx +29 -22
- package/src/screens/chat-detail/ChatDetailHeader.tsx +4 -10
- package/src/screens/chat-detail/ChatLinkPreview.tsx +1 -1
- package/src/screens/chat-detail/ChatListLegend.tsx +1 -2
- package/src/screens/chat-detail/conversationHeader.utils.ts +11 -14
- package/src/screens/chat-detail/legend/LegendChatMessage.tsx +15 -33
- package/src/screens/chat-detail/legend/message-types.tsx +167 -12
- package/src/screens/chat-detail/types.ts +6 -8
- 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 +1 -0
- package/src/utils/conversation.ts +44 -17
- package/src/utils/legendListMessage.ts +0 -5
- package/src/utils/message.ts +10 -12
- package/src/utils/url.ts +3 -3
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { create } from 'zustand';
|
|
2
|
+
import type { MessageItem } from '@droppii/openim-rn-client-sdk';
|
|
3
|
+
import type { DMessageItem, MessageStore } from '../types/chat';
|
|
4
|
+
import { mergeMessages } from '../utils/message';
|
|
5
|
+
|
|
6
|
+
export const useMessageStore = create<MessageStore>()((set, get) => ({
|
|
7
|
+
messages: [],
|
|
8
|
+
hasMoreEarlier: false,
|
|
9
|
+
hasMoreNewer: false,
|
|
10
|
+
|
|
11
|
+
setMessages: (messages, hasMore) => {
|
|
12
|
+
set({ messages, hasMoreEarlier: hasMore });
|
|
13
|
+
},
|
|
14
|
+
|
|
15
|
+
pushNewMessage: (message: MessageItem) => {
|
|
16
|
+
set((state) => ({
|
|
17
|
+
messages: mergeMessages(state.messages, [message as DMessageItem]),
|
|
18
|
+
}));
|
|
19
|
+
},
|
|
20
|
+
|
|
21
|
+
updateOneMessage: (message: MessageItem) => {
|
|
22
|
+
const tmpList = [...get().messages];
|
|
23
|
+
const idx = tmpList.findIndex(
|
|
24
|
+
(msg) => msg.clientMsgID === message.clientMsgID
|
|
25
|
+
);
|
|
26
|
+
if (idx < 0) return;
|
|
27
|
+
tmpList[idx] = { ...tmpList[idx]!, ...message } as DMessageItem;
|
|
28
|
+
set({ messages: tmpList });
|
|
29
|
+
},
|
|
30
|
+
|
|
31
|
+
deleteOneMessage: (clientMsgID: string) => {
|
|
32
|
+
set((state) => ({
|
|
33
|
+
messages: state.messages.filter((msg) => msg.clientMsgID !== clientMsgID),
|
|
34
|
+
}));
|
|
35
|
+
},
|
|
36
|
+
|
|
37
|
+
reset: () => {
|
|
38
|
+
set({
|
|
39
|
+
messages: [],
|
|
40
|
+
hasMoreEarlier: false,
|
|
41
|
+
hasMoreNewer: false,
|
|
42
|
+
});
|
|
43
|
+
},
|
|
44
|
+
}));
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
const i18nKey: Record<string, string> = {
|
|
2
2
|
thread_card_bot_crm_name: 'Droppii Hỗ Trợ',
|
|
3
3
|
thread_card_fallback_name: 'Người dùng',
|
|
4
|
+
msg_type_image: '[Hình ảnh]',
|
|
5
|
+
msg_type_voice: '[Tin nhắn thoại]',
|
|
6
|
+
msg_type_video: '[Video]',
|
|
7
|
+
msg_type_file: '[File đính kèm]',
|
|
8
|
+
msg_type_link: '[Liên kết]',
|
|
9
|
+
msg_type_revoke: 'Đã thu hồi tin nhắn',
|
|
4
10
|
};
|
|
5
11
|
|
|
6
12
|
export default {
|
package/src/types/chat.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
type MessageItem,
|
|
3
|
-
type
|
|
4
|
-
|
|
5
|
-
type GroupAtType,
|
|
3
|
+
type ConversationItem,
|
|
4
|
+
PeerType,
|
|
6
5
|
} from '@droppii/openim-rn-client-sdk';
|
|
7
6
|
import type { PropsWithChildren } from 'react';
|
|
7
|
+
import type { IUrlMetadata } from './common';
|
|
8
8
|
|
|
9
9
|
export const EventProvider = {
|
|
10
10
|
ga: 'ga',
|
|
@@ -20,16 +20,17 @@ type LogGA = (
|
|
|
20
20
|
|
|
21
21
|
export interface ChatContextType {
|
|
22
22
|
logGA?: LogGA;
|
|
23
|
+
applicationType: DChatApplicationType;
|
|
23
24
|
}
|
|
24
25
|
|
|
25
26
|
export type ChatProviderProps = PropsWithChildren<{
|
|
26
|
-
enabled?: boolean;
|
|
27
27
|
logGA?: LogGA;
|
|
28
|
+
applicationType: DChatApplicationType;
|
|
28
29
|
}>;
|
|
29
30
|
|
|
30
31
|
export enum DChatApplicationType {
|
|
31
|
-
|
|
32
|
-
|
|
32
|
+
DROPPII = 'DROPPII',
|
|
33
|
+
OBEFE = 'OBEFE',
|
|
33
34
|
}
|
|
34
35
|
|
|
35
36
|
export enum DChatCategory {
|
|
@@ -40,11 +41,6 @@ export enum DChatCategory {
|
|
|
40
41
|
BIZ_BOT_CRM = 'BIZ_BOT_CRM',
|
|
41
42
|
}
|
|
42
43
|
|
|
43
|
-
export enum DChatType {
|
|
44
|
-
SINGLE = 'SINGLE',
|
|
45
|
-
GROUP = 'GROUP',
|
|
46
|
-
}
|
|
47
|
-
|
|
48
44
|
export enum DMemberRole {
|
|
49
45
|
AGENT = 'AGENT',
|
|
50
46
|
MEMBER = 'MEMBER',
|
|
@@ -65,11 +61,11 @@ export interface DConversationPeer {
|
|
|
65
61
|
group: null; // to be defined when group is implemented
|
|
66
62
|
}
|
|
67
63
|
|
|
68
|
-
export interface DConversationItem {
|
|
64
|
+
export interface DConversationItem extends ConversationItem {
|
|
69
65
|
// Droppii API fields
|
|
70
66
|
conversationId: string;
|
|
71
67
|
chatCategory: DChatCategory;
|
|
72
|
-
chatType:
|
|
68
|
+
chatType: PeerType;
|
|
73
69
|
applicationType: string;
|
|
74
70
|
memberRole: DMemberRole;
|
|
75
71
|
pinnedAt: string | null;
|
|
@@ -77,23 +73,6 @@ export interface DConversationItem {
|
|
|
77
73
|
peer: DConversationPeerUser;
|
|
78
74
|
// Merged from OpenIM (available after getConversationListSplit merge)
|
|
79
75
|
lastMessage?: DMessageItem;
|
|
80
|
-
unreadCount?: number;
|
|
81
|
-
conversationType?: SessionType;
|
|
82
|
-
userID?: string;
|
|
83
|
-
groupID?: string;
|
|
84
|
-
showName?: string;
|
|
85
|
-
faceURL?: string;
|
|
86
|
-
recvMsgOpt?: MessageReceiveOptType;
|
|
87
|
-
groupAtType?: GroupAtType;
|
|
88
|
-
latestMsgSendTime?: number;
|
|
89
|
-
draftText?: string;
|
|
90
|
-
draftTextTime?: number;
|
|
91
|
-
isPinned?: boolean;
|
|
92
|
-
isNotInGroup?: boolean;
|
|
93
|
-
isPrivateChat?: boolean;
|
|
94
|
-
isMsgDestruct?: boolean;
|
|
95
|
-
attachedInfo?: string;
|
|
96
|
-
ex?: string;
|
|
97
76
|
}
|
|
98
77
|
|
|
99
78
|
export interface DConversationQueryParams {
|
|
@@ -134,3 +113,25 @@ export interface DMessagePushInfoEx {
|
|
|
134
113
|
title: string;
|
|
135
114
|
desc: string;
|
|
136
115
|
}
|
|
116
|
+
|
|
117
|
+
export interface IMessageItemEx {
|
|
118
|
+
applicationType: DChatApplicationType;
|
|
119
|
+
sessionId?: string;
|
|
120
|
+
messageInfo?: {
|
|
121
|
+
type: 'MESSAGE_INFO';
|
|
122
|
+
data: 'rich_text';
|
|
123
|
+
content: string;
|
|
124
|
+
};
|
|
125
|
+
urlMetadata?: IUrlMetadata;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export interface MessageStore {
|
|
129
|
+
messages: DMessageItem[];
|
|
130
|
+
hasMoreEarlier: boolean;
|
|
131
|
+
hasMoreNewer: boolean;
|
|
132
|
+
setMessages: (messages: DMessageItem[], hasMore: boolean) => void;
|
|
133
|
+
pushNewMessage: (message: MessageItem) => void;
|
|
134
|
+
updateOneMessage: (message: MessageItem) => void;
|
|
135
|
+
deleteOneMessage: (clientMsgID: string) => void;
|
|
136
|
+
reset: () => void;
|
|
137
|
+
}
|
package/src/types/common.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
|
+
MessageType,
|
|
2
3
|
SessionType,
|
|
3
4
|
type ConversationItem,
|
|
4
5
|
} from '@droppii/openim-rn-client-sdk';
|
|
5
6
|
import { type DConversationItem, type DMessageItem } from '../types/chat';
|
|
7
|
+
import { trans } from '../translation';
|
|
6
8
|
|
|
7
9
|
export const conversationCompare = (
|
|
8
10
|
a: ConversationItem,
|
|
@@ -26,38 +28,37 @@ export const dConversationCompare = (
|
|
|
26
28
|
a: DConversationItem,
|
|
27
29
|
b: DConversationItem
|
|
28
30
|
) => {
|
|
29
|
-
|
|
30
|
-
const bIsPinned = b.pinnedAt != null;
|
|
31
|
-
|
|
32
|
-
if (aIsPinned !== bIsPinned) return aIsPinned ? -1 : 1;
|
|
31
|
+
if (a.isPinned !== b.isPinned) return a.isPinned ? -1 : 1;
|
|
33
32
|
|
|
34
|
-
const
|
|
35
|
-
|
|
33
|
+
const aTime =
|
|
34
|
+
a.draftTextTime > a.latestMsgSendTime
|
|
35
|
+
? a.draftTextTime
|
|
36
|
+
: a.latestMsgSendTime;
|
|
37
|
+
const bTime =
|
|
38
|
+
b.draftTextTime > b.latestMsgSendTime
|
|
39
|
+
? b.draftTextTime
|
|
40
|
+
: b.latestMsgSendTime;
|
|
36
41
|
|
|
37
|
-
return
|
|
42
|
+
return bTime - aTime;
|
|
38
43
|
};
|
|
39
44
|
|
|
40
45
|
export const mergeOpenIMIntoConversation = (
|
|
41
|
-
|
|
46
|
+
existing: DConversationItem,
|
|
42
47
|
openim: ConversationItem
|
|
43
48
|
): DConversationItem => {
|
|
44
|
-
|
|
45
|
-
const { latestMsg, conversationID, ...openimRest } = openim;
|
|
49
|
+
const { latestMsg, ...openimRest } = openim;
|
|
46
50
|
|
|
47
|
-
let lastMessage: DMessageItem | undefined =
|
|
51
|
+
let lastMessage: DMessageItem | undefined = existing.lastMessage;
|
|
48
52
|
if (latestMsg) {
|
|
49
53
|
try {
|
|
50
54
|
lastMessage = JSON.parse(latestMsg) as DMessageItem;
|
|
51
55
|
} catch {
|
|
52
|
-
// keep
|
|
56
|
+
// keep existing lastMessage if parse fails
|
|
53
57
|
}
|
|
54
58
|
}
|
|
55
59
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
...openimRest,
|
|
59
|
-
lastMessage,
|
|
60
|
-
};
|
|
60
|
+
// Spread existing first so peerType (not in ConversationItem) is preserved
|
|
61
|
+
return { ...existing, ...openimRest, lastMessage };
|
|
61
62
|
};
|
|
62
63
|
|
|
63
64
|
export const getConversationID = (
|
|
@@ -81,3 +82,29 @@ export const sortConversation = (map: Record<string, DConversationItem>) => {
|
|
|
81
82
|
);
|
|
82
83
|
return { map, list };
|
|
83
84
|
};
|
|
85
|
+
|
|
86
|
+
export const generateContentBasedOnMessageType = (
|
|
87
|
+
contentType: MessageType,
|
|
88
|
+
plainText?: string
|
|
89
|
+
) => {
|
|
90
|
+
switch (contentType) {
|
|
91
|
+
case MessageType.TextMessage:
|
|
92
|
+
case MessageType.QuoteMessage:
|
|
93
|
+
case MessageType.LogTextMessage:
|
|
94
|
+
return plainText || '';
|
|
95
|
+
case MessageType.PictureMessage:
|
|
96
|
+
return trans('msg_type_image');
|
|
97
|
+
case MessageType.VoiceMessage:
|
|
98
|
+
return trans('msg_type_voice');
|
|
99
|
+
case MessageType.VideoMessage:
|
|
100
|
+
return trans('msg_type_video');
|
|
101
|
+
case MessageType.FileMessage:
|
|
102
|
+
return trans('msg_type_file');
|
|
103
|
+
case MessageType.UrlTextMessage:
|
|
104
|
+
return trans('msg_type_link');
|
|
105
|
+
case MessageType.RevokeMessage:
|
|
106
|
+
return trans('revoked');
|
|
107
|
+
default:
|
|
108
|
+
return '';
|
|
109
|
+
}
|
|
110
|
+
};
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { MessageType } from '@droppii/openim-rn-client-sdk';
|
|
2
2
|
import type { DMessageItem } from '../types/chat';
|
|
3
|
-
import { resolveChatMessageType } from './resolveMessageType';
|
|
4
|
-
import type { DChatMessageType } from '../types/message';
|
|
5
3
|
|
|
6
4
|
/**
|
|
7
5
|
* Extract message text based on content type
|
|
@@ -41,7 +39,6 @@ export const getMessageText = (message: DMessageItem): string => {
|
|
|
41
39
|
export interface PrecomputedMessageData {
|
|
42
40
|
messageId: string;
|
|
43
41
|
dayStart: boolean;
|
|
44
|
-
messageType: DChatMessageType;
|
|
45
42
|
createdAt: number;
|
|
46
43
|
}
|
|
47
44
|
|
|
@@ -66,12 +63,10 @@ export const precomputeLegendListData = (
|
|
|
66
63
|
|
|
67
64
|
const createdAt = message.sendTime || message.createTime;
|
|
68
65
|
const day = new Date(createdAt).getDate();
|
|
69
|
-
const messageType = resolveChatMessageType(message);
|
|
70
66
|
|
|
71
67
|
dataMap.set(messageId, {
|
|
72
68
|
messageId,
|
|
73
69
|
dayStart: lastDay !== day,
|
|
74
|
-
messageType,
|
|
75
70
|
createdAt,
|
|
76
71
|
});
|
|
77
72
|
|
package/src/utils/message.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { SessionType, type MessageItem } from '@droppii/openim-rn-client-sdk';
|
|
2
1
|
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
type
|
|
6
|
-
} from '
|
|
2
|
+
PeerType,
|
|
3
|
+
SessionType,
|
|
4
|
+
type MessageItem,
|
|
5
|
+
} from '@droppii/openim-rn-client-sdk';
|
|
6
|
+
import { type DConversationItem, type DMessageItem } from '../types/chat';
|
|
7
7
|
import { getConversationID } from './conversation';
|
|
8
8
|
|
|
9
9
|
const getMessageTime = (message: DMessageItem) =>
|
|
@@ -129,14 +129,12 @@ export const belongsToConversation = (
|
|
|
129
129
|
export const getReceiverId = (conversation?: DConversationItem) => {
|
|
130
130
|
if (conversation == null) return { groupID: '', recvID: '' };
|
|
131
131
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
const
|
|
135
|
-
|
|
136
|
-
? conversation.conversationId?.slice(3) // Remove sg_
|
|
137
|
-
: conversation.groupID;
|
|
132
|
+
if (conversation.peerType === PeerType.Group) {
|
|
133
|
+
// Group conversation: groupID is embedded after the "sg_" prefix
|
|
134
|
+
const groupID =
|
|
135
|
+
conversation.groupID || conversation.conversationID.slice(3);
|
|
138
136
|
return { groupID: groupID ?? '', recvID: '' };
|
|
139
137
|
}
|
|
140
138
|
|
|
141
|
-
return { groupID: '', recvID: conversation.
|
|
139
|
+
return { groupID: '', recvID: conversation.userID ?? '' };
|
|
142
140
|
};
|
package/src/utils/url.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const URL_REGEX =
|
|
1
|
+
const URL_REGEX = /\bhttps?:\/\/[^\s<>"']*[^\s<>"',.!?()\[\]{}]/g;
|
|
2
2
|
|
|
3
|
-
export function
|
|
4
|
-
return text.match(URL_REGEX)
|
|
3
|
+
export function extractUrls(text: string): string[] {
|
|
4
|
+
return text.match(URL_REGEX) ?? [];
|
|
5
5
|
}
|