stream-chat-react-native-core 5.21.0 → 5.22.0-beta.10

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 (285) hide show
  1. package/README.md +10 -5
  2. package/lib/commonjs/components/Attachment/AudioAttachment.js +12 -12
  3. package/lib/commonjs/components/Attachment/AudioAttachment.js.map +1 -1
  4. package/lib/commonjs/components/Attachment/FileAttachment.js +10 -7
  5. package/lib/commonjs/components/Attachment/FileAttachment.js.map +1 -1
  6. package/lib/commonjs/components/AttachmentPicker/AttachmentPicker.js +8 -6
  7. package/lib/commonjs/components/AttachmentPicker/AttachmentPicker.js.map +1 -1
  8. package/lib/commonjs/components/AttachmentPicker/components/AttachmentPickerItem.js +24 -20
  9. package/lib/commonjs/components/AttachmentPicker/components/AttachmentPickerItem.js.map +1 -1
  10. package/lib/commonjs/components/AttachmentPicker/components/AttachmentSelectionBar.js +26 -11
  11. package/lib/commonjs/components/AttachmentPicker/components/AttachmentSelectionBar.js.map +1 -1
  12. package/lib/commonjs/components/Channel/Channel.js +65 -46
  13. package/lib/commonjs/components/Channel/Channel.js.map +1 -1
  14. package/lib/commonjs/components/Channel/hooks/useCreateChannelContext.js +2 -0
  15. package/lib/commonjs/components/Channel/hooks/useCreateChannelContext.js.map +1 -1
  16. package/lib/commonjs/components/Channel/hooks/useCreateInputMessageInputContext.js +2 -2
  17. package/lib/commonjs/components/Channel/hooks/useCreateInputMessageInputContext.js.map +1 -1
  18. package/lib/commonjs/components/ChannelPreview/ChannelPreviewMessenger.js +16 -14
  19. package/lib/commonjs/components/ChannelPreview/ChannelPreviewMessenger.js.map +1 -1
  20. package/lib/commonjs/components/ChannelPreview/hooks/useChannelPreviewDisplayName.js +4 -2
  21. package/lib/commonjs/components/ChannelPreview/hooks/useChannelPreviewDisplayName.js.map +1 -1
  22. package/lib/commonjs/components/ImageGallery/ImageGallery.js +30 -32
  23. package/lib/commonjs/components/ImageGallery/ImageGallery.js.map +1 -1
  24. package/lib/commonjs/components/ImageGallery/components/AnimatedGalleryImage.js +7 -5
  25. package/lib/commonjs/components/ImageGallery/components/AnimatedGalleryImage.js.map +1 -1
  26. package/lib/commonjs/components/ImageGallery/components/AnimatedGalleryVideo.js +10 -8
  27. package/lib/commonjs/components/ImageGallery/components/AnimatedGalleryVideo.js.map +1 -1
  28. package/lib/commonjs/components/ImageGallery/components/ImageGalleryFooter.js +18 -15
  29. package/lib/commonjs/components/ImageGallery/components/ImageGalleryFooter.js.map +1 -1
  30. package/lib/commonjs/components/ImageGallery/components/ImageGalleryVideoControl.js +41 -12
  31. package/lib/commonjs/components/ImageGallery/components/ImageGalleryVideoControl.js.map +1 -1
  32. package/lib/commonjs/components/ImageGallery/components/ImageGrid.js +10 -8
  33. package/lib/commonjs/components/ImageGallery/components/ImageGrid.js.map +1 -1
  34. package/lib/commonjs/components/Indicators/EmptyStateIndicator.js +17 -12
  35. package/lib/commonjs/components/Indicators/EmptyStateIndicator.js.map +1 -1
  36. package/lib/commonjs/components/Message/MessageSimple/MessageContent.js +20 -17
  37. package/lib/commonjs/components/Message/MessageSimple/MessageContent.js.map +1 -1
  38. package/lib/commonjs/components/Message/MessageSimple/ReactionList.js +18 -17
  39. package/lib/commonjs/components/Message/MessageSimple/ReactionList.js.map +1 -1
  40. package/lib/commonjs/components/Message/MessageSimple/utils/generateMarkdownText.js +7 -5
  41. package/lib/commonjs/components/Message/MessageSimple/utils/generateMarkdownText.js.map +1 -1
  42. package/lib/commonjs/components/Message/MessageSimple/utils/generateMarkdownText.test.js +8 -0
  43. package/lib/commonjs/components/Message/MessageSimple/utils/generateMarkdownText.test.js.map +1 -0
  44. package/lib/commonjs/components/Message/MessageSimple/utils/renderText.js +25 -17
  45. package/lib/commonjs/components/Message/MessageSimple/utils/renderText.js.map +1 -1
  46. package/lib/commonjs/components/MessageInput/FileUploadPreview.js +30 -20
  47. package/lib/commonjs/components/MessageInput/FileUploadPreview.js.map +1 -1
  48. package/lib/commonjs/components/MessageInput/ImageUploadPreview.js +13 -13
  49. package/lib/commonjs/components/MessageInput/ImageUploadPreview.js.map +1 -1
  50. package/lib/commonjs/components/MessageInput/MessageInput.js +1 -1
  51. package/lib/commonjs/components/MessageInput/MessageInput.js.map +1 -1
  52. package/lib/commonjs/components/MessageInput/UploadProgressIndicator.js.map +1 -1
  53. package/lib/commonjs/components/MessageList/InlineUnreadIndicator.js +13 -11
  54. package/lib/commonjs/components/MessageList/InlineUnreadIndicator.js.map +1 -1
  55. package/lib/commonjs/components/MessageOverlay/MessageActionList.js +8 -14
  56. package/lib/commonjs/components/MessageOverlay/MessageActionList.js.map +1 -1
  57. package/lib/commonjs/components/MessageOverlay/MessageActionListItem.js +11 -8
  58. package/lib/commonjs/components/MessageOverlay/MessageActionListItem.js.map +1 -1
  59. package/lib/commonjs/components/MessageOverlay/MessageOverlay.js +32 -29
  60. package/lib/commonjs/components/MessageOverlay/MessageOverlay.js.map +1 -1
  61. package/lib/commonjs/components/Thread/components/ThreadFooterComponent.js +17 -15
  62. package/lib/commonjs/components/Thread/components/ThreadFooterComponent.js.map +1 -1
  63. package/lib/commonjs/contexts/channelContext/ChannelContext.js +2 -2
  64. package/lib/commonjs/contexts/channelContext/ChannelContext.js.map +1 -1
  65. package/lib/commonjs/contexts/messageInputContext/MessageInputContext.js +66 -45
  66. package/lib/commonjs/contexts/messageInputContext/MessageInputContext.js.map +1 -1
  67. package/lib/commonjs/contexts/messageInputContext/hooks/useCreateMessageInputContext.js +2 -2
  68. package/lib/commonjs/contexts/messageInputContext/hooks/useCreateMessageInputContext.js.map +1 -1
  69. package/lib/commonjs/contexts/messageInputContext/hooks/useMessageDetailsForState.js.map +1 -1
  70. package/lib/commonjs/contexts/messagesContext/MessagesContext.js.map +1 -1
  71. package/lib/commonjs/contexts/themeContext/utils/theme.js +1 -4
  72. package/lib/commonjs/contexts/themeContext/utils/theme.js.map +1 -1
  73. package/lib/commonjs/hooks/index.js +11 -0
  74. package/lib/commonjs/hooks/index.js.map +1 -1
  75. package/lib/commonjs/hooks/useViewport.js +47 -0
  76. package/lib/commonjs/hooks/useViewport.js.map +1 -0
  77. package/lib/commonjs/i18n/en.json +6 -1
  78. package/lib/commonjs/i18n/es.json +77 -0
  79. package/lib/commonjs/i18n/fr.json +65 -60
  80. package/lib/commonjs/i18n/he.json +6 -1
  81. package/lib/commonjs/i18n/hi.json +65 -60
  82. package/lib/commonjs/i18n/it.json +65 -60
  83. package/lib/commonjs/i18n/ja.json +6 -1
  84. package/lib/commonjs/i18n/ko.json +6 -1
  85. package/lib/commonjs/i18n/nl.json +65 -60
  86. package/lib/commonjs/i18n/ru.json +65 -60
  87. package/lib/commonjs/i18n/tr.json +65 -60
  88. package/lib/commonjs/native.js.map +1 -1
  89. package/lib/commonjs/types/types.js.map +1 -1
  90. package/lib/commonjs/utils/Streami18n.js +4 -1
  91. package/lib/commonjs/utils/Streami18n.js.map +1 -1
  92. package/lib/commonjs/utils/compressImage.js +37 -0
  93. package/lib/commonjs/utils/compressImage.js.map +1 -0
  94. package/lib/commonjs/utils/utils.js +1 -15
  95. package/lib/commonjs/utils/utils.js.map +1 -1
  96. package/lib/commonjs/version.json +1 -1
  97. package/lib/module/components/Attachment/AudioAttachment.js +12 -12
  98. package/lib/module/components/Attachment/AudioAttachment.js.map +1 -1
  99. package/lib/module/components/Attachment/FileAttachment.js +10 -7
  100. package/lib/module/components/Attachment/FileAttachment.js.map +1 -1
  101. package/lib/module/components/AttachmentPicker/AttachmentPicker.js +8 -6
  102. package/lib/module/components/AttachmentPicker/AttachmentPicker.js.map +1 -1
  103. package/lib/module/components/AttachmentPicker/components/AttachmentPickerItem.js +24 -20
  104. package/lib/module/components/AttachmentPicker/components/AttachmentPickerItem.js.map +1 -1
  105. package/lib/module/components/AttachmentPicker/components/AttachmentSelectionBar.js +26 -11
  106. package/lib/module/components/AttachmentPicker/components/AttachmentSelectionBar.js.map +1 -1
  107. package/lib/module/components/Channel/Channel.js +65 -46
  108. package/lib/module/components/Channel/Channel.js.map +1 -1
  109. package/lib/module/components/Channel/hooks/useCreateChannelContext.js +2 -0
  110. package/lib/module/components/Channel/hooks/useCreateChannelContext.js.map +1 -1
  111. package/lib/module/components/Channel/hooks/useCreateInputMessageInputContext.js +2 -2
  112. package/lib/module/components/Channel/hooks/useCreateInputMessageInputContext.js.map +1 -1
  113. package/lib/module/components/ChannelPreview/ChannelPreviewMessenger.js +16 -14
  114. package/lib/module/components/ChannelPreview/ChannelPreviewMessenger.js.map +1 -1
  115. package/lib/module/components/ChannelPreview/hooks/useChannelPreviewDisplayName.js +4 -2
  116. package/lib/module/components/ChannelPreview/hooks/useChannelPreviewDisplayName.js.map +1 -1
  117. package/lib/module/components/ImageGallery/ImageGallery.js +30 -32
  118. package/lib/module/components/ImageGallery/ImageGallery.js.map +1 -1
  119. package/lib/module/components/ImageGallery/components/AnimatedGalleryImage.js +7 -5
  120. package/lib/module/components/ImageGallery/components/AnimatedGalleryImage.js.map +1 -1
  121. package/lib/module/components/ImageGallery/components/AnimatedGalleryVideo.js +10 -8
  122. package/lib/module/components/ImageGallery/components/AnimatedGalleryVideo.js.map +1 -1
  123. package/lib/module/components/ImageGallery/components/ImageGalleryFooter.js +18 -15
  124. package/lib/module/components/ImageGallery/components/ImageGalleryFooter.js.map +1 -1
  125. package/lib/module/components/ImageGallery/components/ImageGalleryVideoControl.js +41 -12
  126. package/lib/module/components/ImageGallery/components/ImageGalleryVideoControl.js.map +1 -1
  127. package/lib/module/components/ImageGallery/components/ImageGrid.js +10 -8
  128. package/lib/module/components/ImageGallery/components/ImageGrid.js.map +1 -1
  129. package/lib/module/components/Indicators/EmptyStateIndicator.js +17 -12
  130. package/lib/module/components/Indicators/EmptyStateIndicator.js.map +1 -1
  131. package/lib/module/components/Message/MessageSimple/MessageContent.js +20 -17
  132. package/lib/module/components/Message/MessageSimple/MessageContent.js.map +1 -1
  133. package/lib/module/components/Message/MessageSimple/ReactionList.js +18 -17
  134. package/lib/module/components/Message/MessageSimple/ReactionList.js.map +1 -1
  135. package/lib/module/components/Message/MessageSimple/utils/generateMarkdownText.js +7 -5
  136. package/lib/module/components/Message/MessageSimple/utils/generateMarkdownText.js.map +1 -1
  137. package/lib/module/components/Message/MessageSimple/utils/generateMarkdownText.test.js +8 -0
  138. package/lib/module/components/Message/MessageSimple/utils/generateMarkdownText.test.js.map +1 -0
  139. package/lib/module/components/Message/MessageSimple/utils/renderText.js +25 -17
  140. package/lib/module/components/Message/MessageSimple/utils/renderText.js.map +1 -1
  141. package/lib/module/components/MessageInput/FileUploadPreview.js +30 -20
  142. package/lib/module/components/MessageInput/FileUploadPreview.js.map +1 -1
  143. package/lib/module/components/MessageInput/ImageUploadPreview.js +13 -13
  144. package/lib/module/components/MessageInput/ImageUploadPreview.js.map +1 -1
  145. package/lib/module/components/MessageInput/MessageInput.js +1 -1
  146. package/lib/module/components/MessageInput/MessageInput.js.map +1 -1
  147. package/lib/module/components/MessageInput/UploadProgressIndicator.js.map +1 -1
  148. package/lib/module/components/MessageList/InlineUnreadIndicator.js +13 -11
  149. package/lib/module/components/MessageList/InlineUnreadIndicator.js.map +1 -1
  150. package/lib/module/components/MessageOverlay/MessageActionList.js +8 -14
  151. package/lib/module/components/MessageOverlay/MessageActionList.js.map +1 -1
  152. package/lib/module/components/MessageOverlay/MessageActionListItem.js +11 -8
  153. package/lib/module/components/MessageOverlay/MessageActionListItem.js.map +1 -1
  154. package/lib/module/components/MessageOverlay/MessageOverlay.js +32 -29
  155. package/lib/module/components/MessageOverlay/MessageOverlay.js.map +1 -1
  156. package/lib/module/components/Thread/components/ThreadFooterComponent.js +17 -15
  157. package/lib/module/components/Thread/components/ThreadFooterComponent.js.map +1 -1
  158. package/lib/module/contexts/channelContext/ChannelContext.js +2 -2
  159. package/lib/module/contexts/channelContext/ChannelContext.js.map +1 -1
  160. package/lib/module/contexts/messageInputContext/MessageInputContext.js +66 -45
  161. package/lib/module/contexts/messageInputContext/MessageInputContext.js.map +1 -1
  162. package/lib/module/contexts/messageInputContext/hooks/useCreateMessageInputContext.js +2 -2
  163. package/lib/module/contexts/messageInputContext/hooks/useCreateMessageInputContext.js.map +1 -1
  164. package/lib/module/contexts/messageInputContext/hooks/useMessageDetailsForState.js.map +1 -1
  165. package/lib/module/contexts/messagesContext/MessagesContext.js.map +1 -1
  166. package/lib/module/contexts/themeContext/utils/theme.js +1 -4
  167. package/lib/module/contexts/themeContext/utils/theme.js.map +1 -1
  168. package/lib/module/hooks/index.js +11 -0
  169. package/lib/module/hooks/index.js.map +1 -1
  170. package/lib/module/hooks/useViewport.js +47 -0
  171. package/lib/module/hooks/useViewport.js.map +1 -0
  172. package/lib/module/i18n/en.json +6 -1
  173. package/lib/module/i18n/es.json +77 -0
  174. package/lib/module/i18n/fr.json +65 -60
  175. package/lib/module/i18n/he.json +6 -1
  176. package/lib/module/i18n/hi.json +65 -60
  177. package/lib/module/i18n/it.json +65 -60
  178. package/lib/module/i18n/ja.json +6 -1
  179. package/lib/module/i18n/ko.json +6 -1
  180. package/lib/module/i18n/nl.json +65 -60
  181. package/lib/module/i18n/ru.json +65 -60
  182. package/lib/module/i18n/tr.json +65 -60
  183. package/lib/module/native.js.map +1 -1
  184. package/lib/module/types/types.js.map +1 -1
  185. package/lib/module/utils/Streami18n.js +4 -1
  186. package/lib/module/utils/Streami18n.js.map +1 -1
  187. package/lib/module/utils/compressImage.js +37 -0
  188. package/lib/module/utils/compressImage.js.map +1 -0
  189. package/lib/module/utils/utils.js +1 -15
  190. package/lib/module/utils/utils.js.map +1 -1
  191. package/lib/module/version.json +1 -1
  192. package/lib/typescript/components/Attachment/AudioAttachment.d.ts +1 -1
  193. package/lib/typescript/components/Channel/hooks/useCreateChannelContext.d.ts +1 -1
  194. package/lib/typescript/components/ImageGallery/components/ImageGalleryFooter.d.ts +3 -0
  195. package/lib/typescript/components/Message/MessageSimple/utils/generateMarkdownText.d.ts +1 -3
  196. package/lib/typescript/components/Message/MessageSimple/utils/generateMarkdownText.test.d.ts +1 -0
  197. package/lib/typescript/components/Message/hooks/useMessageActionHandlers.d.ts +1 -1
  198. package/lib/typescript/components/Message/hooks/useMessageActions.d.ts +1 -1
  199. package/lib/typescript/components/MessageInput/UploadProgressIndicator.d.ts +5 -2
  200. package/lib/typescript/contexts/channelContext/ChannelContext.d.ts +5 -0
  201. package/lib/typescript/contexts/messageContext/MessageContext.d.ts +1 -1
  202. package/lib/typescript/contexts/messageInputContext/MessageInputContext.d.ts +3 -23
  203. package/lib/typescript/contexts/messageInputContext/hooks/useMessageDetailsForState.d.ts +2 -2
  204. package/lib/typescript/contexts/messagesContext/MessagesContext.d.ts +2 -2
  205. package/lib/typescript/contexts/themeContext/utils/theme.d.ts +1 -3
  206. package/lib/typescript/hooks/index.d.ts +1 -0
  207. package/lib/typescript/hooks/useViewport.d.ts +11 -0
  208. package/lib/typescript/i18n/en.json +6 -1
  209. package/lib/typescript/i18n/es.json +77 -0
  210. package/lib/typescript/i18n/fr.json +65 -60
  211. package/lib/typescript/i18n/he.json +6 -1
  212. package/lib/typescript/i18n/hi.json +65 -60
  213. package/lib/typescript/i18n/it.json +65 -60
  214. package/lib/typescript/i18n/ja.json +6 -1
  215. package/lib/typescript/i18n/ko.json +6 -1
  216. package/lib/typescript/i18n/nl.json +65 -60
  217. package/lib/typescript/i18n/ru.json +65 -60
  218. package/lib/typescript/i18n/tr.json +65 -60
  219. package/lib/typescript/native.d.ts +2 -0
  220. package/lib/typescript/store/mappers/mapStorableToChannel.d.ts +1 -1
  221. package/lib/typescript/types/types.d.ts +27 -10
  222. package/lib/typescript/utils/Streami18n.d.ts +7 -1
  223. package/lib/typescript/utils/compressImage.d.ts +8 -0
  224. package/lib/typescript/utils/utils.d.ts +0 -2
  225. package/package.json +2 -2
  226. package/src/components/Attachment/AudioAttachment.tsx +2 -1
  227. package/src/components/Attachment/FileAttachment.tsx +12 -3
  228. package/src/components/AttachmentPicker/AttachmentPicker.tsx +4 -2
  229. package/src/components/AttachmentPicker/components/AttachmentPickerItem.tsx +7 -5
  230. package/src/components/AttachmentPicker/components/AttachmentSelectionBar.tsx +13 -1
  231. package/src/components/Channel/Channel.tsx +32 -8
  232. package/src/components/Channel/hooks/useCreateChannelContext.ts +2 -0
  233. package/src/components/Channel/hooks/useCreateInputMessageInputContext.ts +2 -9
  234. package/src/components/ChannelPreview/ChannelPreviewMessenger.tsx +4 -3
  235. package/src/components/ChannelPreview/hooks/useChannelPreviewDisplayName.ts +4 -3
  236. package/src/components/ImageGallery/ImageGallery.tsx +10 -19
  237. package/src/components/ImageGallery/components/AnimatedGalleryImage.tsx +5 -3
  238. package/src/components/ImageGallery/components/AnimatedGalleryVideo.tsx +5 -3
  239. package/src/components/ImageGallery/components/ImageGalleryFooter.tsx +6 -2
  240. package/src/components/ImageGallery/components/ImageGalleryVideoControl.tsx +12 -7
  241. package/src/components/ImageGallery/components/ImageGrid.tsx +2 -1
  242. package/src/components/Indicators/EmptyStateIndicator.tsx +8 -7
  243. package/src/components/Message/MessageSimple/MessageContent.tsx +3 -1
  244. package/src/components/Message/MessageSimple/ReactionList.tsx +2 -1
  245. package/src/components/Message/MessageSimple/utils/generateMarkdownText.test.ts +23 -0
  246. package/src/components/Message/MessageSimple/utils/generateMarkdownText.ts +12 -13
  247. package/src/components/Message/MessageSimple/utils/renderText.tsx +12 -2
  248. package/src/components/MessageInput/FileUploadPreview.tsx +17 -3
  249. package/src/components/MessageInput/ImageUploadPreview.tsx +1 -2
  250. package/src/components/MessageInput/MessageInput.tsx +1 -1
  251. package/src/components/MessageInput/UploadProgressIndicator.tsx +2 -2
  252. package/src/components/MessageInput/__tests__/AudioAttachmentUploadPreviewExpo.test.tsx +1 -1
  253. package/src/components/MessageInput/__tests__/AudioAttachmentUploadPreviewNative.test.tsx +1 -1
  254. package/src/components/MessageInput/__tests__/MessageInput.test.js +2 -2
  255. package/src/components/MessageList/InlineUnreadIndicator.tsx +2 -1
  256. package/src/components/MessageOverlay/MessageActionList.tsx +3 -11
  257. package/src/components/MessageOverlay/MessageActionListItem.tsx +5 -2
  258. package/src/components/MessageOverlay/MessageOverlay.tsx +5 -3
  259. package/src/components/Thread/components/ThreadFooterComponent.tsx +2 -1
  260. package/src/contexts/channelContext/ChannelContext.tsx +5 -0
  261. package/src/contexts/messageInputContext/MessageInputContext.tsx +81 -69
  262. package/src/contexts/messageInputContext/__tests__/__snapshots__/sendMessage.test.tsx.snap +3 -3
  263. package/src/contexts/messageInputContext/hooks/useCreateMessageInputContext.ts +2 -2
  264. package/src/contexts/messageInputContext/hooks/useMessageDetailsForState.ts +2 -2
  265. package/src/contexts/messagesContext/MessagesContext.tsx +2 -2
  266. package/src/contexts/themeContext/utils/theme.ts +2 -7
  267. package/src/hooks/index.ts +1 -0
  268. package/src/hooks/useViewport.ts +41 -0
  269. package/src/i18n/en.json +6 -1
  270. package/src/i18n/es.json +77 -0
  271. package/src/i18n/fr.json +65 -60
  272. package/src/i18n/he.json +6 -1
  273. package/src/i18n/hi.json +65 -60
  274. package/src/i18n/it.json +65 -60
  275. package/src/i18n/ja.json +6 -1
  276. package/src/i18n/ko.json +6 -1
  277. package/src/i18n/nl.json +65 -60
  278. package/src/i18n/ru.json +65 -60
  279. package/src/i18n/tr.json +65 -60
  280. package/src/native.ts +5 -1
  281. package/src/types/types.ts +29 -10
  282. package/src/utils/Streami18n.ts +13 -6
  283. package/src/utils/compressImage.ts +32 -0
  284. package/src/utils/utils.ts +0 -13
  285. package/src/version.json +1 -1
@@ -0,0 +1,23 @@
1
+ import { generateMarkdownText } from './generateMarkdownText';
2
+
3
+ describe('generateMarkdownText', () => {
4
+ it.each([
5
+ ['', null],
6
+ [' test message ', 'test message'],
7
+ ['https://www.getstream.io', '[https://www.getstream.io](https://www.getstream.io)'],
8
+ [
9
+ 'https://getstream-production.s3-accelerate.amazonaws.com/N336903591601695/33e78ef89e64642862a75c5cca2541eaf6b1c924/trimmedVideos/alert/2_270_881/outputVideo.mp4?AWSAccessKeyId=AKIAVJAW2AD2SQVQCBXV&Expires=1699998768&Signature=zdEMCGzf4Pq++16YkPprvN5NAds=',
10
+ '[https://getstream-production.s3-accelerate.amazonaws.com/N336903591601695/33e78ef89e64642862a75c5cca2541eaf6b1c924/trimmedVideos/alert/2_270_881/outputVideo.mp4?AWSAccessKeyId=AKIAVJAW2AD2SQVQCBXV&...](https://getstream-production.s3-accelerate.amazonaws.com/N336903591601695/33e78ef89e64642862a75c5cca2541eaf6b1c924/trimmedVideos/alert/2_270_881/outputVideo.mp4?AWSAccessKeyId=AKIAVJAW2AD2SQVQCBXV&Expires=1699998768&Signature=zdEMCGzf4Pq++16YkPprvN5NAds=)',
11
+ ],
12
+ ['Hi @getstream.io', 'Hi @getstream.io'],
13
+ [
14
+ 'Hi test@gmail.com @test@gmail.com',
15
+ 'Hi [test@gmail.com](mailto:test@gmail.com) @test@gmail.com',
16
+ ],
17
+ ['Hi @getstream.io getstream.io', 'Hi @getstream.io [getstream.io](http://getstream.io)'],
18
+ ['Hi <Stream>', 'Hi \\<Stream\\>'],
19
+ ])('Returns the generated markdown text for %p and %p', (text, expected) => {
20
+ const result = generateMarkdownText(text);
21
+ expect(result).toBe(expected);
22
+ });
23
+ });
@@ -2,16 +2,12 @@ import truncate from 'lodash/truncate';
2
2
 
3
3
  import { parseLinksFromText } from './parseLinks';
4
4
 
5
- import type { DefaultStreamChatGenerics } from '../../../../types/types';
6
- import type { MessageType } from '../../../MessageList/hooks/useMessageList';
7
-
8
- export const generateMarkdownText = <
9
- StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
10
- >(
11
- message: MessageType<StreamChatGenerics>,
12
- ) => {
13
- const { text } = message;
5
+ // If you need to use any of the special characters literally (actually searching for a "*", for instance), you must escape it by putting a backslash in front of it.
6
+ function escapeRegExp(text: string) {
7
+ return text.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&');
8
+ }
14
9
 
10
+ export const generateMarkdownText = (text?: string) => {
15
11
  if (!text) return null;
16
12
 
17
13
  // Trim the extra spaces from the text.
@@ -26,18 +22,21 @@ export const generateMarkdownText = <
26
22
  omission: '...',
27
23
  });
28
24
  // Convert raw links/emails in the text to respective markdown syntax.
29
- // Eg: Hi getstream.io -> Hi [getstream.io](getstream.io).
30
- const normalRegEx = new RegExp(linkInfo.raw, 'g');
25
+ // Eg: Hi @getstream.io -> Hi @[getstream.io](getstream.io).
26
+ const normalRegEx = new RegExp(escapeRegExp(linkInfo.raw), 'g');
31
27
  const markdown = `[${displayLink}](${linkInfo.encodedUrl})`;
32
28
  resultText = text.replace(normalRegEx, markdown);
33
29
 
34
30
  // After previous step, in some cases, the mentioned user after `@` might have a link/email so we convert it back to normal raw text.
35
31
  // Eg: Hi, @[test.user@gmail.com](mailto:test.user@gmail.com) to @test.user@gmail.com.
36
- const mentionsRegex = new RegExp(`@\\[${displayLink}\\]\\(${linkInfo.encodedUrl}\\)`, 'g');
32
+ const mentionsRegex = new RegExp(
33
+ `@\\[${escapeRegExp(displayLink)}\\]\\(${escapeRegExp(linkInfo.encodedUrl)}\\)`,
34
+ 'g',
35
+ );
37
36
  resultText = resultText.replace(mentionsRegex, `@${displayLink}`);
38
37
  }
39
38
 
40
- resultText = resultText.replace(/[<&"'>]/g, '\\$&');
39
+ resultText = resultText.replace(/[<"'>]/g, '\\$&');
41
40
 
42
41
  return resultText;
43
42
  };
@@ -100,8 +100,9 @@ export const renderText = <
100
100
  onPress: onPressParam,
101
101
  preventPress,
102
102
  } = params;
103
+ const { text } = message;
103
104
 
104
- const markdownText = generateMarkdownText<StreamChatGenerics>(message);
105
+ const markdownText = generateMarkdownText(text);
105
106
 
106
107
  const styles: MarkdownStyle = {
107
108
  ...defaultMarkdownStyles,
@@ -141,8 +142,17 @@ export const renderText = <
141
142
  : Linking.canOpenURL(url).then((canOpenUrl) => canOpenUrl && Linking.openURL(url));
142
143
  };
143
144
 
145
+ let previousLink: string | undefined;
144
146
  const linkReact: ReactNodeOutput = (node, output, { ...state }) => {
145
- const url = node.target;
147
+ let url: string;
148
+ // Some long URLs with `&` separated parameters are trimmed and the url only until first param is taken.
149
+ // This is done because of internal link been taken from the original URL in react-native-markdown-package. So, we check for `withinLink` and take the previous full URL.
150
+ if (state?.withinLink && previousLink) {
151
+ url = previousLink;
152
+ } else {
153
+ url = node.target;
154
+ previousLink = node.target;
155
+ }
146
156
  const onPress = (event: GestureResponderEvent) => {
147
157
  if (!preventPress && onPressParam) {
148
158
  onPressParam({
@@ -1,11 +1,12 @@
1
1
  import React, { useEffect, useRef, useState } from 'react';
2
2
  import { FlatList, I18nManager, StyleSheet, Text, TouchableOpacity, View } from 'react-native';
3
3
 
4
+ import dayjs from 'dayjs';
5
+
4
6
  import { UploadProgressIndicator } from './UploadProgressIndicator';
5
7
 
6
8
  import { ChatContextValue, useChatContext } from '../../contexts';
7
9
  import {
8
- FileUpload,
9
10
  MessageInputContextValue,
10
11
  useMessageInputContext,
11
12
  } from '../../contexts/messageInputContext/MessageInputContext';
@@ -18,7 +19,7 @@ import { useTranslationContext } from '../../contexts/translationContext/Transla
18
19
  import { Close } from '../../icons/Close';
19
20
  import { Warning } from '../../icons/Warning';
20
21
  import { isAudioPackageAvailable } from '../../native';
21
- import type { DefaultStreamChatGenerics } from '../../types/types';
22
+ import type { DefaultStreamChatGenerics, FileUpload } from '../../types/types';
22
23
  import { FileState, getIndicatorTypeForFileState, ProgressIndicatorTypes } from '../../utils/utils';
23
24
  import { getFileSizeDisplayText } from '../Attachment/FileAttachment';
24
25
  import { WritingDirectionAwareText } from '../RTLComponents/WritingDirectionAwareText';
@@ -101,6 +102,19 @@ const UnsupportedFileTypeOrFileSizeIndicator = ({
101
102
  },
102
103
  } = useTheme();
103
104
 
105
+ const ONE_HOUR_IN_SECONDS = 3600;
106
+ let durationLabel = '00:00';
107
+ const videoDuration = item.file.duration;
108
+
109
+ if (videoDuration) {
110
+ const isDurationLongerThanHour = videoDuration / ONE_HOUR_IN_SECONDS >= 1;
111
+ const formattedDurationParam = isDurationLongerThanHour ? 'HH:mm:ss' : 'mm:ss';
112
+ const formattedVideoDuration = dayjs
113
+ .duration(videoDuration, 'second')
114
+ .format(formattedDurationParam);
115
+ durationLabel = formattedVideoDuration;
116
+ }
117
+
104
118
  const { t } = useTranslationContext();
105
119
 
106
120
  return indicatorType === ProgressIndicatorTypes.NOT_SUPPORTED ? (
@@ -117,7 +131,7 @@ const UnsupportedFileTypeOrFileSizeIndicator = ({
117
131
  </View>
118
132
  ) : (
119
133
  <WritingDirectionAwareText style={[styles.fileSizeText, { color: grey }, fileSizeText]}>
120
- {item.file.duration || getFileSizeDisplayText(item.file.size)}
134
+ {videoDuration ? durationLabel : getFileSizeDisplayText(item.file.size)}
121
135
  </WritingDirectionAwareText>
122
136
  );
123
137
  };
@@ -13,7 +13,6 @@ import { UploadProgressIndicator } from './UploadProgressIndicator';
13
13
 
14
14
  import { ChatContextValue, useChatContext } from '../../contexts';
15
15
  import {
16
- ImageUpload,
17
16
  MessageInputContextValue,
18
17
  useMessageInputContext,
19
18
  } from '../../contexts/messageInputContext/MessageInputContext';
@@ -21,7 +20,7 @@ import { useTheme } from '../../contexts/themeContext/ThemeContext';
21
20
  import { useTranslationContext } from '../../contexts/translationContext/TranslationContext';
22
21
  import { Close } from '../../icons/Close';
23
22
  import { Warning } from '../../icons/Warning';
24
- import type { DefaultStreamChatGenerics } from '../../types/types';
23
+ import type { DefaultStreamChatGenerics, ImageUpload } from '../../types/types';
25
24
  import { getIndicatorTypeForFileState, ProgressIndicatorTypes } from '../../utils/utils';
26
25
 
27
26
  const IMAGE_PREVIEW_SIZE = 100;
@@ -288,7 +288,7 @@ const MessageInputWithContext = <
288
288
  // Check if the file size of the image exceeds the threshold of 100MB
289
289
  if (
290
290
  imageToUpload &&
291
- Number(imageToUpload.fileSize) / MEGA_BYTES_TO_BYTES > MAX_FILE_SIZE_TO_UPLOAD_IN_MB
291
+ Number(imageToUpload.size) / MEGA_BYTES_TO_BYTES > MAX_FILE_SIZE_TO_UPLOAD_IN_MB
292
292
  ) {
293
293
  Alert.alert(
294
294
  t(
@@ -1,4 +1,4 @@
1
- import React from 'react';
1
+ import React, { PropsWithChildren } from 'react';
2
2
  import {
3
3
  ActivityIndicator,
4
4
  GestureResponderEvent,
@@ -24,7 +24,7 @@ export type UploadProgressIndicatorProps = {
24
24
  type?: 'in_progress' | 'retry' | 'not_supported' | 'inactive' | null;
25
25
  };
26
26
 
27
- export const UploadProgressIndicator: React.FC<UploadProgressIndicatorProps> = (props) => {
27
+ export const UploadProgressIndicator = (props: PropsWithChildren<UploadProgressIndicatorProps>) => {
28
28
  const { action, children, style, type } = props;
29
29
 
30
30
  const {
@@ -5,7 +5,6 @@ import { act } from 'react-test-renderer';
5
5
  import { fireEvent, render } from '@testing-library/react-native';
6
6
 
7
7
  import {
8
- FileUpload,
9
8
  MessageInputContext,
10
9
  MessageInputContextValue,
11
10
  } from '../../../contexts/messageInputContext/MessageInputContext';
@@ -13,6 +12,7 @@ import { ThemeProvider } from '../../../contexts/themeContext/ThemeContext';
13
12
  import { defaultTheme } from '../../../contexts/themeContext/utils/theme';
14
13
 
15
14
  import { generateFileUploadPreview } from '../../../mock-builders/generator/attachment';
15
+ import type { FileUpload } from '../../../types/types';
16
16
  import { AudioAttachment, AudioAttachmentProps } from '../../Attachment/AudioAttachment';
17
17
 
18
18
  jest.mock('../../../native.ts', () => ({
@@ -5,7 +5,6 @@ import { act } from 'react-test-renderer';
5
5
  import { fireEvent, render } from '@testing-library/react-native';
6
6
 
7
7
  import {
8
- FileUpload,
9
8
  MessageInputContext,
10
9
  MessageInputContextValue,
11
10
  } from '../../../contexts/messageInputContext/MessageInputContext';
@@ -13,6 +12,7 @@ import { ThemeProvider } from '../../../contexts/themeContext/ThemeContext';
13
12
  import { defaultTheme } from '../../../contexts/themeContext/utils/theme';
14
13
 
15
14
  import { generateFileUploadPreview } from '../../../mock-builders/generator/attachment';
15
+ import type { FileUpload } from '../../../types/types';
16
16
  import { AudioAttachment, AudioAttachmentProps } from '../../Attachment/AudioAttachment';
17
17
 
18
18
  jest.mock('../../../native.ts', () => {
@@ -39,12 +39,12 @@ describe('MessageInput', () => {
39
39
  selectedImages: [
40
40
  generateImageAttachment({
41
41
  file: { height: 100, uri: 'https://picsum.photos/200/300', width: 100 },
42
- fileSize: 500000000,
42
+ size: 500000000,
43
43
  uri: 'https://picsum.photos/200/300',
44
44
  }),
45
45
  generateImageAttachment({
46
46
  file: { height: 100, uri: 'https://picsum.photos/200/300', width: 100 },
47
- fileSize: 600000000,
47
+ size: 600000000,
48
48
  uri: 'https://picsum.photos/200/300',
49
49
  }),
50
50
  ],
@@ -4,7 +4,7 @@ import Svg, { Defs, LinearGradient, Rect, Stop } from 'react-native-svg';
4
4
 
5
5
  import { useTheme } from '../../contexts/themeContext/ThemeContext';
6
6
  import { useTranslationContext } from '../../contexts/translationContext/TranslationContext';
7
- import { vw } from '../../utils/utils';
7
+ import { useViewport } from '../../hooks/useViewport';
8
8
 
9
9
  const styles = StyleSheet.create({
10
10
  container: {
@@ -28,6 +28,7 @@ export const InlineUnreadIndicator: React.FC = () => {
28
28
  },
29
29
  } = useTheme();
30
30
  const { t } = useTranslationContext();
31
+ const { vw } = useViewport();
31
32
 
32
33
  return (
33
34
  <View style={[styles.container, container]}>
@@ -10,8 +10,8 @@ import {
10
10
  } from '../../contexts/messageOverlayContext/MessageOverlayContext';
11
11
  import type { OverlayProviderProps } from '../../contexts/overlayContext/OverlayContext';
12
12
  import { useTheme } from '../../contexts/themeContext/ThemeContext';
13
+ import { useViewport } from '../../hooks/useViewport';
13
14
  import type { DefaultStreamChatGenerics } from '../../types/types';
14
- import { vw } from '../../utils/utils';
15
15
 
16
16
  export type MessageActionListPropsWithContext<
17
17
  StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
@@ -52,6 +52,7 @@ const MessageActionListWithContext = <
52
52
  message,
53
53
  messageReactions,
54
54
  };
55
+ const { vw } = useViewport();
55
56
 
56
57
  const {
57
58
  theme: {
@@ -89,7 +90,7 @@ const MessageActionListWithContext = <
89
90
  width.value = layout.width;
90
91
  height.value = layout.height;
91
92
  }}
92
- style={[styles.container, { backgroundColor: white_snow }, showScreenStyle]}
93
+ style={[styles.container, { backgroundColor: white_snow, minWidth: vw(65) }, showScreenStyle]}
93
94
  testID='message-action-list'
94
95
  >
95
96
  {messageActions?.map((messageAction, index) => (
@@ -154,17 +155,8 @@ const styles = StyleSheet.create({
154
155
  container: {
155
156
  borderRadius: 16,
156
157
  marginTop: 8,
157
- minWidth: vw(65),
158
158
  overflow: 'hidden',
159
159
  },
160
- row: {
161
- alignItems: 'center',
162
- flexDirection: 'row',
163
- justifyContent: 'flex-start',
164
- minWidth: vw(65),
165
- paddingHorizontal: 20,
166
- paddingVertical: 10,
167
- },
168
160
  titleStyle: {
169
161
  paddingLeft: 20,
170
162
  },
@@ -6,8 +6,8 @@ import Animated from 'react-native-reanimated';
6
6
  import { useMessageActionAnimation } from './hooks/useMessageActionAnimation';
7
7
 
8
8
  import { useTheme } from '../../contexts/themeContext/ThemeContext';
9
+ import { useViewport } from '../../hooks/useViewport';
9
10
  import type { DefaultStreamChatGenerics } from '../../types/types';
10
- import { vw } from '../../utils/utils';
11
11
  import type { MessageOverlayPropsWithContext } from '../MessageOverlay/MessageOverlay';
12
12
 
13
13
  export type ActionType =
@@ -50,6 +50,7 @@ const MessageActionListItemWithContext = <
50
50
  props: MessageActionListItemProps<StreamChatGenerics>,
51
51
  ) => {
52
52
  const { action, actionType, icon, index, length, title, titleStyle } = props;
53
+ const { vw } = useViewport();
53
54
 
54
55
  const {
55
56
  theme: {
@@ -65,6 +66,9 @@ const MessageActionListItemWithContext = <
65
66
  <Animated.View
66
67
  style={[
67
68
  styles.row,
69
+ {
70
+ minWidth: vw(65),
71
+ },
68
72
  index !== length - 1 ? { ...styles.bottomBorder, borderBottomColor: border } : {},
69
73
  animatedStyle,
70
74
  messageActions.actionContainer,
@@ -114,7 +118,6 @@ const styles = StyleSheet.create({
114
118
  alignItems: 'center',
115
119
  flexDirection: 'row',
116
120
  justifyContent: 'flex-start',
117
- minWidth: vw(65),
118
121
  paddingHorizontal: 20,
119
122
  paddingVertical: 10,
120
123
  },
@@ -41,8 +41,8 @@ import {
41
41
  } from '../../contexts/overlayContext/OverlayContext';
42
42
  import { mergeThemes, ThemeProvider, useTheme } from '../../contexts/themeContext/ThemeContext';
43
43
 
44
+ import { useViewport } from '../../hooks/useViewport';
44
45
  import type { DefaultStreamChatGenerics } from '../../types/types';
45
- import { vh, vw } from '../../utils/utils';
46
46
  import { MessageTextContainer } from '../Message/MessageSimple/MessageTextContainer';
47
47
  import {
48
48
  OverlayReactions as DefaultOverlayReactions,
@@ -78,8 +78,6 @@ const styles = StyleSheet.create({
78
78
  scrollView: { overflow: Platform.OS === 'ios' ? 'visible' : 'scroll' },
79
79
  });
80
80
 
81
- const screenHeight = vh(100);
82
- const halfScreenHeight = vh(50);
83
81
  const DefaultMessageTextNumberOfLines = 5;
84
82
 
85
83
  export type MessageOverlayPropsWithContext<
@@ -154,6 +152,10 @@ const MessageOverlayWithContext = <
154
152
  };
155
153
 
156
154
  const { theme } = useTheme();
155
+ const { vh, vw } = useViewport();
156
+
157
+ const screenHeight = vh(100);
158
+ const halfScreenHeight = vh(50);
157
159
 
158
160
  const myMessageTheme = messagesContext?.myMessageTheme;
159
161
  const wrapMessageInTheme = clientId === message?.user?.id && !!myMessageTheme;
@@ -12,8 +12,8 @@ import {
12
12
  useThreadContext,
13
13
  } from '../../../contexts/threadContext/ThreadContext';
14
14
  import { useTranslationContext } from '../../../contexts/translationContext/TranslationContext';
15
+ import { useViewport } from '../../../hooks/useViewport';
15
16
  import type { DefaultStreamChatGenerics } from '../../../types/types';
16
- import { vw } from '../../../utils/utils';
17
17
 
18
18
  const styles = StyleSheet.create({
19
19
  absolute: { position: 'absolute' },
@@ -47,6 +47,7 @@ const ThreadFooterComponentWithContext = <
47
47
  ) => {
48
48
  const { Message, thread } = props;
49
49
  const { t } = useTranslationContext();
50
+ const { vw } = useViewport();
50
51
 
51
52
  const {
52
53
  theme: {
@@ -137,6 +137,11 @@ export type ChannelContextValue<
137
137
  scrollToFirstUnreadThreshold: number;
138
138
  setLastRead: React.Dispatch<React.SetStateAction<Date | undefined>>;
139
139
  setTargetedMessage: (messageId: string) => void;
140
+ /**
141
+ * Abort controller for cancelling async requests made for uploading images/files
142
+ * Its a map of filename and AbortController
143
+ */
144
+ uploadAbortControllerRef: React.MutableRefObject<Map<string, AbortController>>;
140
145
  /**
141
146
  *
142
147
  * ```json
@@ -35,8 +35,16 @@ import type { MoreOptionsButtonProps } from '../../components/MessageInput/MoreO
35
35
  import type { SendButtonProps } from '../../components/MessageInput/SendButton';
36
36
  import type { UploadProgressIndicatorProps } from '../../components/MessageInput/UploadProgressIndicator';
37
37
  import type { MessageType } from '../../components/MessageList/hooks/useMessageList';
38
- import { compressImage, pickDocument } from '../../native';
39
- import type { Asset, DefaultStreamChatGenerics, File, UnknownType } from '../../types/types';
38
+ import { pickDocument } from '../../native';
39
+ import type {
40
+ Asset,
41
+ DefaultStreamChatGenerics,
42
+ File,
43
+ FileUpload,
44
+ ImageUpload,
45
+ UnknownType,
46
+ } from '../../types/types';
47
+ import { compressedImageURI } from '../../utils/compressImage';
40
48
  import { removeReservedFields } from '../../utils/removeReservedFields';
41
49
  import {
42
50
  ACITriggerSettings,
@@ -58,28 +66,6 @@ import { DEFAULT_BASE_CONTEXT_VALUE } from '../utils/defaultBaseContextValue';
58
66
  import { getDisplayName } from '../utils/getDisplayName';
59
67
  import { isTestEnvironment } from '../utils/isTestEnvironment';
60
68
 
61
- export type FileUpload = {
62
- file: File;
63
- id: string;
64
- state: FileStateValue;
65
- duration?: number;
66
- paused?: boolean;
67
- progress?: number;
68
- thumb_url?: string;
69
- url?: string;
70
- };
71
-
72
- export type ImageUpload = {
73
- file: Partial<Asset> & {
74
- name?: string;
75
- };
76
- id: string;
77
- state: FileStateValue;
78
- height?: number;
79
- url?: string;
80
- width?: number;
81
- };
82
-
83
69
  export type MentionAllAppUsersQuery<
84
70
  StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
85
71
  > = {
@@ -438,7 +424,8 @@ export const MessageInputProvider = <
438
424
 
439
425
  const channelCapabities = useOwnCapabilitiesContext();
440
426
 
441
- const { channel, giphyEnabled } = useChannelContext<StreamChatGenerics>();
427
+ const { channel, giphyEnabled, uploadAbortControllerRef } =
428
+ useChannelContext<StreamChatGenerics>();
442
429
  const { thread } = useThreadContext<StreamChatGenerics>();
443
430
  const { t } = useTranslationContext();
444
431
  const inputBoxRef = useRef<TextInput | null>(null);
@@ -640,20 +627,21 @@ export const MessageInputProvider = <
640
627
  setText('');
641
628
  };
642
629
 
643
- const mapImageUploadToAttachment = (image: ImageUpload) => {
644
- const mime_type: string | boolean = lookup(image.file.filename as string);
630
+ const mapImageUploadToAttachment = (image: ImageUpload): Attachment<StreamChatGenerics> => {
631
+ const mime_type: string | boolean = lookup(image.file.name as string);
632
+ const name = image.file.name as string;
645
633
  return {
646
- fallback: image.file.name,
634
+ fallback: name,
647
635
  image_url: image.url,
648
636
  mime_type: mime_type ? mime_type : undefined,
649
637
  original_height: image.height,
650
638
  original_width: image.width,
651
- originalFile: image.file,
639
+ originalImage: image.file,
652
640
  type: 'image',
653
- } as Attachment;
641
+ };
654
642
  };
655
643
 
656
- const mapFileUploadToAttachment = (file: FileUpload) => {
644
+ const mapFileUploadToAttachment = (file: FileUpload): Attachment<StreamChatGenerics> => {
657
645
  if (file.file.mimeType?.startsWith('image/')) {
658
646
  return {
659
647
  fallback: file.file.name,
@@ -968,11 +956,24 @@ export const MessageInputProvider = <
968
956
  if (value.doDocUploadRequest) {
969
957
  response = await value.doDocUploadRequest(file, channel);
970
958
  } else if (channel && file.uri) {
959
+ uploadAbortControllerRef.current.set(
960
+ file.name,
961
+ client.createAbortControllerForNextRequest(),
962
+ );
971
963
  response = await channel.sendFile(file.uri, file.name, file.mimeType);
964
+ uploadAbortControllerRef.current.delete(file.name);
972
965
  }
973
966
  const extraData: Partial<FileUpload> = { thumb_url: response.thumb_url, url: response.file };
974
967
  setFileUploads(getUploadSetStateAction(id, FileState.UPLOADED, extraData));
975
968
  } catch (error: unknown) {
969
+ if (
970
+ error instanceof Error &&
971
+ (error.name === 'AbortError' || error.name === 'CanceledError')
972
+ ) {
973
+ // nothing to do
974
+ uploadAbortControllerRef.current.delete(file.name);
975
+ return;
976
+ }
976
977
  handleFileOrImageUploadError(error, false, id);
977
978
  }
978
979
  };
@@ -986,52 +987,55 @@ export const MessageInputProvider = <
986
987
 
987
988
  let response = {} as SendFileAPIResponse;
988
989
 
990
+ const uri = file.uri || '';
991
+ const filename = file.name ?? uri.replace(/^(file:\/\/|content:\/\/)/, '');
992
+
989
993
  try {
990
- const uri = file.uri || '';
991
- /**
992
- * We skip compression if:
993
- * - the file is from the camera as that should already be compressed
994
- * - the file has no height/width value to maintain for compression
995
- * - the compressImageQuality number is not present or is 1 (meaning no compression)
996
- */
997
- const compressedUri = await (file.source === 'camera' ||
998
- !file.height ||
999
- !file.width ||
1000
- typeof value.compressImageQuality !== 'number' ||
1001
- value.compressImageQuality === 1
1002
- ? uri
1003
- : compressImage({
1004
- compressImageQuality: value.compressImageQuality,
1005
- height: file.height,
1006
- uri,
1007
- width: file.width,
1008
- }));
1009
- const filename = file.filename ?? uri.replace(/^(file:\/\/|content:\/\/)/, '');
994
+ const compressedUri = await compressedImageURI(file, value.compressImageQuality);
1010
995
  const contentType = lookup(filename) || 'multipart/form-data';
1011
996
  if (value.doImageUploadRequest) {
1012
997
  response = await value.doImageUploadRequest(file, channel);
1013
998
  } else if (compressedUri && channel) {
1014
999
  if (value.sendImageAsync) {
1015
- channel.sendImage(compressedUri, filename, contentType).then((res) => {
1016
- if (asyncIds.includes(id)) {
1017
- // Evaluates to true if user hit send before image successfully uploaded
1018
- setAsyncUploads((prevAsyncUploads) => {
1019
- prevAsyncUploads[id] = {
1020
- ...prevAsyncUploads[id],
1021
- state: FileState.UPLOADED,
1022
- url: res.file,
1023
- };
1024
- return prevAsyncUploads;
1025
- });
1026
- } else {
1027
- const newImageUploads = getUploadSetStateAction<ImageUpload>(id, FileState.UPLOADED, {
1028
- url: res.file,
1029
- });
1030
- setImageUploads(newImageUploads);
1031
- }
1032
- });
1000
+ uploadAbortControllerRef.current.set(
1001
+ filename,
1002
+ client.createAbortControllerForNextRequest(),
1003
+ );
1004
+ channel.sendImage(compressedUri, filename, contentType).then(
1005
+ (res) => {
1006
+ uploadAbortControllerRef.current.delete(filename);
1007
+ if (asyncIds.includes(id)) {
1008
+ // Evaluates to true if user hit send before image successfully uploaded
1009
+ setAsyncUploads((prevAsyncUploads) => {
1010
+ prevAsyncUploads[id] = {
1011
+ ...prevAsyncUploads[id],
1012
+ state: FileState.UPLOADED,
1013
+ url: res.file,
1014
+ };
1015
+ return prevAsyncUploads;
1016
+ });
1017
+ } else {
1018
+ const newImageUploads = getUploadSetStateAction<ImageUpload>(
1019
+ id,
1020
+ FileState.UPLOADED,
1021
+ {
1022
+ url: res.file,
1023
+ },
1024
+ );
1025
+ setImageUploads(newImageUploads);
1026
+ }
1027
+ },
1028
+ () => {
1029
+ uploadAbortControllerRef.current.delete(filename);
1030
+ },
1031
+ );
1033
1032
  } else {
1033
+ uploadAbortControllerRef.current.set(
1034
+ filename,
1035
+ client.createAbortControllerForNextRequest(),
1036
+ );
1034
1037
  response = await channel.sendImage(compressedUri, filename, contentType);
1038
+ uploadAbortControllerRef.current.delete(filename);
1035
1039
  }
1036
1040
  }
1037
1041
 
@@ -1044,6 +1048,14 @@ export const MessageInputProvider = <
1044
1048
  setImageUploads(newImageUploads);
1045
1049
  }
1046
1050
  } catch (error) {
1051
+ if (
1052
+ error instanceof Error &&
1053
+ (error.name === 'AbortError' || error.name === 'CanceledError')
1054
+ ) {
1055
+ // nothing to do
1056
+ uploadAbortControllerRef.current.delete(filename);
1057
+ return;
1058
+ }
1047
1059
  handleFileOrImageUploadError(error, true, id);
1048
1060
  }
1049
1061
  };
@@ -7,7 +7,7 @@ Object {
7
7
  "fallback": undefined,
8
8
  "image_url": undefined,
9
9
  "mime_type": undefined,
10
- "originalFile": Object {
10
+ "originalImage": Object {
11
11
  "uri": "http://www.jackblack.com/tenac_iousd.bmp",
12
12
  },
13
13
  "original_height": undefined,
@@ -106,7 +106,7 @@ Object {
106
106
  "fallback": undefined,
107
107
  "image_url": undefined,
108
108
  "mime_type": undefined,
109
- "originalFile": Object {
109
+ "originalImage": Object {
110
110
  "uri": "http://www.jackblack.com/tenac_iousd.bmp",
111
111
  },
112
112
  "original_height": undefined,
@@ -117,7 +117,7 @@ Object {
117
117
  "fallback": undefined,
118
118
  "image_url": undefined,
119
119
  "mime_type": undefined,
120
- "originalFile": Object {
120
+ "originalImage": Object {
121
121
  "uri": "http://www.jackblack.com/tenac_iousd.bmp",
122
122
  },
123
123
  "original_height": undefined,