@droppii-org/chat-mobile 0.2.50 → 0.2.51

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.
Files changed (137) hide show
  1. package/lib/module/components/StickerPicker/StickerCategoryTabs.js +86 -0
  2. package/lib/module/components/StickerPicker/StickerCategoryTabs.js.map +1 -0
  3. package/lib/module/components/StickerPicker/StickerPickerPlaceholder.js +18 -0
  4. package/lib/module/components/StickerPicker/StickerPickerPlaceholder.js.map +1 -0
  5. package/lib/module/components/StickerPicker/StickerPickerRowItem.js +35 -0
  6. package/lib/module/components/StickerPicker/StickerPickerRowItem.js.map +1 -0
  7. package/lib/module/components/StickerPicker/StickerSectionList.js +110 -0
  8. package/lib/module/components/StickerPicker/StickerSectionList.js.map +1 -0
  9. package/lib/module/components/StickerPicker/constants.js +14 -0
  10. package/lib/module/components/StickerPicker/constants.js.map +1 -0
  11. package/lib/module/components/StickerPicker/index.js +134 -0
  12. package/lib/module/components/StickerPicker/index.js.map +1 -0
  13. package/lib/module/components/messages/stickerMessage/index.js +28 -0
  14. package/lib/module/components/messages/stickerMessage/index.js.map +1 -0
  15. package/lib/module/config/api-endpoints.js +4 -1
  16. package/lib/module/config/api-endpoints.js.map +1 -1
  17. package/lib/module/hooks/conversation/useGetConversationDetail.js +15 -0
  18. package/lib/module/hooks/conversation/useGetConversationDetail.js.map +1 -1
  19. package/lib/module/hooks/flows/useGetConversationFlowMainMenu.js +1 -1
  20. package/lib/module/hooks/flows/useGetConversationFlowMainMenu.js.map +1 -1
  21. package/lib/module/hooks/message/useSendMessage.js +45 -18
  22. package/lib/module/hooks/message/useSendMessage.js.map +1 -1
  23. package/lib/module/hooks/query-keys.js +7 -0
  24. package/lib/module/hooks/query-keys.js.map +1 -1
  25. package/lib/module/hooks/stickers/useFetchStickerByCategory.js +12 -0
  26. package/lib/module/hooks/stickers/useFetchStickerByCategory.js.map +1 -0
  27. package/lib/module/hooks/stickers/useStickerCategories.js +14 -0
  28. package/lib/module/hooks/stickers/useStickerCategories.js.map +1 -0
  29. package/lib/module/hooks/stickers/useStickerHistory.js +16 -0
  30. package/lib/module/hooks/stickers/useStickerHistory.js.map +1 -0
  31. package/lib/module/hooks/useChatCompose.js +1 -18
  32. package/lib/module/hooks/useChatCompose.js.map +1 -1
  33. package/lib/module/screens/chat-detail/ChatComposer.js +64 -16
  34. package/lib/module/screens/chat-detail/ChatComposer.js.map +1 -1
  35. package/lib/module/screens/chat-detail/ChatDetail.js +6 -20
  36. package/lib/module/screens/chat-detail/ChatDetail.js.map +1 -1
  37. package/lib/module/screens/chat-detail/hooks/useChatComposerAnimation.js +15 -4
  38. package/lib/module/screens/chat-detail/hooks/useChatComposerAnimation.js.map +1 -1
  39. package/lib/module/screens/chat-detail/hooks/useChatComposerState.js +3 -0
  40. package/lib/module/screens/chat-detail/hooks/useChatComposerState.js.map +1 -1
  41. package/lib/module/screens/chat-detail/legend/LegendChatMessage.js +5 -6
  42. package/lib/module/screens/chat-detail/legend/LegendChatMessage.js.map +1 -1
  43. package/lib/module/services/attachmentOrchestrator.js +1 -1
  44. package/lib/module/services/attachmentOrchestrator.js.map +1 -1
  45. package/lib/module/services/endpoints.js +4 -1
  46. package/lib/module/services/endpoints.js.map +1 -1
  47. package/lib/module/store/conversation.js +1 -20
  48. package/lib/module/store/conversation.js.map +1 -1
  49. package/lib/module/translation/resources/i18n.js +3 -1
  50. package/lib/module/translation/resources/i18n.js.map +1 -1
  51. package/lib/module/types/chat.js +6 -0
  52. package/lib/module/types/chat.js.map +1 -1
  53. package/lib/module/types/sticker.js +2 -0
  54. package/lib/module/types/sticker.js.map +1 -0
  55. package/lib/module/utils/conversation.js +1 -24
  56. package/lib/module/utils/conversation.js.map +1 -1
  57. package/lib/module/utils/messageUtils.js +2 -0
  58. package/lib/module/utils/messageUtils.js.map +1 -1
  59. package/lib/typescript/src/components/StickerPicker/StickerCategoryTabs.d.ts +9 -0
  60. package/lib/typescript/src/components/StickerPicker/StickerCategoryTabs.d.ts.map +1 -0
  61. package/lib/typescript/src/components/StickerPicker/StickerPickerPlaceholder.d.ts +2 -0
  62. package/lib/typescript/src/components/StickerPicker/StickerPickerPlaceholder.d.ts.map +1 -0
  63. package/lib/typescript/src/components/StickerPicker/StickerPickerRowItem.d.ts +8 -0
  64. package/lib/typescript/src/components/StickerPicker/StickerPickerRowItem.d.ts.map +1 -0
  65. package/lib/typescript/src/components/StickerPicker/StickerSectionList.d.ts +15 -0
  66. package/lib/typescript/src/components/StickerPicker/StickerSectionList.d.ts.map +1 -0
  67. package/lib/typescript/src/components/StickerPicker/constants.d.ts +11 -0
  68. package/lib/typescript/src/components/StickerPicker/constants.d.ts.map +1 -0
  69. package/lib/typescript/src/components/StickerPicker/index.d.ts +7 -0
  70. package/lib/typescript/src/components/StickerPicker/index.d.ts.map +1 -0
  71. package/lib/typescript/src/components/messages/stickerMessage/index.d.ts +3 -0
  72. package/lib/typescript/src/components/messages/stickerMessage/index.d.ts.map +1 -0
  73. package/lib/typescript/src/config/api-endpoints.d.ts +3 -0
  74. package/lib/typescript/src/config/api-endpoints.d.ts.map +1 -1
  75. package/lib/typescript/src/hooks/conversation/useGetConversationDetail.d.ts +2 -1
  76. package/lib/typescript/src/hooks/conversation/useGetConversationDetail.d.ts.map +1 -1
  77. package/lib/typescript/src/hooks/message/useSendMessage.d.ts +5 -3
  78. package/lib/typescript/src/hooks/message/useSendMessage.d.ts.map +1 -1
  79. package/lib/typescript/src/hooks/query-keys.d.ts +7 -0
  80. package/lib/typescript/src/hooks/query-keys.d.ts.map +1 -1
  81. package/lib/typescript/src/hooks/stickers/useFetchStickerByCategory.d.ts +3 -0
  82. package/lib/typescript/src/hooks/stickers/useFetchStickerByCategory.d.ts.map +1 -0
  83. package/lib/typescript/src/hooks/stickers/useStickerCategories.d.ts +3 -0
  84. package/lib/typescript/src/hooks/stickers/useStickerCategories.d.ts.map +1 -0
  85. package/lib/typescript/src/hooks/stickers/useStickerHistory.d.ts +3 -0
  86. package/lib/typescript/src/hooks/stickers/useStickerHistory.d.ts.map +1 -0
  87. package/lib/typescript/src/hooks/useChatCompose.d.ts.map +1 -1
  88. package/lib/typescript/src/screens/chat-detail/ChatComposer.d.ts +2 -2
  89. package/lib/typescript/src/screens/chat-detail/ChatComposer.d.ts.map +1 -1
  90. package/lib/typescript/src/screens/chat-detail/ChatDetail.d.ts.map +1 -1
  91. package/lib/typescript/src/screens/chat-detail/hooks/useChatComposerAnimation.d.ts +2 -1
  92. package/lib/typescript/src/screens/chat-detail/hooks/useChatComposerAnimation.d.ts.map +1 -1
  93. package/lib/typescript/src/screens/chat-detail/hooks/useChatComposerState.d.ts +3 -0
  94. package/lib/typescript/src/screens/chat-detail/hooks/useChatComposerState.d.ts.map +1 -1
  95. package/lib/typescript/src/screens/chat-detail/legend/LegendChatMessage.d.ts.map +1 -1
  96. package/lib/typescript/src/services/endpoints.d.ts +4 -1
  97. package/lib/typescript/src/services/endpoints.d.ts.map +1 -1
  98. package/lib/typescript/src/store/conversation.d.ts +0 -3
  99. package/lib/typescript/src/store/conversation.d.ts.map +1 -1
  100. package/lib/typescript/src/translation/resources/i18n.d.ts.map +1 -1
  101. package/lib/typescript/src/types/chat.d.ts +12 -19
  102. package/lib/typescript/src/types/chat.d.ts.map +1 -1
  103. package/lib/typescript/src/types/sticker.d.ts +21 -0
  104. package/lib/typescript/src/types/sticker.d.ts.map +1 -0
  105. package/lib/typescript/src/utils/conversation.d.ts +1 -2
  106. package/lib/typescript/src/utils/conversation.d.ts.map +1 -1
  107. package/lib/typescript/src/utils/messageUtils.d.ts.map +1 -1
  108. package/package.json +2 -2
  109. package/src/components/StickerPicker/StickerCategoryTabs.tsx +103 -0
  110. package/src/components/StickerPicker/StickerPickerPlaceholder.tsx +16 -0
  111. package/src/components/StickerPicker/StickerPickerRowItem.tsx +43 -0
  112. package/src/components/StickerPicker/StickerSectionList.tsx +141 -0
  113. package/src/components/StickerPicker/constants.ts +20 -0
  114. package/src/components/StickerPicker/index.tsx +166 -0
  115. package/src/components/messages/stickerMessage/index.tsx +26 -0
  116. package/src/config/api-endpoints.ts +6 -0
  117. package/src/hooks/conversation/useGetConversationDetail.ts +20 -1
  118. package/src/hooks/flows/useGetConversationFlowMainMenu.ts +1 -1
  119. package/src/hooks/message/useSendMessage.ts +49 -27
  120. package/src/hooks/query-keys.ts +10 -0
  121. package/src/hooks/stickers/useFetchStickerByCategory.ts +15 -0
  122. package/src/hooks/stickers/useStickerCategories.ts +17 -0
  123. package/src/hooks/stickers/useStickerHistory.ts +19 -0
  124. package/src/hooks/useChatCompose.ts +0 -19
  125. package/src/screens/chat-detail/ChatComposer.tsx +106 -19
  126. package/src/screens/chat-detail/ChatDetail.tsx +5 -19
  127. package/src/screens/chat-detail/hooks/useChatComposerAnimation.ts +21 -5
  128. package/src/screens/chat-detail/hooks/useChatComposerState.ts +7 -0
  129. package/src/screens/chat-detail/legend/LegendChatMessage.tsx +4 -5
  130. package/src/services/attachmentOrchestrator.ts +1 -1
  131. package/src/services/endpoints.ts +6 -1
  132. package/src/store/conversation.ts +0 -24
  133. package/src/translation/resources/i18n.ts +3 -0
  134. package/src/types/chat.ts +13 -21
  135. package/src/types/sticker.ts +23 -0
  136. package/src/utils/conversation.ts +0 -28
  137. package/src/utils/messageUtils.ts +3 -0
@@ -1,6 +1,10 @@
1
1
  import { useState, useMemo, useRef } from 'react';
2
2
 
3
+ export type ActivePanelType = 'attachment' | 'sticker' | null;
4
+
3
5
  interface UseChatComposerStateReturn {
6
+ activePanelType: ActivePanelType;
7
+ setActivePanelType: (type: ActivePanelType) => void;
4
8
  isAttachmentOpen: boolean;
5
9
  setIsAttachmentOpen: (open: boolean) => void;
6
10
  isInputFocused: boolean;
@@ -14,6 +18,7 @@ interface UseChatComposerStateReturn {
14
18
  export const useChatComposerState = (
15
19
  value: string
16
20
  ): UseChatComposerStateReturn => {
21
+ const [activePanelType, setActivePanelType] = useState<ActivePanelType>(null);
17
22
  const [isAttachmentOpen, setIsAttachmentOpen] = useState(false);
18
23
  const [isInputFocused, setIsInputFocused] = useState(false);
19
24
  const [isInputWrapped, setIsInputWrapped] = useState(false);
@@ -28,6 +33,8 @@ export const useChatComposerState = (
28
33
  }, [isInputWrapped, value]);
29
34
 
30
35
  return {
36
+ activePanelType,
37
+ setActivePanelType,
31
38
  isAttachmentOpen,
32
39
  setIsAttachmentOpen,
33
40
  isInputFocused,
@@ -18,6 +18,7 @@ import { MessageStatusIndicator } from '../../../components/messages/MessageStat
18
18
  import type { BaseLegendMessageProps } from '../../../components/messages/types';
19
19
  import { messageStyles } from './messageTypes';
20
20
  import QuotedMessage from '../../../components/messages/quotedMessage';
21
+ import { StickerMessage } from '../../../components/messages/stickerMessage';
21
22
 
22
23
  type MessageProps = BaseLegendMessageProps & {
23
24
  onPressUrl?: (url: string) => void;
@@ -36,9 +37,6 @@ interface LegendChatMessageProps {
36
37
  customMessageItemFactory?: (m: MessageItem) => ReactNode;
37
38
  }
38
39
 
39
- // OpenIM message types (not all exposed as MessageType enum)
40
- const MERGED_MESSAGE_TYPE = 107; // MergerMessage - merged/grouped messages
41
-
42
40
  const messageComponentMap: Partial<
43
41
  Record<MessageType, ComponentType<MessageProps>>
44
42
  > = {
@@ -49,14 +47,15 @@ const messageComponentMap: Partial<
49
47
  [MessageType.PictureMessage]: ImageMessage,
50
48
  [MessageType.VideoMessage]: VideoMessage,
51
49
  [MessageType.FileMessage]: FileMessage,
52
- [MERGED_MESSAGE_TYPE]: MergedMessage,
50
+ [MessageType.MergeMessage]: MergedMessage,
53
51
  [MessageType.RevokeMessage]: RevokedMessage,
52
+ [MessageType.StickerMessage]: StickerMessage,
54
53
  };
55
54
 
56
55
  const MEDIA_TYPES: number[] = [
57
56
  MessageType.PictureMessage,
58
57
  MessageType.VideoMessage,
59
- MERGED_MESSAGE_TYPE,
58
+ MessageType.MergeMessage,
60
59
  ];
61
60
 
62
61
  export const LegendChatMessage = memo(
@@ -293,7 +293,7 @@ export namespace AttachmentOrchestratorService {
293
293
  recvID,
294
294
  groupID,
295
295
  message,
296
- offlinePushInfo: generateOfflinePushInfo(message.contentType, ''),
296
+ offlinePushInfo: generateOfflinePushInfo(message),
297
297
  });
298
298
 
299
299
  if (result) {
@@ -30,7 +30,12 @@ export const ENDPOINTS = {
30
30
  `${getApiEndpoint('conversation')}/${id}/bot-flows/main-menu`,
31
31
  getConversationStatusByBotId: (botId: string) =>
32
32
  `${getApiEndpoint('bot')}/${botId}`,
33
- createConversation: () => getApiEndpoint('conversation'),
33
+ getConversationTarget: (conversationId: string) =>
34
+ `${getApiEndpoint('conversation')}/${conversationId}/target`,
35
+ stickerCategories: () => getApiEndpoint('stickerCategories'),
36
+ stickersByCategoryId: (id: string) =>
37
+ `${getApiEndpoint('stickersByCategory')}/${id}/stickers`,
38
+ stickerHistory: () => getApiEndpoint('stickerHistory'),
34
39
  },
35
40
  uploaderService: {
36
41
  get uploadImage() {
@@ -1,13 +1,6 @@
1
1
  import { create } from 'zustand';
2
2
  import { sortConversation } from '../utils/conversation';
3
3
  import type { ConversationItem } from '@droppii/openim-rn-client-sdk';
4
- import type {
5
- CreateConversationParams,
6
- CreateConversationResponse,
7
- } from '../types/chat';
8
- import { apiInstance } from '../services/apis';
9
- import { ENDPOINTS } from '../services/endpoints';
10
- import type { BaseResponse } from '../types/auth';
11
4
 
12
5
  type ConversationID = string;
13
6
 
@@ -15,8 +8,6 @@ export interface ConversationStore {
15
8
  currentConversationId?: ConversationID;
16
9
  currentUserId?: string;
17
10
  currentGroupId?: string;
18
- isCreatingConversation?: boolean;
19
- createConversation: (params: CreateConversationParams) => Promise<void>;
20
11
  setCurrentConversation(
21
12
  id?: ConversationID,
22
13
  userId?: string,
@@ -87,27 +78,12 @@ export const useConversationStore = create<ConversationStore>()((set, get) => ({
87
78
  list: get().list.filter((item) => item !== id),
88
79
  });
89
80
  },
90
- createConversation: async (params) => {
91
- set({ isCreatingConversation: true });
92
- const res = await apiInstance?.post<
93
- BaseResponse<CreateConversationResponse>
94
- >(ENDPOINTS.chatService.createConversation(), params);
95
- if (res?.data?.data?.conversationId) {
96
- set({
97
- currentConversationId: res?.data?.data?.conversationId,
98
- isCreatingConversation: false,
99
- });
100
- } else {
101
- set({ isCreatingConversation: false });
102
- }
103
- },
104
81
  reset() {
105
82
  set({
106
83
  currentConversationId: undefined,
107
84
  list: [],
108
85
  map: {},
109
86
  newConversationSignal: 0,
110
- isCreatingConversation: false,
111
87
  });
112
88
  },
113
89
  }));
@@ -20,6 +20,8 @@ const i18nKey: Record<string, string> = {
20
20
  'chat:image_upload_failed': 'Có lỗi xảy ra vui lòng thử lại',
21
21
  'chat:generic_error': 'Có lỗi xảy ra vui lòng thử lại',
22
22
  'chat:failed_to_send_message': 'Không thể gửi tin nhắn. Thử lại?',
23
+ 'chat:compose_disabled_seller_inactive':
24
+ 'Người dùng này không còn hoạt động.',
23
25
  'chat:filename': 'Tên tệp',
24
26
  'chat:file_size': 'Kích thước',
25
27
  'chat:dimensions': 'Kích cỡ',
@@ -90,6 +92,7 @@ const i18nKey: Record<string, string> = {
90
92
  'chat:reply_to': 'Trả lời {{name}}',
91
93
  'yourself': 'chính mình',
92
94
  'you': 'Bạn',
95
+ 'recent': 'Gần đây',
93
96
  };
94
97
 
95
98
  export default {
package/src/types/chat.ts CHANGED
@@ -111,6 +111,18 @@ export interface DBotStatus {
111
111
  botSupportPlatform: unknown | null;
112
112
  }
113
113
 
114
+ /**
115
+ * Known target types from GET .../conversations/{id}/target. `type` is a BE
116
+ * string literal; kept as `string` so unexpected values never break the UI.
117
+ */
118
+ export interface DConversationTarget {
119
+ id: string;
120
+ name: string;
121
+ avartar: string; // BE typo — intentional, matches API contract exactly
122
+ isActive: boolean;
123
+ type: string; // 'BOT' | 'SELLER' | 'CUSTOMER' | 'GROUP' (known), tolerate others
124
+ }
125
+
114
126
  export enum SyncStatus {
115
127
  Loading = 0,
116
128
  Success = 1,
@@ -154,6 +166,7 @@ export interface IMessageItemEx {
154
166
  };
155
167
  urlMetadata?: IUrlMetadata;
156
168
  flow?: IRunConversationFlowPayload;
169
+ stickerId?: string;
157
170
  }
158
171
 
159
172
  export interface IGetMessagesParams {
@@ -229,24 +242,3 @@ export type CustomElemOrderData = {
229
242
  export type CustomMessagePayload =
230
243
  | { type: typeof CustomMessageType.Order; data: CustomElemOrderData }
231
244
  | { type: typeof CustomMessageType.Product; data: Record<string, unknown> };
232
-
233
- export interface CreateConversationParams {
234
- peerUserId: string;
235
- chatCategory: DChatCategory;
236
- applicationType: DChatApplicationType;
237
- chatType: 'SINGLE' | 'GROUP';
238
- }
239
-
240
- export interface CreateConversationResponse {
241
- conversationId: string;
242
- groupId?: string;
243
- groupName?: string;
244
- groupAvatar?: string;
245
- chatCategory: DChatCategory;
246
- applicationType: DChatApplicationType;
247
- chatType: 'SINGLE' | 'GROUP';
248
- members?: {
249
- userId: string;
250
- memberRole?: string;
251
- }[];
252
- }
@@ -0,0 +1,23 @@
1
+ export interface StickerFileResource {
2
+ streamId: string;
3
+ containerName: string;
4
+ contentType: string;
5
+ baseUrl: string;
6
+ fullUrl: string;
7
+ }
8
+
9
+ export interface StickerCategory {
10
+ id: string;
11
+ name: string;
12
+ icon: StickerFileResource | null;
13
+ stickerCount: number;
14
+ }
15
+
16
+ export interface StickerItem {
17
+ id: string;
18
+ name: string;
19
+ categoryId: string;
20
+ file: StickerFileResource;
21
+ }
22
+
23
+ export type StickerRow = (StickerItem | null)[];
@@ -1,10 +1,8 @@
1
1
  import {
2
- MessageType,
3
2
  PeerType,
4
3
  SessionType,
5
4
  type ConversationItem,
6
5
  } from '@droppii/openim-rn-client-sdk';
7
- import { trans } from '../translation';
8
6
 
9
7
  export const conversationCompare = (
10
8
  a: ConversationItem,
@@ -46,32 +44,6 @@ export const sortConversation = (map: Record<string, ConversationItem>) => {
46
44
  return { map, list };
47
45
  };
48
46
 
49
- export const generateContentBasedOnMessageType = (
50
- contentType: MessageType,
51
- plainText?: string
52
- ) => {
53
- switch (contentType) {
54
- case MessageType.TextMessage:
55
- case MessageType.QuoteMessage:
56
- case MessageType.LogTextMessage:
57
- return plainText || '';
58
- case MessageType.PictureMessage:
59
- return trans('msg_type_image');
60
- case MessageType.VoiceMessage:
61
- return trans('msg_type_voice');
62
- case MessageType.VideoMessage:
63
- return trans('msg_type_video');
64
- case MessageType.FileMessage:
65
- return trans('msg_type_file');
66
- case MessageType.UrlTextMessage:
67
- return trans('msg_type_link');
68
- case MessageType.RevokeMessage:
69
- return trans('msg_type_revoke');
70
- default:
71
- return '';
72
- }
73
- };
74
-
75
47
  export const getBotId = (conversation?: ConversationItem) => {
76
48
  if (conversation && conversation?.peerType === PeerType.Bot) {
77
49
  try {
@@ -92,6 +92,9 @@ export const getMessagePreview = (message?: MessageItem): string => {
92
92
  return message?.customElem?.description;
93
93
  }
94
94
  return '';
95
+
96
+ case MessageType.StickerMessage:
97
+ return '[Sticker]';
95
98
  default:
96
99
  return '[Tin nhắn không được hỗ trợ]';
97
100
  }