@droppii-org/chat-mobile 0.2.49 → 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 (159) 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/ThreadCard/MuteThread.js +4 -28
  14. package/lib/module/components/ThreadCard/MuteThread.js.map +1 -1
  15. package/lib/module/components/ThreadCard/PinThread.js +45 -0
  16. package/lib/module/components/ThreadCard/PinThread.js.map +1 -0
  17. package/lib/module/components/ThreadCard/ThreadCard.js +14 -9
  18. package/lib/module/components/ThreadCard/ThreadCard.js.map +1 -1
  19. package/lib/module/components/messages/stickerMessage/index.js +28 -0
  20. package/lib/module/components/messages/stickerMessage/index.js.map +1 -0
  21. package/lib/module/config/api-endpoints.js +4 -1
  22. package/lib/module/config/api-endpoints.js.map +1 -1
  23. package/lib/module/hooks/conversation/useGetConversationDetail.js +15 -0
  24. package/lib/module/hooks/conversation/useGetConversationDetail.js.map +1 -1
  25. package/lib/module/hooks/flows/useGetConversationFlowMainMenu.js +1 -1
  26. package/lib/module/hooks/flows/useGetConversationFlowMainMenu.js.map +1 -1
  27. package/lib/module/hooks/message/useSendMessage.js +45 -18
  28. package/lib/module/hooks/message/useSendMessage.js.map +1 -1
  29. package/lib/module/hooks/query-keys.js +7 -0
  30. package/lib/module/hooks/query-keys.js.map +1 -1
  31. package/lib/module/hooks/stickers/useFetchStickerByCategory.js +12 -0
  32. package/lib/module/hooks/stickers/useFetchStickerByCategory.js.map +1 -0
  33. package/lib/module/hooks/stickers/useStickerCategories.js +14 -0
  34. package/lib/module/hooks/stickers/useStickerCategories.js.map +1 -0
  35. package/lib/module/hooks/stickers/useStickerHistory.js +16 -0
  36. package/lib/module/hooks/stickers/useStickerHistory.js.map +1 -0
  37. package/lib/module/hooks/useChatCompose.js +1 -18
  38. package/lib/module/hooks/useChatCompose.js.map +1 -1
  39. package/lib/module/hooks/useMuteConversation.js +34 -15
  40. package/lib/module/hooks/useMuteConversation.js.map +1 -1
  41. package/lib/module/hooks/usePinConversation.js +72 -0
  42. package/lib/module/hooks/usePinConversation.js.map +1 -0
  43. package/lib/module/screens/chat-detail/ChatComposer.js +64 -16
  44. package/lib/module/screens/chat-detail/ChatComposer.js.map +1 -1
  45. package/lib/module/screens/chat-detail/ChatDetail.js +6 -20
  46. package/lib/module/screens/chat-detail/ChatDetail.js.map +1 -1
  47. package/lib/module/screens/chat-detail/hooks/useChatComposerAnimation.js +15 -4
  48. package/lib/module/screens/chat-detail/hooks/useChatComposerAnimation.js.map +1 -1
  49. package/lib/module/screens/chat-detail/hooks/useChatComposerState.js +3 -0
  50. package/lib/module/screens/chat-detail/hooks/useChatComposerState.js.map +1 -1
  51. package/lib/module/screens/chat-detail/legend/LegendChatMessage.js +5 -6
  52. package/lib/module/screens/chat-detail/legend/LegendChatMessage.js.map +1 -1
  53. package/lib/module/services/attachmentOrchestrator.js +1 -1
  54. package/lib/module/services/attachmentOrchestrator.js.map +1 -1
  55. package/lib/module/services/endpoints.js +4 -1
  56. package/lib/module/services/endpoints.js.map +1 -1
  57. package/lib/module/store/conversation.js +1 -20
  58. package/lib/module/store/conversation.js.map +1 -1
  59. package/lib/module/translation/resources/i18n.js +10 -1
  60. package/lib/module/translation/resources/i18n.js.map +1 -1
  61. package/lib/module/types/chat.js +6 -0
  62. package/lib/module/types/chat.js.map +1 -1
  63. package/lib/module/types/sticker.js +2 -0
  64. package/lib/module/types/sticker.js.map +1 -0
  65. package/lib/module/utils/conversation.js +1 -24
  66. package/lib/module/utils/conversation.js.map +1 -1
  67. package/lib/module/utils/messageUtils.js +2 -0
  68. package/lib/module/utils/messageUtils.js.map +1 -1
  69. package/lib/typescript/src/components/StickerPicker/StickerCategoryTabs.d.ts +9 -0
  70. package/lib/typescript/src/components/StickerPicker/StickerCategoryTabs.d.ts.map +1 -0
  71. package/lib/typescript/src/components/StickerPicker/StickerPickerPlaceholder.d.ts +2 -0
  72. package/lib/typescript/src/components/StickerPicker/StickerPickerPlaceholder.d.ts.map +1 -0
  73. package/lib/typescript/src/components/StickerPicker/StickerPickerRowItem.d.ts +8 -0
  74. package/lib/typescript/src/components/StickerPicker/StickerPickerRowItem.d.ts.map +1 -0
  75. package/lib/typescript/src/components/StickerPicker/StickerSectionList.d.ts +15 -0
  76. package/lib/typescript/src/components/StickerPicker/StickerSectionList.d.ts.map +1 -0
  77. package/lib/typescript/src/components/StickerPicker/constants.d.ts +11 -0
  78. package/lib/typescript/src/components/StickerPicker/constants.d.ts.map +1 -0
  79. package/lib/typescript/src/components/StickerPicker/index.d.ts +7 -0
  80. package/lib/typescript/src/components/StickerPicker/index.d.ts.map +1 -0
  81. package/lib/typescript/src/components/ThreadCard/MuteThread.d.ts.map +1 -1
  82. package/lib/typescript/src/components/ThreadCard/PinThread.d.ts +10 -0
  83. package/lib/typescript/src/components/ThreadCard/PinThread.d.ts.map +1 -0
  84. package/lib/typescript/src/components/ThreadCard/ThreadCard.d.ts.map +1 -1
  85. package/lib/typescript/src/components/messages/stickerMessage/index.d.ts +3 -0
  86. package/lib/typescript/src/components/messages/stickerMessage/index.d.ts.map +1 -0
  87. package/lib/typescript/src/config/api-endpoints.d.ts +3 -0
  88. package/lib/typescript/src/config/api-endpoints.d.ts.map +1 -1
  89. package/lib/typescript/src/hooks/conversation/useGetConversationDetail.d.ts +2 -1
  90. package/lib/typescript/src/hooks/conversation/useGetConversationDetail.d.ts.map +1 -1
  91. package/lib/typescript/src/hooks/message/useSendMessage.d.ts +5 -3
  92. package/lib/typescript/src/hooks/message/useSendMessage.d.ts.map +1 -1
  93. package/lib/typescript/src/hooks/query-keys.d.ts +7 -0
  94. package/lib/typescript/src/hooks/query-keys.d.ts.map +1 -1
  95. package/lib/typescript/src/hooks/stickers/useFetchStickerByCategory.d.ts +3 -0
  96. package/lib/typescript/src/hooks/stickers/useFetchStickerByCategory.d.ts.map +1 -0
  97. package/lib/typescript/src/hooks/stickers/useStickerCategories.d.ts +3 -0
  98. package/lib/typescript/src/hooks/stickers/useStickerCategories.d.ts.map +1 -0
  99. package/lib/typescript/src/hooks/stickers/useStickerHistory.d.ts +3 -0
  100. package/lib/typescript/src/hooks/stickers/useStickerHistory.d.ts.map +1 -0
  101. package/lib/typescript/src/hooks/useChatCompose.d.ts.map +1 -1
  102. package/lib/typescript/src/hooks/useMuteConversation.d.ts.map +1 -1
  103. package/lib/typescript/src/hooks/usePinConversation.d.ts +6 -0
  104. package/lib/typescript/src/hooks/usePinConversation.d.ts.map +1 -0
  105. package/lib/typescript/src/screens/chat-detail/ChatComposer.d.ts +2 -2
  106. package/lib/typescript/src/screens/chat-detail/ChatComposer.d.ts.map +1 -1
  107. package/lib/typescript/src/screens/chat-detail/ChatDetail.d.ts.map +1 -1
  108. package/lib/typescript/src/screens/chat-detail/hooks/useChatComposerAnimation.d.ts +2 -1
  109. package/lib/typescript/src/screens/chat-detail/hooks/useChatComposerAnimation.d.ts.map +1 -1
  110. package/lib/typescript/src/screens/chat-detail/hooks/useChatComposerState.d.ts +3 -0
  111. package/lib/typescript/src/screens/chat-detail/hooks/useChatComposerState.d.ts.map +1 -1
  112. package/lib/typescript/src/screens/chat-detail/legend/LegendChatMessage.d.ts.map +1 -1
  113. package/lib/typescript/src/services/endpoints.d.ts +4 -1
  114. package/lib/typescript/src/services/endpoints.d.ts.map +1 -1
  115. package/lib/typescript/src/store/conversation.d.ts +0 -3
  116. package/lib/typescript/src/store/conversation.d.ts.map +1 -1
  117. package/lib/typescript/src/translation/resources/i18n.d.ts.map +1 -1
  118. package/lib/typescript/src/types/chat.d.ts +12 -19
  119. package/lib/typescript/src/types/chat.d.ts.map +1 -1
  120. package/lib/typescript/src/types/sticker.d.ts +21 -0
  121. package/lib/typescript/src/types/sticker.d.ts.map +1 -0
  122. package/lib/typescript/src/utils/conversation.d.ts +1 -2
  123. package/lib/typescript/src/utils/conversation.d.ts.map +1 -1
  124. package/lib/typescript/src/utils/messageUtils.d.ts.map +1 -1
  125. package/package.json +2 -2
  126. package/src/components/StickerPicker/StickerCategoryTabs.tsx +103 -0
  127. package/src/components/StickerPicker/StickerPickerPlaceholder.tsx +16 -0
  128. package/src/components/StickerPicker/StickerPickerRowItem.tsx +43 -0
  129. package/src/components/StickerPicker/StickerSectionList.tsx +141 -0
  130. package/src/components/StickerPicker/constants.ts +20 -0
  131. package/src/components/StickerPicker/index.tsx +166 -0
  132. package/src/components/ThreadCard/MuteThread.tsx +4 -28
  133. package/src/components/ThreadCard/PinThread.tsx +58 -0
  134. package/src/components/ThreadCard/ThreadCard.tsx +11 -5
  135. package/src/components/messages/stickerMessage/index.tsx +26 -0
  136. package/src/config/api-endpoints.ts +6 -0
  137. package/src/hooks/conversation/useGetConversationDetail.ts +20 -1
  138. package/src/hooks/flows/useGetConversationFlowMainMenu.ts +1 -1
  139. package/src/hooks/message/useSendMessage.ts +49 -27
  140. package/src/hooks/query-keys.ts +10 -0
  141. package/src/hooks/stickers/useFetchStickerByCategory.ts +15 -0
  142. package/src/hooks/stickers/useStickerCategories.ts +17 -0
  143. package/src/hooks/stickers/useStickerHistory.ts +19 -0
  144. package/src/hooks/useChatCompose.ts +0 -19
  145. package/src/hooks/useMuteConversation.ts +32 -17
  146. package/src/hooks/usePinConversation.ts +87 -0
  147. package/src/screens/chat-detail/ChatComposer.tsx +106 -19
  148. package/src/screens/chat-detail/ChatDetail.tsx +5 -19
  149. package/src/screens/chat-detail/hooks/useChatComposerAnimation.ts +21 -5
  150. package/src/screens/chat-detail/hooks/useChatComposerState.ts +7 -0
  151. package/src/screens/chat-detail/legend/LegendChatMessage.tsx +4 -5
  152. package/src/services/attachmentOrchestrator.ts +1 -1
  153. package/src/services/endpoints.ts +6 -1
  154. package/src/store/conversation.ts +0 -24
  155. package/src/translation/resources/i18n.ts +11 -0
  156. package/src/types/chat.ts +13 -21
  157. package/src/types/sticker.ts +23 -0
  158. package/src/utils/conversation.ts +0 -28
  159. package/src/utils/messageUtils.ts +3 -0
@@ -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ỡ',
@@ -51,6 +53,14 @@ const i18nKey: Record<string, string> = {
51
53
  'chat:pinned_messages_title': 'Tin nhắn đã ghim',
52
54
  'chat:pinned_messages_hint':
53
55
  'Nhấn vào tin nhắn để xem tin nhắn gốc, nhấn vào biểu tượng để bỏ ghim',
56
+ 'chat:pin_thread': 'Ghim',
57
+ 'chat:unpin_thread': 'Bỏ ghim',
58
+ 'chat:pin_thread_success': 'Đã ghim đoạn chat thành công',
59
+ 'chat:unpin_thread_success': 'Đã bỏ ghim đoạn chat thành công',
60
+ 'chat:pin_thread_limit_title': 'Không thể ghim đoạn chat',
61
+ 'chat:pin_thread_limit_desc':
62
+ 'Bạn đã ghim số đoạn chat tối đa. Để ghim đoạn chat này, trước tiên bạn phải bỏ ghim đoạn chat khác.',
63
+ 'chat:pin_thread_limit_button': 'OK',
54
64
  'chat:view_original_message': 'Xem tin nhắn gốc',
55
65
  'chat:scroll_to_message_todo':
56
66
  'Tính năng di chuyển đến tin nhắn gốc sẽ sớm được cập nhật',
@@ -82,6 +92,7 @@ const i18nKey: Record<string, string> = {
82
92
  'chat:reply_to': 'Trả lời {{name}}',
83
93
  'yourself': 'chính mình',
84
94
  'you': 'Bạn',
95
+ 'recent': 'Gần đây',
85
96
  };
86
97
 
87
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
  }