@droppii-org/chat-mobile 0.2.6 → 0.2.8

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 (398) hide show
  1. package/lib/module/components/AttachmentPreview.js +250 -0
  2. package/lib/module/components/AttachmentPreview.js.map +1 -0
  3. package/lib/module/components/MediaViewer/index.js +2 -0
  4. package/lib/module/components/MediaViewer/index.js.map +1 -0
  5. package/lib/module/components/MediaViewerModal.js +57 -0
  6. package/lib/module/components/MediaViewerModal.js.map +1 -0
  7. package/lib/module/components/MergedImageGrid.js +173 -0
  8. package/lib/module/components/MergedImageGrid.js.map +1 -0
  9. package/lib/module/components/ThreadCard/AvatarSection.js +4 -4
  10. package/lib/module/components/ThreadCard/AvatarSection.js.map +1 -1
  11. package/lib/module/components/ThreadCard/NamePrefixIcon.js +13 -16
  12. package/lib/module/components/ThreadCard/NamePrefixIcon.js.map +1 -1
  13. package/lib/module/components/ThreadCard/ThreadCard.js +13 -33
  14. package/lib/module/components/ThreadCard/ThreadCard.js.map +1 -1
  15. package/lib/module/components/ThreadCard/thread-card.utils.js +80 -4
  16. package/lib/module/components/ThreadCard/thread-card.utils.js.map +1 -1
  17. package/lib/module/components/messages/fileMessage/index.js +26 -0
  18. package/lib/module/components/messages/fileMessage/index.js.map +1 -0
  19. package/lib/module/components/messages/imageMessage/index.js +118 -0
  20. package/lib/module/components/messages/imageMessage/index.js.map +1 -0
  21. package/lib/module/components/messages/linkMessage/index.js +122 -0
  22. package/lib/module/components/messages/linkMessage/index.js.map +1 -0
  23. package/lib/module/components/messages/mergedMessage/index.js +37 -0
  24. package/lib/module/components/messages/mergedMessage/index.js.map +1 -0
  25. package/lib/module/components/messages/styles.js +41 -0
  26. package/lib/module/components/messages/styles.js.map +1 -0
  27. package/lib/module/components/messages/textMessage/index.js +38 -0
  28. package/lib/module/components/messages/textMessage/index.js.map +1 -0
  29. package/lib/module/components/messages/types.js +14 -0
  30. package/lib/module/components/messages/types.js.map +1 -0
  31. package/lib/module/components/messages/videoMessage/index.js +110 -0
  32. package/lib/module/components/messages/videoMessage/index.js.map +1 -0
  33. package/lib/module/config/api-endpoints.js +66 -0
  34. package/lib/module/config/api-endpoints.js.map +1 -0
  35. package/lib/module/config/attachment-priority.js +81 -0
  36. package/lib/module/config/attachment-priority.js.map +1 -0
  37. package/lib/module/config/configuration.js +50 -0
  38. package/lib/module/config/configuration.js.map +1 -0
  39. package/lib/module/config/index.js +22 -0
  40. package/lib/module/config/index.js.map +1 -0
  41. package/lib/module/context/ChatContext.js +7 -6
  42. package/lib/module/context/ChatContext.js.map +1 -1
  43. package/lib/module/core/index.js +19 -1
  44. package/lib/module/core/index.js.map +1 -1
  45. package/lib/module/core/useChatListener.js +0 -14
  46. package/lib/module/core/useChatListener.js.map +1 -1
  47. package/lib/module/hooks/message/useSendMessage.js +106 -0
  48. package/lib/module/hooks/message/useSendMessage.js.map +1 -0
  49. package/lib/module/hooks/useChatMessages.js +36 -121
  50. package/lib/module/hooks/useChatMessages.js.map +1 -1
  51. package/lib/module/hooks/useConversationList.js +29 -17
  52. package/lib/module/hooks/useConversationList.js.map +1 -1
  53. package/lib/module/hooks/useImageAttachment.js +263 -0
  54. package/lib/module/hooks/useImageAttachment.js.map +1 -0
  55. package/lib/module/hooks/useLinkPreview/useLinkPreview.js +3 -2
  56. package/lib/module/hooks/useLinkPreview/useLinkPreview.js.map +1 -1
  57. package/lib/module/hooks/useMediaViewer.js +24 -0
  58. package/lib/module/hooks/useMediaViewer.js.map +1 -0
  59. package/lib/module/hooks/useSendAttachment.js +182 -0
  60. package/lib/module/hooks/useSendAttachment.js.map +1 -0
  61. package/lib/module/hooks/useVideoAttachment.js +251 -0
  62. package/lib/module/hooks/useVideoAttachment.js.map +1 -0
  63. package/lib/module/index.js +13 -1
  64. package/lib/module/index.js.map +1 -1
  65. package/lib/module/screens/MediaView/VideoPlayer.js +177 -0
  66. package/lib/module/screens/MediaView/VideoPlayer.js.map +1 -0
  67. package/lib/module/screens/MediaView/index.js +264 -0
  68. package/lib/module/screens/MediaView/index.js.map +1 -0
  69. package/lib/module/screens/chat-detail/ChatComposer.js +190 -196
  70. package/lib/module/screens/chat-detail/ChatComposer.js.map +1 -1
  71. package/lib/module/screens/chat-detail/ChatDetail.js +106 -71
  72. package/lib/module/screens/chat-detail/ChatDetail.js.map +1 -1
  73. package/lib/module/screens/chat-detail/ChatDetailHeader.js +5 -8
  74. package/lib/module/screens/chat-detail/ChatDetailHeader.js.map +1 -1
  75. package/lib/module/screens/chat-detail/ChatLinkPreview.js +1 -1
  76. package/lib/module/screens/chat-detail/ChatLinkPreview.js.map +1 -1
  77. package/lib/module/screens/chat-detail/ChatListLegend.js +5 -15
  78. package/lib/module/screens/chat-detail/ChatListLegend.js.map +1 -1
  79. package/lib/module/screens/chat-detail/components/ChatInputActions.js +51 -0
  80. package/lib/module/screens/chat-detail/components/ChatInputActions.js.map +1 -0
  81. package/lib/module/screens/chat-detail/components/ChatMessageInput.js +93 -0
  82. package/lib/module/screens/chat-detail/components/ChatMessageInput.js.map +1 -0
  83. package/lib/module/screens/chat-detail/conversationHeader.utils.js +7 -9
  84. package/lib/module/screens/chat-detail/conversationHeader.utils.js.map +1 -1
  85. package/lib/module/screens/chat-detail/hooks/useAttachmentSendHandler.js +221 -0
  86. package/lib/module/screens/chat-detail/hooks/useAttachmentSendHandler.js.map +1 -0
  87. package/lib/module/screens/chat-detail/hooks/useChatComposerAnimation.js +114 -0
  88. package/lib/module/screens/chat-detail/hooks/useChatComposerAnimation.js.map +1 -0
  89. package/lib/module/screens/chat-detail/hooks/useChatComposerState.js +26 -0
  90. package/lib/module/screens/chat-detail/hooks/useChatComposerState.js.map +1 -0
  91. package/lib/module/screens/chat-detail/index.js +0 -1
  92. package/lib/module/screens/chat-detail/index.js.map +1 -1
  93. package/lib/module/screens/chat-detail/legend/LegendChatMessage.js +32 -25
  94. package/lib/module/screens/chat-detail/legend/LegendChatMessage.js.map +1 -1
  95. package/lib/module/screens/chat-detail/legend/messageTypes.js +15 -0
  96. package/lib/module/screens/chat-detail/legend/messageTypes.js.map +1 -0
  97. package/lib/module/screens/inbox/MessagesTab.js.map +1 -1
  98. package/lib/module/services/attachmentHandlers/fileAttachmentHandler.js +61 -0
  99. package/lib/module/services/attachmentHandlers/fileAttachmentHandler.js.map +1 -0
  100. package/lib/module/services/attachmentHandlers/imageAttachmentHandler.js +54 -0
  101. package/lib/module/services/attachmentHandlers/imageAttachmentHandler.js.map +1 -0
  102. package/lib/module/services/attachmentHandlers/index.js +12 -0
  103. package/lib/module/services/attachmentHandlers/index.js.map +1 -0
  104. package/lib/module/services/attachmentHandlers/videoAttachmentHandler.js +85 -0
  105. package/lib/module/services/attachmentHandlers/videoAttachmentHandler.js.map +1 -0
  106. package/lib/module/services/attachmentOrchestrator.js +225 -0
  107. package/lib/module/services/attachmentOrchestrator.js.map +1 -0
  108. package/lib/module/services/auth.js +35 -0
  109. package/lib/module/services/auth.js.map +1 -0
  110. package/lib/module/services/endpoints.js +20 -1
  111. package/lib/module/services/endpoints.js.map +1 -1
  112. package/lib/module/services/imageUpload.js +126 -0
  113. package/lib/module/services/imageUpload.js.map +1 -0
  114. package/lib/module/store/conversation.js +1 -1
  115. package/lib/module/store/conversation.js.map +1 -1
  116. package/lib/module/store/message.js +45 -0
  117. package/lib/module/store/message.js.map +1 -0
  118. package/lib/module/translation/resources/i18n.js +22 -2
  119. package/lib/module/translation/resources/i18n.js.map +1 -1
  120. package/lib/module/types/attachment.js +2 -0
  121. package/lib/module/types/attachment.js.map +1 -0
  122. package/lib/module/types/attachmentHandler.js +20 -0
  123. package/lib/module/types/attachmentHandler.js.map +1 -0
  124. package/lib/module/types/chat.js +2 -7
  125. package/lib/module/types/chat.js.map +1 -1
  126. package/lib/module/types/imageUpload.js +2 -0
  127. package/lib/module/types/imageUpload.js.map +1 -0
  128. package/lib/module/types/message.js +1 -0
  129. package/lib/module/types/message.js.map +1 -1
  130. package/lib/module/utils/chatImageDimens.js +148 -0
  131. package/lib/module/utils/chatImageDimens.js.map +1 -0
  132. package/lib/module/utils/conversation.js +34 -13
  133. package/lib/module/utils/conversation.js.map +1 -1
  134. package/lib/module/utils/device.js +65 -0
  135. package/lib/module/utils/device.js.map +1 -0
  136. package/lib/module/utils/imageUrlOptimizer.js +41 -0
  137. package/lib/module/utils/imageUrlOptimizer.js.map +1 -0
  138. package/lib/module/utils/imageUtils.js +69 -0
  139. package/lib/module/utils/imageUtils.js.map +1 -0
  140. package/lib/module/utils/legendListMessage.js +0 -3
  141. package/lib/module/utils/legendListMessage.js.map +1 -1
  142. package/lib/module/utils/message.js +5 -8
  143. package/lib/module/utils/message.js.map +1 -1
  144. package/lib/module/utils/resolveMessageType.js +3 -0
  145. package/lib/module/utils/resolveMessageType.js.map +1 -1
  146. package/lib/module/utils/ui.js +17 -0
  147. package/lib/module/utils/ui.js.map +1 -0
  148. package/lib/module/utils/url.js +3 -3
  149. package/lib/module/utils/url.js.map +1 -1
  150. package/lib/module/utils/videoThumbnail.js +62 -0
  151. package/lib/module/utils/videoThumbnail.js.map +1 -0
  152. package/lib/typescript/src/components/AttachmentPreview.d.ts +28 -0
  153. package/lib/typescript/src/components/AttachmentPreview.d.ts.map +1 -0
  154. package/lib/typescript/src/components/MediaViewer/index.d.ts +1 -0
  155. package/lib/typescript/src/components/MediaViewer/index.d.ts.map +1 -0
  156. package/lib/typescript/src/components/MediaViewerModal.d.ts +10 -0
  157. package/lib/typescript/src/components/MediaViewerModal.d.ts.map +1 -0
  158. package/lib/typescript/src/components/MergedImageGrid.d.ts +16 -0
  159. package/lib/typescript/src/components/MergedImageGrid.d.ts.map +1 -0
  160. package/lib/typescript/src/components/ThreadCard/AvatarSection.d.ts +2 -2
  161. package/lib/typescript/src/components/ThreadCard/AvatarSection.d.ts.map +1 -1
  162. package/lib/typescript/src/components/ThreadCard/NamePrefixIcon.d.ts +3 -4
  163. package/lib/typescript/src/components/ThreadCard/NamePrefixIcon.d.ts.map +1 -1
  164. package/lib/typescript/src/components/ThreadCard/ThreadCard.d.ts.map +1 -1
  165. package/lib/typescript/src/components/ThreadCard/thread-card.utils.d.ts.map +1 -1
  166. package/lib/typescript/src/components/messages/fileMessage/index.d.ts +3 -0
  167. package/lib/typescript/src/components/messages/fileMessage/index.d.ts.map +1 -0
  168. package/lib/typescript/src/components/messages/imageMessage/index.d.ts +3 -0
  169. package/lib/typescript/src/components/messages/imageMessage/index.d.ts.map +1 -0
  170. package/lib/typescript/src/components/messages/linkMessage/index.d.ts +9 -0
  171. package/lib/typescript/src/components/messages/linkMessage/index.d.ts.map +1 -0
  172. package/lib/typescript/src/components/messages/mergedMessage/index.d.ts +3 -0
  173. package/lib/typescript/src/components/messages/mergedMessage/index.d.ts.map +1 -0
  174. package/lib/typescript/src/components/messages/styles.d.ts +36 -0
  175. package/lib/typescript/src/components/messages/styles.d.ts.map +1 -0
  176. package/lib/typescript/src/components/messages/textMessage/index.d.ts +9 -0
  177. package/lib/typescript/src/components/messages/textMessage/index.d.ts.map +1 -0
  178. package/lib/typescript/src/components/messages/types.d.ts +10 -0
  179. package/lib/typescript/src/components/messages/types.d.ts.map +1 -0
  180. package/lib/typescript/src/components/messages/videoMessage/index.d.ts +3 -0
  181. package/lib/typescript/src/components/messages/videoMessage/index.d.ts.map +1 -0
  182. package/lib/typescript/src/config/api-endpoints.d.ts +40 -0
  183. package/lib/typescript/src/config/api-endpoints.d.ts.map +1 -0
  184. package/lib/typescript/src/config/attachment-priority.d.ts +31 -0
  185. package/lib/typescript/src/config/attachment-priority.d.ts.map +1 -0
  186. package/lib/typescript/src/config/configuration.d.ts +30 -0
  187. package/lib/typescript/src/config/configuration.d.ts.map +1 -0
  188. package/lib/typescript/src/config/index.d.ts +15 -0
  189. package/lib/typescript/src/config/index.d.ts.map +1 -0
  190. package/lib/typescript/src/context/ChatContext.d.ts +1 -1
  191. package/lib/typescript/src/context/ChatContext.d.ts.map +1 -1
  192. package/lib/typescript/src/core/index.d.ts +13 -1
  193. package/lib/typescript/src/core/index.d.ts.map +1 -1
  194. package/lib/typescript/src/core/useChatListener.d.ts.map +1 -1
  195. package/lib/typescript/src/hooks/message/useSendMessage.d.ts +12 -0
  196. package/lib/typescript/src/hooks/message/useSendMessage.d.ts.map +1 -0
  197. package/lib/typescript/src/hooks/useChatMessages.d.ts +0 -1
  198. package/lib/typescript/src/hooks/useChatMessages.d.ts.map +1 -1
  199. package/lib/typescript/src/hooks/useConversationList.d.ts +2 -1
  200. package/lib/typescript/src/hooks/useConversationList.d.ts.map +1 -1
  201. package/lib/typescript/src/hooks/useImageAttachment.d.ts +20 -0
  202. package/lib/typescript/src/hooks/useImageAttachment.d.ts.map +1 -0
  203. package/lib/typescript/src/hooks/useLinkPreview/useLinkPreview.d.ts.map +1 -1
  204. package/lib/typescript/src/hooks/useMediaViewer.d.ts +13 -0
  205. package/lib/typescript/src/hooks/useMediaViewer.d.ts.map +1 -0
  206. package/lib/typescript/src/hooks/useSendAttachment.d.ts +59 -0
  207. package/lib/typescript/src/hooks/useSendAttachment.d.ts.map +1 -0
  208. package/lib/typescript/src/hooks/useVideoAttachment.d.ts +29 -0
  209. package/lib/typescript/src/hooks/useVideoAttachment.d.ts.map +1 -0
  210. package/lib/typescript/src/index.d.ts +14 -1
  211. package/lib/typescript/src/index.d.ts.map +1 -1
  212. package/lib/typescript/src/screens/MediaView/VideoPlayer.d.ts +12 -0
  213. package/lib/typescript/src/screens/MediaView/VideoPlayer.d.ts.map +1 -0
  214. package/lib/typescript/src/screens/MediaView/index.d.ts +11 -0
  215. package/lib/typescript/src/screens/MediaView/index.d.ts.map +1 -0
  216. package/lib/typescript/src/screens/chat-detail/ChatComposer.d.ts +1 -1
  217. package/lib/typescript/src/screens/chat-detail/ChatComposer.d.ts.map +1 -1
  218. package/lib/typescript/src/screens/chat-detail/ChatDetail.d.ts +1 -1
  219. package/lib/typescript/src/screens/chat-detail/ChatDetail.d.ts.map +1 -1
  220. package/lib/typescript/src/screens/chat-detail/ChatDetailHeader.d.ts +1 -1
  221. package/lib/typescript/src/screens/chat-detail/ChatDetailHeader.d.ts.map +1 -1
  222. package/lib/typescript/src/screens/chat-detail/ChatListLegend.d.ts +1 -1
  223. package/lib/typescript/src/screens/chat-detail/ChatListLegend.d.ts.map +1 -1
  224. package/lib/typescript/src/screens/chat-detail/components/ChatInputActions.d.ts +8 -0
  225. package/lib/typescript/src/screens/chat-detail/components/ChatInputActions.d.ts.map +1 -0
  226. package/lib/typescript/src/screens/chat-detail/components/ChatMessageInput.d.ts +15 -0
  227. package/lib/typescript/src/screens/chat-detail/components/ChatMessageInput.d.ts.map +1 -0
  228. package/lib/typescript/src/screens/chat-detail/conversationHeader.utils.d.ts +1 -1
  229. package/lib/typescript/src/screens/chat-detail/conversationHeader.utils.d.ts.map +1 -1
  230. package/lib/typescript/src/screens/chat-detail/hooks/useAttachmentSendHandler.d.ts +23 -0
  231. package/lib/typescript/src/screens/chat-detail/hooks/useAttachmentSendHandler.d.ts.map +1 -0
  232. package/lib/typescript/src/screens/chat-detail/hooks/useChatComposerAnimation.d.ts +15 -0
  233. package/lib/typescript/src/screens/chat-detail/hooks/useChatComposerAnimation.d.ts.map +1 -0
  234. package/lib/typescript/src/screens/chat-detail/hooks/useChatComposerState.d.ts +13 -0
  235. package/lib/typescript/src/screens/chat-detail/hooks/useChatComposerState.d.ts.map +1 -0
  236. package/lib/typescript/src/screens/chat-detail/index.d.ts +0 -2
  237. package/lib/typescript/src/screens/chat-detail/index.d.ts.map +1 -1
  238. package/lib/typescript/src/screens/chat-detail/legend/LegendChatMessage.d.ts +3 -3
  239. package/lib/typescript/src/screens/chat-detail/legend/LegendChatMessage.d.ts.map +1 -1
  240. package/lib/typescript/src/screens/chat-detail/legend/messageTypes.d.ts +13 -0
  241. package/lib/typescript/src/screens/chat-detail/legend/messageTypes.d.ts.map +1 -0
  242. package/lib/typescript/src/screens/chat-detail/types.d.ts +10 -8
  243. package/lib/typescript/src/screens/chat-detail/types.d.ts.map +1 -1
  244. package/lib/typescript/src/services/attachmentHandlers/fileAttachmentHandler.d.ts +22 -0
  245. package/lib/typescript/src/services/attachmentHandlers/fileAttachmentHandler.d.ts.map +1 -0
  246. package/lib/typescript/src/services/attachmentHandlers/imageAttachmentHandler.d.ts +3 -0
  247. package/lib/typescript/src/services/attachmentHandlers/imageAttachmentHandler.d.ts.map +1 -0
  248. package/lib/typescript/src/services/attachmentHandlers/index.d.ts +5 -0
  249. package/lib/typescript/src/services/attachmentHandlers/index.d.ts.map +1 -0
  250. package/lib/typescript/src/services/attachmentHandlers/videoAttachmentHandler.d.ts +31 -0
  251. package/lib/typescript/src/services/attachmentHandlers/videoAttachmentHandler.d.ts.map +1 -0
  252. package/lib/typescript/src/services/attachmentOrchestrator.d.ts +5 -0
  253. package/lib/typescript/src/services/attachmentOrchestrator.d.ts.map +1 -0
  254. package/lib/typescript/src/services/auth.d.ts +19 -0
  255. package/lib/typescript/src/services/auth.d.ts.map +1 -0
  256. package/lib/typescript/src/services/endpoints.d.ts +11 -1
  257. package/lib/typescript/src/services/endpoints.d.ts.map +1 -1
  258. package/lib/typescript/src/services/imageUpload.d.ts +7 -0
  259. package/lib/typescript/src/services/imageUpload.d.ts.map +1 -0
  260. package/lib/typescript/src/store/message.d.ts +3 -0
  261. package/lib/typescript/src/store/message.d.ts.map +1 -0
  262. package/lib/typescript/src/translation/resources/i18n.d.ts.map +1 -1
  263. package/lib/typescript/src/types/attachment.d.ts +72 -0
  264. package/lib/typescript/src/types/attachment.d.ts.map +1 -0
  265. package/lib/typescript/src/types/attachmentHandler.d.ts +13 -0
  266. package/lib/typescript/src/types/attachmentHandler.d.ts.map +1 -0
  267. package/lib/typescript/src/types/chat.d.ts +28 -27
  268. package/lib/typescript/src/types/chat.d.ts.map +1 -1
  269. package/lib/typescript/src/types/common.d.ts +1 -0
  270. package/lib/typescript/src/types/common.d.ts.map +1 -1
  271. package/lib/typescript/src/types/imageUpload.d.ts +26 -0
  272. package/lib/typescript/src/types/imageUpload.d.ts.map +1 -0
  273. package/lib/typescript/src/types/message.d.ts +1 -0
  274. package/lib/typescript/src/types/message.d.ts.map +1 -1
  275. package/lib/typescript/src/utils/chatImageDimens.d.ts +34 -0
  276. package/lib/typescript/src/utils/chatImageDimens.d.ts.map +1 -0
  277. package/lib/typescript/src/utils/conversation.d.ts +3 -2
  278. package/lib/typescript/src/utils/conversation.d.ts.map +1 -1
  279. package/lib/typescript/src/utils/device.d.ts +7 -0
  280. package/lib/typescript/src/utils/device.d.ts.map +1 -0
  281. package/lib/typescript/src/utils/imageUrlOptimizer.d.ts +12 -0
  282. package/lib/typescript/src/utils/imageUrlOptimizer.d.ts.map +1 -0
  283. package/lib/typescript/src/utils/imageUtils.d.ts +9 -0
  284. package/lib/typescript/src/utils/imageUtils.d.ts.map +1 -0
  285. package/lib/typescript/src/utils/legendListMessage.d.ts +0 -2
  286. package/lib/typescript/src/utils/legendListMessage.d.ts.map +1 -1
  287. package/lib/typescript/src/utils/message.d.ts.map +1 -1
  288. package/lib/typescript/src/utils/resolveMessageType.d.ts.map +1 -1
  289. package/lib/typescript/src/utils/ui.d.ts +13 -0
  290. package/lib/typescript/src/utils/ui.d.ts.map +1 -0
  291. package/lib/typescript/src/utils/url.d.ts +1 -1
  292. package/lib/typescript/src/utils/url.d.ts.map +1 -1
  293. package/lib/typescript/src/utils/videoThumbnail.d.ts +16 -0
  294. package/lib/typescript/src/utils/videoThumbnail.d.ts.map +1 -0
  295. package/package.json +15 -3
  296. package/src/components/AttachmentPreview.tsx +304 -0
  297. package/src/components/MediaViewer/index.tsx +0 -0
  298. package/src/components/MediaViewerModal.tsx +70 -0
  299. package/src/components/MergedImageGrid.tsx +238 -0
  300. package/src/components/ThreadCard/AvatarSection.tsx +5 -8
  301. package/src/components/ThreadCard/NamePrefixIcon.tsx +27 -38
  302. package/src/components/ThreadCard/ThreadCard.tsx +16 -30
  303. package/src/components/ThreadCard/thread-card.utils.ts +95 -4
  304. package/src/components/messages/fileMessage/index.tsx +30 -0
  305. package/src/components/messages/imageMessage/index.tsx +137 -0
  306. package/src/components/messages/linkMessage/index.tsx +162 -0
  307. package/src/components/messages/mergedMessage/index.tsx +45 -0
  308. package/src/components/messages/styles.ts +39 -0
  309. package/src/components/messages/textMessage/index.tsx +53 -0
  310. package/src/components/messages/types.ts +22 -0
  311. package/src/components/messages/videoMessage/index.tsx +120 -0
  312. package/src/config/api-endpoints.ts +72 -0
  313. package/src/config/attachment-priority.ts +93 -0
  314. package/src/config/configuration.ts +50 -0
  315. package/src/config/index.ts +19 -0
  316. package/src/context/ChatContext.tsx +12 -4
  317. package/src/core/index.ts +25 -1
  318. package/src/core/useChatListener.ts +0 -21
  319. package/src/hooks/message/useSendMessage.ts +143 -0
  320. package/src/hooks/useChatMessages.ts +69 -161
  321. package/src/hooks/useConversationList.ts +34 -16
  322. package/src/hooks/useImageAttachment.ts +348 -0
  323. package/src/hooks/useLinkPreview/useLinkPreview.ts +3 -2
  324. package/src/hooks/useMediaViewer.ts +32 -0
  325. package/src/hooks/useSendAttachment.ts +295 -0
  326. package/src/hooks/useVideoAttachment.ts +334 -0
  327. package/src/index.tsx +13 -1
  328. package/src/screens/MediaView/VideoPlayer.tsx +211 -0
  329. package/src/screens/MediaView/index.tsx +327 -0
  330. package/src/screens/chat-detail/ChatComposer.tsx +206 -271
  331. package/src/screens/chat-detail/ChatDetail.tsx +164 -104
  332. package/src/screens/chat-detail/ChatDetailHeader.tsx +4 -10
  333. package/src/screens/chat-detail/ChatLinkPreview.tsx +1 -1
  334. package/src/screens/chat-detail/ChatListLegend.tsx +10 -13
  335. package/src/screens/chat-detail/components/ChatInputActions.tsx +71 -0
  336. package/src/screens/chat-detail/components/ChatMessageInput.tsx +127 -0
  337. package/src/screens/chat-detail/conversationHeader.utils.ts +11 -14
  338. package/src/screens/chat-detail/hooks/useAttachmentSendHandler.ts +291 -0
  339. package/src/screens/chat-detail/hooks/useChatComposerAnimation.ts +184 -0
  340. package/src/screens/chat-detail/hooks/useChatComposerState.ts +40 -0
  341. package/src/screens/chat-detail/index.ts +0 -2
  342. package/src/screens/chat-detail/legend/LegendChatMessage.tsx +44 -39
  343. package/src/screens/chat-detail/legend/messageTypes.tsx +13 -0
  344. package/src/screens/chat-detail/types.ts +11 -9
  345. package/src/screens/inbox/MessagesTab.tsx +1 -1
  346. package/src/services/attachmentHandlers/fileAttachmentHandler.ts +78 -0
  347. package/src/services/attachmentHandlers/imageAttachmentHandler.ts +54 -0
  348. package/src/services/attachmentHandlers/index.ts +10 -0
  349. package/src/services/attachmentHandlers/videoAttachmentHandler.ts +114 -0
  350. package/src/services/attachmentOrchestrator.ts +300 -0
  351. package/src/services/auth.ts +34 -0
  352. package/src/services/endpoints.ts +24 -1
  353. package/src/services/imageUpload.ts +162 -0
  354. package/src/store/conversation.ts +1 -1
  355. package/src/store/message.ts +44 -0
  356. package/src/translation/resources/i18n.ts +22 -2
  357. package/src/types/attachment.ts +85 -0
  358. package/src/types/attachmentHandler.ts +31 -0
  359. package/src/types/chat.ts +31 -30
  360. package/src/types/common.ts +1 -0
  361. package/src/types/imageUpload.ts +28 -0
  362. package/src/types/message.ts +1 -0
  363. package/src/utils/chatImageDimens.ts +178 -0
  364. package/src/utils/conversation.ts +44 -17
  365. package/src/utils/device.ts +73 -0
  366. package/src/utils/imageUrlOptimizer.ts +56 -0
  367. package/src/utils/imageUtils.ts +76 -0
  368. package/src/utils/legendListMessage.ts +0 -5
  369. package/src/utils/message.ts +10 -12
  370. package/src/utils/resolveMessageType.ts +2 -0
  371. package/src/utils/ui.ts +19 -0
  372. package/src/utils/url.ts +3 -3
  373. package/src/utils/videoThumbnail.ts +85 -0
  374. package/lib/module/screens/chat-detail/ChatList.js +0 -147
  375. package/lib/module/screens/chat-detail/ChatList.js.map +0 -1
  376. package/lib/module/screens/chat-detail/ChatTextBubble.js +0 -62
  377. package/lib/module/screens/chat-detail/ChatTextBubble.js.map +0 -1
  378. package/lib/module/screens/chat-detail/legend/message-types.js +0 -122
  379. package/lib/module/screens/chat-detail/legend/message-types.js.map +0 -1
  380. package/lib/module/screens/chat-detail/messages/ChatMessageBubble.js +0 -24
  381. package/lib/module/screens/chat-detail/messages/ChatMessageBubble.js.map +0 -1
  382. package/lib/module/screens/chat-detail/messages/types.js +0 -4
  383. package/lib/module/screens/chat-detail/messages/types.js.map +0 -1
  384. package/lib/typescript/src/screens/chat-detail/ChatList.d.ts +0 -3
  385. package/lib/typescript/src/screens/chat-detail/ChatList.d.ts.map +0 -1
  386. package/lib/typescript/src/screens/chat-detail/ChatTextBubble.d.ts +0 -3
  387. package/lib/typescript/src/screens/chat-detail/ChatTextBubble.d.ts.map +0 -1
  388. package/lib/typescript/src/screens/chat-detail/legend/message-types.d.ts +0 -12
  389. package/lib/typescript/src/screens/chat-detail/legend/message-types.d.ts.map +0 -1
  390. package/lib/typescript/src/screens/chat-detail/messages/ChatMessageBubble.d.ts +0 -3
  391. package/lib/typescript/src/screens/chat-detail/messages/ChatMessageBubble.d.ts.map +0 -1
  392. package/lib/typescript/src/screens/chat-detail/messages/types.d.ts +0 -13
  393. package/lib/typescript/src/screens/chat-detail/messages/types.d.ts.map +0 -1
  394. package/src/screens/chat-detail/ChatList.tsx +0 -190
  395. package/src/screens/chat-detail/ChatTextBubble.tsx +0 -73
  396. package/src/screens/chat-detail/legend/message-types.tsx +0 -149
  397. package/src/screens/chat-detail/messages/ChatMessageBubble.tsx +0 -23
  398. package/src/screens/chat-detail/messages/types.ts +0 -14
@@ -0,0 +1,70 @@
1
+ import { forwardRef, useImperativeHandle } from 'react';
2
+ import { Modal, StyleSheet } from 'react-native';
3
+ import MediaViewerScreen from '../screens/MediaView';
4
+ import { useMediaViewer, type MediaItem } from '../hooks/useMediaViewer';
5
+
6
+ export interface MediaViewerModalHandle {
7
+ show: (items: MediaItem[], index?: number) => void;
8
+ }
9
+
10
+ interface MediaViewerModalProps {
11
+ onDismiss?: () => void;
12
+ }
13
+
14
+ export const MediaViewerModal = forwardRef<
15
+ MediaViewerModalHandle,
16
+ MediaViewerModalProps
17
+ >(({ onDismiss }, ref) => {
18
+ const { visible, mediaList, initIndex, show, hide } = useMediaViewer();
19
+
20
+ // Expose show method to parent via ref
21
+ useImperativeHandle(
22
+ ref,
23
+ () => ({
24
+ show,
25
+ }),
26
+ [show]
27
+ );
28
+
29
+ const handleDismiss = () => {
30
+ hide();
31
+ onDismiss?.();
32
+ };
33
+
34
+ if (!visible || mediaList.length === 0) {
35
+ return null;
36
+ }
37
+
38
+ const images = mediaList.map((item) => ({
39
+ url: item.url,
40
+ isVideo: item.isVideo || false,
41
+ }));
42
+
43
+ return (
44
+ <Modal
45
+ visible={visible}
46
+ transparent={false}
47
+ statusBarTranslucent={true}
48
+ style={styles.modal}
49
+ presentationStyle="overFullScreen"
50
+ animationType="fade"
51
+ onRequestClose={handleDismiss}
52
+ >
53
+ <MediaViewerScreen
54
+ images={images}
55
+ initIndex={initIndex}
56
+ pagination={images.length > 1}
57
+ onDismiss={handleDismiss}
58
+ download
59
+ />
60
+ </Modal>
61
+ );
62
+ });
63
+
64
+ MediaViewerModal.displayName = 'MediaViewerModal';
65
+
66
+ const styles = StyleSheet.create({
67
+ modal: {
68
+ flex: 1,
69
+ },
70
+ });
@@ -0,0 +1,238 @@
1
+ import { memo, useMemo, useState, useCallback } from 'react';
2
+ import { StyleSheet, useWindowDimensions } from 'react-native';
3
+ import { KContainer, KImage, KLabel, KColors } from '@droppii/libs';
4
+ import ChatImageDimens from '../utils/chatImageDimens';
5
+ import type { MediaItem } from '../hooks/useMediaViewer';
6
+
7
+ interface MergedImageGridProps {
8
+ images: Array<{
9
+ pictureElem?: any;
10
+ }>;
11
+ maxDisplay?: number;
12
+ onMediaPress?: (items: MediaItem[], index?: number) => void;
13
+ }
14
+
15
+ /**
16
+ * Generic image grid for merged messages
17
+ * Layout: 1 image (1x1), 2 images (1x2), 3 images (1x3), 4+ images (2x2)
18
+ * Shows "+N more" overlay on last cell if images exceed limit
19
+ */
20
+ export const MergedImageGrid = memo(
21
+ ({ images, maxDisplay = 4, onMediaPress }: MergedImageGridProps) => {
22
+ const windowWidth = useWindowDimensions().width;
23
+ const [loadingState, setLoadingState] = useState<Record<number, boolean>>(
24
+ {}
25
+ );
26
+
27
+ const displayedImages = useMemo(
28
+ () => images.slice(0, maxDisplay),
29
+ [images, maxDisplay]
30
+ );
31
+ const hiddenCount = Math.max(0, images.length - maxDisplay);
32
+
33
+ // Calculate single image dimensions respecting aspect ratio and 80% width limit
34
+ const singleImageSize = useMemo(() => {
35
+ if (displayedImages.length !== 1) return null;
36
+
37
+ const image = displayedImages[0];
38
+ const pictureElem = image?.pictureElem;
39
+ const imgWidth =
40
+ pictureElem?.width || pictureElem?.bigPicture?.width || 0;
41
+ const imgHeight =
42
+ pictureElem?.height || pictureElem?.bigPicture?.height || 0;
43
+
44
+ const maxWidth = Math.floor(windowWidth * 0.8);
45
+ const aspectRatio = imgWidth && imgHeight ? imgWidth / imgHeight : 1;
46
+
47
+ // Calculate dimensions respecting aspect ratio and max width
48
+ let finalWidth = maxWidth;
49
+ let finalHeight = maxWidth / aspectRatio;
50
+
51
+ // If height exceeds reasonable limit, scale down
52
+ const maxHeight = 400;
53
+ if (finalHeight > maxHeight) {
54
+ finalHeight = maxHeight;
55
+ finalWidth = finalHeight * aspectRatio;
56
+ }
57
+
58
+ return {
59
+ width: Math.round(finalWidth),
60
+ height: Math.round(finalHeight),
61
+ };
62
+ }, [displayedImages, windowWidth]);
63
+
64
+ const mediaItems = useMemo(
65
+ () =>
66
+ images
67
+ .map((image) => {
68
+ const pictureElem = image.pictureElem;
69
+ const imageUrl =
70
+ pictureElem?.snapshotPicture?.url ||
71
+ pictureElem?.bigPicture?.url ||
72
+ pictureElem?.sourcePicture?.url;
73
+ return { url: imageUrl };
74
+ })
75
+ .filter((item): item is MediaItem => Boolean(item.url)),
76
+ [images]
77
+ );
78
+
79
+ const handleImageLoadEnd = useCallback((index: number) => {
80
+ setLoadingState((prev) => ({
81
+ ...prev,
82
+ [index]: false,
83
+ }));
84
+ }, []);
85
+
86
+ const handleImagePress = useCallback(
87
+ (index: number) => {
88
+ onMediaPress?.(mediaItems, index);
89
+ },
90
+ [onMediaPress, mediaItems]
91
+ );
92
+
93
+ const initializeLoading = useMemo(() => {
94
+ const initial: Record<number, boolean> = {};
95
+ displayedImages.forEach((_, index) => {
96
+ initial[index] = true;
97
+ });
98
+ return initial;
99
+ }, [displayedImages]);
100
+
101
+ useMemo(() => {
102
+ setLoadingState(initializeLoading);
103
+ }, [initializeLoading]);
104
+
105
+ if (displayedImages.length === 0) {
106
+ return null;
107
+ }
108
+
109
+ // Calculate columns based on image count
110
+ let columns = 1;
111
+ if (displayedImages.length === 2) {
112
+ columns = 2; // 2 images: horizontal layout (1x2)
113
+ } else if (displayedImages.length === 3) {
114
+ columns = 3; // 3 images: horizontal layout (1x3)
115
+ } else if (displayedImages.length >= 4) {
116
+ columns = 2; // 4+ images: grid layout (2x2)
117
+ }
118
+
119
+ // Use calculated aspect ratio for single image, 100x100 for multiple images
120
+ const cellSize =
121
+ displayedImages.length === 1 && singleImageSize
122
+ ? singleImageSize.width
123
+ : 100;
124
+ const cellHeight =
125
+ displayedImages.length === 1 && singleImageSize
126
+ ? singleImageSize.height
127
+ : cellSize;
128
+ const gap = 4;
129
+ const totalWidth = cellSize * columns + gap * (columns - 1);
130
+
131
+ return (
132
+ <KContainer.View
133
+ style={[
134
+ styles.grid,
135
+ {
136
+ width: totalWidth,
137
+ },
138
+ ]}
139
+ >
140
+ {displayedImages.map((image, index) => {
141
+ const pictureElem = image.pictureElem;
142
+ const imageUrl =
143
+ pictureElem?.snapshotPicture?.url ||
144
+ pictureElem?.bigPicture?.url ||
145
+ pictureElem?.sourcePicture?.url;
146
+
147
+ if (!imageUrl) {
148
+ return null;
149
+ }
150
+
151
+ // Use dynamic optimization based on calculated dimensions
152
+ const optimizedUrl =
153
+ ChatImageDimens.getOptimizedImageUrlWithDimensions(
154
+ imageUrl,
155
+ cellSize,
156
+ cellHeight
157
+ );
158
+
159
+ const isLastCell = index === displayedImages.length - 1;
160
+ const showHiddenCount = isLastCell && hiddenCount > 0;
161
+ const isImageLoading = loadingState[index] ?? true;
162
+
163
+ return (
164
+ <KContainer.Touchable
165
+ key={`merged-image-${index}`}
166
+ onPress={() => handleImagePress(index)}
167
+ style={[
168
+ styles.imageCell,
169
+ {
170
+ width: cellSize,
171
+ height: cellHeight,
172
+ },
173
+ ]}
174
+ >
175
+ <KImage.Base
176
+ uri={optimizedUrl}
177
+ width={cellSize}
178
+ height={cellHeight}
179
+ style={styles.image}
180
+ onLoadEnd={() => handleImageLoadEnd(index)}
181
+ />
182
+
183
+ {isImageLoading && <KContainer.View style={styles.skeleton} />}
184
+
185
+ {/* Hidden count overlay with +N text */}
186
+ {showHiddenCount && (
187
+ <KContainer.View style={styles.hiddenOverlay} center>
188
+ <KLabel.Text typo="TextMdBold" color={KColors.white}>
189
+ +{hiddenCount}
190
+ </KLabel.Text>
191
+ </KContainer.View>
192
+ )}
193
+ </KContainer.Touchable>
194
+ );
195
+ })}
196
+ </KContainer.View>
197
+ );
198
+ }
199
+ );
200
+
201
+ MergedImageGrid.displayName = 'MergedImageGrid';
202
+
203
+ const styles = StyleSheet.create({
204
+ grid: {
205
+ flexDirection: 'row',
206
+ flexWrap: 'wrap',
207
+ gap: 4,
208
+ justifyContent: 'flex-start',
209
+ alignItems: 'flex-start',
210
+ },
211
+ imageCell: {
212
+ position: 'relative',
213
+ overflow: 'hidden',
214
+ borderRadius: 8,
215
+ backgroundColor: '#f0f0f0',
216
+ },
217
+ image: {
218
+ width: '100%',
219
+ height: '100%',
220
+ },
221
+ skeleton: {
222
+ position: 'absolute',
223
+ top: 0,
224
+ left: 0,
225
+ right: 0,
226
+ bottom: 0,
227
+ backgroundColor: '#f0f0f0',
228
+ borderRadius: 8,
229
+ },
230
+ hiddenOverlay: {
231
+ position: 'absolute',
232
+ top: 0,
233
+ left: 0,
234
+ right: 0,
235
+ bottom: 0,
236
+ backgroundColor: 'rgba(0, 0, 0, 0.5)',
237
+ },
238
+ });
@@ -1,21 +1,18 @@
1
1
  import { memo } from 'react';
2
2
  import { Avatar } from '../Avatar';
3
- import { DChatCategory } from '../../types/chat';
4
3
  import type { DConversationItem } from '../../types/chat';
4
+ import { PeerType } from '@droppii/openim-rn-client-sdk';
5
5
 
6
6
  interface AvatarSectionProps extends Partial<
7
- Pick<DConversationItem, 'chatCategory' | 'applicationType' | 'chatType'>
7
+ Pick<DConversationItem, 'peerType' | 'applicationType'>
8
8
  > {
9
9
  avatar: string | null;
10
10
  fullName: string;
11
11
  }
12
12
 
13
13
  export const AvatarSection = memo(
14
- ({ avatar, fullName, chatCategory, applicationType }: AvatarSectionProps) => {
15
- if (
16
- chatCategory === DChatCategory.BIZ_BOT_CRM ||
17
- chatCategory === DChatCategory.BIZ_BOT_PDP
18
- ) {
14
+ ({ avatar, fullName, peerType, applicationType }: AvatarSectionProps) => {
15
+ if (peerType === PeerType.Bot) {
19
16
  return (
20
17
  <Avatar
21
18
  source={avatar}
@@ -25,7 +22,7 @@ export const AvatarSection = memo(
25
22
  );
26
23
  }
27
24
 
28
- if (applicationType === 'MALL') {
25
+ if (peerType === PeerType.Customer || applicationType === 'MALL') {
29
26
  return (
30
27
  <Avatar
31
28
  source={avatar}
@@ -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
- chatCategory?: DChatCategory;
16
- chatType?: DChatType;
15
+ peerType?: PeerType | string;
17
16
  }
18
17
 
19
- export const NamePrefixIcon = memo(
20
- ({ chatCategory, chatType }: NamePrefixIconProps) => {
21
- if (chatCategory === DChatCategory.BIZ_BOT_CRM) {
22
- return (
23
- <KContainer.View marginR="0.25rem">
24
- <Image source={Images.ICON_DROPPII} style={styles.icon} />
25
- </KContainer.View>
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
- return null;
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 { StyleSheet, type GestureResponderEvent } from 'react-native';
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
- peer,
20
- chatCategory,
17
+ peerType,
18
+ showName,
19
+ faceURL,
21
20
  lastMessage,
22
21
  unreadCount = 0,
23
- isMuted,
24
- pinnedAt,
22
+ recvMsgOpt,
23
+ isPinned,
25
24
  applicationType,
26
- chatType,
27
25
  latestMsgSendTime,
28
26
  } = useConversation(item) ?? {};
29
27
 
30
- const fullName = peer?.fullName ?? peer?.username ?? '';
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={peer?.avatar ?? null}
54
+ avatar={faceURL ?? null}
56
55
  fullName={fullName}
57
- chatCategory={chatCategory}
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 chatCategory={chatCategory} chatType={chatType} />
67
- <KContainer.VisibleView
68
- visible={
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={!!isMuted}>
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(pinnedAt)}>
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
- });
@@ -1,5 +1,6 @@
1
1
  import { MessageType } from '@droppii/openim-rn-client-sdk';
2
2
  import type { DMessageItem } from '../../types/chat';
3
+ import { DChatMessageType } from '../../types/message';
3
4
 
4
5
  const extractTextContent = (message: DMessageItem): string => {
5
6
  if (message.textElem?.content) return message.textElem.content;
@@ -11,18 +12,108 @@ const extractTextContent = (message: DMessageItem): string => {
11
12
  }
12
13
  };
13
14
 
15
+ const formatDuration = (seconds: number): string => {
16
+ const mins = Math.floor(seconds / 60);
17
+ const secs = seconds % 60;
18
+ return `${mins}:${secs.toString().padStart(2, '0')}`;
19
+ };
20
+
21
+ const getMessagePreview = (message: DMessageItem): string => {
22
+ // Check custom message type first
23
+ if (message.contentType === MessageType.CustomMessage) {
24
+ try {
25
+ const data = JSON.parse(message.content);
26
+ const dataType = data.dataType || data.type;
27
+
28
+ if (dataType === DChatMessageType.Link) {
29
+ const linkText = data.content || data.title || 'Link';
30
+ return linkText;
31
+ }
32
+
33
+ if (dataType === DChatMessageType.Order) {
34
+ const orderCode = data.orderCode || data.code || '';
35
+ return `[Đơn hàng] ${orderCode}`;
36
+ }
37
+ } catch {
38
+ // Fall through to default
39
+ }
40
+ }
41
+
42
+ // Handle standard message types
43
+ switch (message.contentType) {
44
+ case MessageType.TextMessage:
45
+ return extractTextContent(message);
46
+
47
+ case MessageType.PictureMessage:
48
+ return '[Hình ảnh]';
49
+
50
+ case MessageType.VideoMessage:
51
+ try {
52
+ const videoData = JSON.parse(message.content);
53
+ const duration = videoData.duration || 0;
54
+ const durationStr = duration > 0 ? ` ${formatDuration(duration)}` : '';
55
+ return `[Video]${durationStr}`;
56
+ } catch {
57
+ return '[Video]';
58
+ }
59
+
60
+ case MessageType.FileMessage:
61
+ try {
62
+ const fileData = JSON.parse(message.content);
63
+ const fileName = fileData.fileName || fileData.name || 'File';
64
+ return `[File] ${fileName}`;
65
+ } catch {
66
+ return '[File]';
67
+ }
68
+
69
+ case MessageType.MergeMessage:
70
+ // Show image count for merged messages containing images
71
+ try {
72
+ const mergeData = message.mergeElem;
73
+ if (mergeData?.multiMessage) {
74
+ const imageCount = mergeData.multiMessage.filter(
75
+ (msg: any) => msg.contentType === MessageType.PictureMessage
76
+ ).length;
77
+ if (imageCount > 0) {
78
+ return `${imageCount} [Hình ảnh]`;
79
+ }
80
+ }
81
+ } catch {
82
+ // Fall through to default
83
+ }
84
+ return '';
85
+
86
+ case MessageType.UrlTextMessage:
87
+ // Preview link message - show with [Link] prefix
88
+ const urlText =
89
+ message?.urlTextElem?.content || message?.urlTextElem?.urls?.[0] || '';
90
+ console.log('message', urlText);
91
+ return urlText ? `[Link] ${urlText}` : '[Link]';
92
+
93
+ case MessageType.AtTextMessage:
94
+ case MessageType.QuoteMessage:
95
+ return extractTextContent(message);
96
+
97
+ default:
98
+ return '[Tin nhắn không được hỗ trợ]';
99
+ }
100
+ };
101
+
14
102
  export const getLastMessageText = (
15
103
  message: DMessageItem | undefined,
16
104
  currentUserId?: string
17
105
  ): string => {
18
106
  if (!message) return '';
19
- if (message.contentType !== MessageType.TextMessage) return '';
20
107
 
21
- const text = extractTextContent(message);
108
+ const preview = getMessagePreview(message);
109
+ if (!preview) return '';
110
+
111
+ // Add sender name
22
112
  if (currentUserId && message.sendID === currentUserId) {
23
- return `Bạn: ${text}`;
113
+ return `Bạn: ${preview}`;
24
114
  }
25
- return text;
115
+
116
+ return preview;
26
117
  };
27
118
 
28
119
  export const formatTimestamp = (ts: number | string | null): string => {
@@ -0,0 +1,30 @@
1
+ import { memo } from 'react';
2
+ import { KContainer, KLabel } from '@droppii/libs';
3
+ import { CHAT_BUBBLE_COLORS } from '../../../screens/chat-detail/constants';
4
+ import { messageStyles } from '../styles';
5
+ import type { BaseLegendMessageProps } from '../types';
6
+
7
+ export const FileMessage = memo(
8
+ ({ message, isOutgoing }: BaseLegendMessageProps) => {
9
+ const fileName = message.fileElem?.fileName || message.content || '[File]';
10
+
11
+ return (
12
+ <KContainer.View style={messageStyles.wrapper}>
13
+ <KContainer.View
14
+ style={[
15
+ messageStyles.bubble,
16
+ isOutgoing
17
+ ? messageStyles.bubbleSent
18
+ : messageStyles.bubbleReceived,
19
+ ]}
20
+ >
21
+ <KLabel.Text typo="TextSmNormal" color={CHAT_BUBBLE_COLORS.text}>
22
+ 📎 {fileName}
23
+ </KLabel.Text>
24
+ </KContainer.View>
25
+ </KContainer.View>
26
+ );
27
+ }
28
+ );
29
+
30
+ FileMessage.displayName = 'FileMessage';