@droppii-org/chat-mobile 0.2.18 → 0.2.19
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.map +1 -1
- package/lib/module/components/ThreadCard/ThreadCard.js +17 -9
- package/lib/module/components/ThreadCard/ThreadCard.js.map +1 -1
- package/lib/module/components/flows/inputButtons/index.js +7 -3
- package/lib/module/components/flows/inputButtons/index.js.map +1 -1
- package/lib/module/context/ChatContext.js +27 -4
- package/lib/module/context/ChatContext.js.map +1 -1
- package/lib/module/context/ChatDetailContext.js.map +1 -1
- package/lib/module/core/useChatListener.js +2 -4
- package/lib/module/core/useChatListener.js.map +1 -1
- package/lib/module/core/useUserListener.js +0 -7
- package/lib/module/core/useUserListener.js.map +1 -1
- package/lib/module/hooks/flows/useFlow.js +14 -3
- package/lib/module/hooks/flows/useFlow.js.map +1 -1
- package/lib/module/hooks/message/useSendMessage.js +1 -1
- package/lib/module/hooks/message/useSendMessage.js.map +1 -1
- package/lib/module/hooks/useConversationList.js +3 -27
- package/lib/module/hooks/useConversationList.js.map +1 -1
- package/lib/module/hooks/useLinkPreview/useLinkPreview.js +1 -1
- package/lib/module/hooks/useLinkPreview/useLinkPreview.js.map +1 -1
- package/lib/module/screens/chat-detail/ChatDetail.js +1 -6
- package/lib/module/screens/chat-detail/ChatDetail.js.map +1 -1
- package/lib/module/screens/chat-detail/ChatDetailHeader.js +6 -6
- package/lib/module/screens/chat-detail/ChatDetailHeader.js.map +1 -1
- package/lib/module/screens/chat-detail/ChatLinkPreview.js +3 -1
- package/lib/module/screens/chat-detail/ChatLinkPreview.js.map +1 -1
- package/lib/module/screens/chat-detail/ChatListLegend.js +2 -2
- package/lib/module/screens/chat-detail/ChatListLegend.js.map +1 -1
- package/lib/module/screens/chat-detail/conversationHeader.utils.js +9 -0
- package/lib/module/screens/chat-detail/conversationHeader.utils.js.map +1 -1
- package/lib/module/screens/inbox/Inbox.js +5 -1
- package/lib/module/screens/inbox/Inbox.js.map +1 -1
- package/lib/module/services/apis.js +0 -20
- package/lib/module/services/apis.js.map +1 -1
- package/lib/module/store/conversation.js +1 -38
- package/lib/module/store/conversation.js.map +1 -1
- package/lib/module/types/auth.js.map +1 -1
- package/lib/module/types/chat.js.map +1 -1
- package/lib/module/utils/conversation.js +1 -28
- package/lib/module/utils/conversation.js.map +1 -1
- package/lib/module/utils/message.js.map +1 -1
- package/lib/module/utils/messageUtils.js +5 -3
- package/lib/module/utils/messageUtils.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/ThreadCard.d.ts.map +1 -1
- package/lib/typescript/src/context/ChatContext.d.ts.map +1 -1
- package/lib/typescript/src/core/useChatListener.d.ts.map +1 -1
- package/lib/typescript/src/core/useUserListener.d.ts.map +1 -1
- package/lib/typescript/src/hooks/flows/useFlow.d.ts.map +1 -1
- package/lib/typescript/src/hooks/useConversationList.d.ts +2 -2
- 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/ChatLinkPreview.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 +7 -5
- package/lib/typescript/src/screens/chat-detail/conversationHeader.utils.d.ts.map +1 -1
- package/lib/typescript/src/screens/chat-detail/types.d.ts +6 -9
- package/lib/typescript/src/screens/chat-detail/types.d.ts.map +1 -1
- package/lib/typescript/src/screens/inbox/Inbox.d.ts.map +1 -1
- package/lib/typescript/src/services/apis.d.ts +0 -4
- package/lib/typescript/src/services/apis.d.ts.map +1 -1
- package/lib/typescript/src/store/conversation.d.ts +5 -8
- package/lib/typescript/src/store/conversation.d.ts.map +1 -1
- package/lib/typescript/src/types/auth.d.ts +1 -0
- package/lib/typescript/src/types/auth.d.ts.map +1 -1
- package/lib/typescript/src/types/chat.d.ts +15 -13
- package/lib/typescript/src/types/chat.d.ts.map +1 -1
- package/lib/typescript/src/utils/conversation.d.ts +2 -5
- package/lib/typescript/src/utils/conversation.d.ts.map +1 -1
- package/lib/typescript/src/utils/message.d.ts +3 -3
- package/lib/typescript/src/utils/message.d.ts.map +1 -1
- package/lib/typescript/src/utils/messageUtils.d.ts +2 -1
- package/lib/typescript/src/utils/messageUtils.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/components/ThreadCard/AvatarSection.tsx +2 -3
- package/src/components/ThreadCard/ThreadCard.tsx +22 -15
- package/src/components/flows/inputButtons/index.tsx +4 -1
- package/src/context/ChatContext.tsx +35 -3
- package/src/context/ChatDetailContext.tsx +1 -1
- package/src/core/useChatListener.ts +2 -4
- package/src/core/useUserListener.ts +0 -8
- package/src/hooks/flows/useFlow.ts +12 -3
- package/src/hooks/message/useSendMessage.ts +1 -1
- package/src/hooks/useConversationList.ts +6 -40
- package/src/hooks/useLinkPreview/useLinkPreview.ts +6 -1
- package/src/screens/chat-detail/ChatDetail.tsx +1 -7
- package/src/screens/chat-detail/ChatDetailHeader.tsx +6 -7
- package/src/screens/chat-detail/ChatLinkPreview.tsx +16 -12
- package/src/screens/chat-detail/ChatListLegend.tsx +2 -6
- package/src/screens/chat-detail/conversationHeader.utils.ts +16 -6
- package/src/screens/chat-detail/types.ts +6 -13
- package/src/screens/inbox/Inbox.tsx +5 -1
- package/src/services/apis.ts +0 -38
- package/src/store/conversation.ts +6 -55
- package/src/types/auth.ts +1 -0
- package/src/types/chat.ts +16 -20
- package/src/utils/conversation.ts +2 -40
- package/src/utils/message.ts +3 -2
- package/src/utils/messageUtils.ts +11 -3
package/src/types/chat.ts
CHANGED
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
type MessageItem,
|
|
3
|
-
type ConversationItem,
|
|
4
|
-
PeerType,
|
|
5
|
-
} from '@droppii/openim-rn-client-sdk';
|
|
1
|
+
import { type MessageItem } from '@droppii/openim-rn-client-sdk';
|
|
6
2
|
import type { PropsWithChildren } from 'react';
|
|
7
3
|
import type { IUrlMetadata } from './common';
|
|
8
4
|
import type {
|
|
@@ -10,6 +6,7 @@ import type {
|
|
|
10
6
|
IConversationFlowStep,
|
|
11
7
|
IRunConversationFlowPayload,
|
|
12
8
|
} from './flows';
|
|
9
|
+
import type { GetOpenIMTokenResponse } from './auth';
|
|
13
10
|
|
|
14
11
|
export const EventProvider = {
|
|
15
12
|
ga: 'ga',
|
|
@@ -31,6 +28,7 @@ export interface ChatContextType {
|
|
|
31
28
|
export type ChatProviderProps = PropsWithChildren<{
|
|
32
29
|
logGA?: LogGA;
|
|
33
30
|
applicationType: DChatApplicationType;
|
|
31
|
+
getChatToken: () => Promise<GetOpenIMTokenResponse | null>;
|
|
34
32
|
}>;
|
|
35
33
|
|
|
36
34
|
export enum DChatApplicationType {
|
|
@@ -66,20 +64,6 @@ export interface DConversationPeer {
|
|
|
66
64
|
group: null; // to be defined when group is implemented
|
|
67
65
|
}
|
|
68
66
|
|
|
69
|
-
export interface DConversationItem extends ConversationItem {
|
|
70
|
-
// Droppii API fields
|
|
71
|
-
conversationId: string;
|
|
72
|
-
chatCategory: DChatCategory;
|
|
73
|
-
chatType: PeerType;
|
|
74
|
-
applicationType: DChatApplicationType;
|
|
75
|
-
memberRole: DMemberRole;
|
|
76
|
-
pinnedAt: string | null;
|
|
77
|
-
isMuted: boolean;
|
|
78
|
-
peer: DConversationPeerUser;
|
|
79
|
-
// Merged from OpenIM (available after getConversationListSplit merge)
|
|
80
|
-
lastMessage?: DMessageItem;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
67
|
export interface DConversationQueryParams {
|
|
84
68
|
applicationType: string;
|
|
85
69
|
page: number;
|
|
@@ -146,7 +130,19 @@ export interface ChatDetailContextType {
|
|
|
146
130
|
conversationFlow?: IConversationFlow;
|
|
147
131
|
refetchConversationFlow: () => void;
|
|
148
132
|
isBotConversation: boolean;
|
|
149
|
-
setConverationFlowStep: (step
|
|
133
|
+
setConverationFlowStep: (step?: IConversationFlowStep) => void;
|
|
150
134
|
}
|
|
151
135
|
|
|
152
136
|
export interface ChatDetailProviderProps extends PropsWithChildren {}
|
|
137
|
+
|
|
138
|
+
export interface IConversationItemEx {
|
|
139
|
+
applicationType: DChatApplicationType;
|
|
140
|
+
sessionInfo?: {
|
|
141
|
+
type: 'SESSION_INFO';
|
|
142
|
+
data: {
|
|
143
|
+
ownerId: string;
|
|
144
|
+
botId: string;
|
|
145
|
+
};
|
|
146
|
+
};
|
|
147
|
+
chatCategory: DChatCategory;
|
|
148
|
+
}
|
|
@@ -3,7 +3,6 @@ import {
|
|
|
3
3
|
SessionType,
|
|
4
4
|
type ConversationItem,
|
|
5
5
|
} from '@droppii/openim-rn-client-sdk';
|
|
6
|
-
import { type DConversationItem, type DMessageItem } from '../types/chat';
|
|
7
6
|
import { trans } from '../translation';
|
|
8
7
|
|
|
9
8
|
export const conversationCompare = (
|
|
@@ -24,43 +23,6 @@ export const conversationCompare = (
|
|
|
24
23
|
return bCompare - aCompare;
|
|
25
24
|
};
|
|
26
25
|
|
|
27
|
-
export const dConversationCompare = (
|
|
28
|
-
a: DConversationItem,
|
|
29
|
-
b: DConversationItem
|
|
30
|
-
) => {
|
|
31
|
-
if (a.isPinned !== b.isPinned) return a.isPinned ? -1 : 1;
|
|
32
|
-
|
|
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;
|
|
41
|
-
|
|
42
|
-
return bTime - aTime;
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
export const mergeOpenIMIntoConversation = (
|
|
46
|
-
existing: DConversationItem,
|
|
47
|
-
openim: ConversationItem
|
|
48
|
-
): DConversationItem => {
|
|
49
|
-
const { latestMsg, ...openimRest } = openim;
|
|
50
|
-
|
|
51
|
-
let lastMessage: DMessageItem | undefined = existing.lastMessage;
|
|
52
|
-
if (latestMsg) {
|
|
53
|
-
try {
|
|
54
|
-
lastMessage = JSON.parse(latestMsg) as DMessageItem;
|
|
55
|
-
} catch {
|
|
56
|
-
// keep existing lastMessage if parse fails
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
// Spread existing first so peerType (not in ConversationItem) is preserved
|
|
61
|
-
return { ...existing, ...openimRest, lastMessage };
|
|
62
|
-
};
|
|
63
|
-
|
|
64
26
|
export const getConversationID = (
|
|
65
27
|
sessionType: SessionType,
|
|
66
28
|
senderID?: string,
|
|
@@ -76,9 +38,9 @@ export const getConversationID = (
|
|
|
76
38
|
return [prefix, senderID, receiverID].filter(Boolean).join('_');
|
|
77
39
|
};
|
|
78
40
|
|
|
79
|
-
export const sortConversation = (map: Record<string,
|
|
41
|
+
export const sortConversation = (map: Record<string, ConversationItem>) => {
|
|
80
42
|
const list = Object.keys(map).sort((a, b) =>
|
|
81
|
-
|
|
43
|
+
conversationCompare(map[a]!, map[b]!)
|
|
82
44
|
);
|
|
83
45
|
return { map, list };
|
|
84
46
|
};
|
package/src/utils/message.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
PeerType,
|
|
3
3
|
SessionType,
|
|
4
|
+
type ConversationItem,
|
|
4
5
|
type MessageItem,
|
|
5
6
|
} from '@droppii/openim-rn-client-sdk';
|
|
6
|
-
import { type
|
|
7
|
+
import { type DMessageItem } from '../types/chat';
|
|
7
8
|
import { getConversationID } from './conversation';
|
|
8
9
|
|
|
9
10
|
const getMessageTime = (message: DMessageItem) =>
|
|
@@ -126,7 +127,7 @@ export const belongsToConversation = (
|
|
|
126
127
|
}
|
|
127
128
|
};
|
|
128
129
|
|
|
129
|
-
export const getReceiverId = (conversation?:
|
|
130
|
+
export const getReceiverId = (conversation?: ConversationItem) => {
|
|
130
131
|
if (conversation == null) return { groupID: '', recvID: '' };
|
|
131
132
|
|
|
132
133
|
if (conversation.peerType === PeerType.Group) {
|
|
@@ -2,7 +2,11 @@
|
|
|
2
2
|
* Message formatting and preview utilities
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
MessageType,
|
|
7
|
+
PeerType,
|
|
8
|
+
type ConversationItem,
|
|
9
|
+
} from '@droppii/openim-rn-client-sdk';
|
|
6
10
|
import type { DMessageItem } from '../types/chat';
|
|
7
11
|
import { DChatMessageType } from '../types/message';
|
|
8
12
|
import { formatDuration } from './dateTimeUtils';
|
|
@@ -86,7 +90,6 @@ export const getMessagePreview = (message: DMessageItem): string => {
|
|
|
86
90
|
// Preview link message - show with [Link] prefix
|
|
87
91
|
const urlText =
|
|
88
92
|
message?.urlTextElem?.content || message?.urlTextElem?.urls?.[0] || '';
|
|
89
|
-
console.log('message', urlText);
|
|
90
93
|
return urlText ? `[Link] ${urlText}` : '[Link]';
|
|
91
94
|
|
|
92
95
|
case MessageType.AtTextMessage:
|
|
@@ -100,7 +103,8 @@ export const getMessagePreview = (message: DMessageItem): string => {
|
|
|
100
103
|
|
|
101
104
|
export const getLastMessageText = (
|
|
102
105
|
message: DMessageItem | undefined,
|
|
103
|
-
currentUserId?: string
|
|
106
|
+
currentUserId?: string,
|
|
107
|
+
conversation?: ConversationItem
|
|
104
108
|
): string => {
|
|
105
109
|
if (!message) return '';
|
|
106
110
|
|
|
@@ -117,5 +121,9 @@ export const getLastMessageText = (
|
|
|
117
121
|
return `${message.senderNickname}: ${preview}`;
|
|
118
122
|
}
|
|
119
123
|
|
|
124
|
+
if (conversation?.peerType === PeerType.Bot) {
|
|
125
|
+
return `${conversation?.showName || ''}: ${preview}`;
|
|
126
|
+
}
|
|
127
|
+
|
|
120
128
|
return preview;
|
|
121
129
|
};
|