stream-chat-react-native-core 4.6.1 → 4.7.0-beta.3

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 (222) hide show
  1. package/lib/commonjs/components/Attachment/Attachment.js +22 -13
  2. package/lib/commonjs/components/Attachment/Attachment.js.map +1 -1
  3. package/lib/commonjs/components/Attachment/Card.js +23 -14
  4. package/lib/commonjs/components/Attachment/Card.js.map +1 -1
  5. package/lib/commonjs/components/Attachment/Gallery.js +72 -37
  6. package/lib/commonjs/components/Attachment/Gallery.js.map +1 -1
  7. package/lib/commonjs/components/Attachment/VideoThumbnail.js +83 -0
  8. package/lib/commonjs/components/Attachment/VideoThumbnail.js.map +1 -0
  9. package/lib/commonjs/components/Attachment/hooks/useGoToURL.js +1 -1
  10. package/lib/commonjs/components/Attachment/hooks/useGoToURL.js.map +1 -1
  11. package/lib/commonjs/components/Attachment/utils/buildGallery/buildThumbnail.js +1 -0
  12. package/lib/commonjs/components/Attachment/utils/buildGallery/buildThumbnail.js.map +1 -1
  13. package/lib/commonjs/components/Attachment/utils/getAspectRatio.js +5 -5
  14. package/lib/commonjs/components/Attachment/utils/getAspectRatio.js.map +1 -1
  15. package/lib/commonjs/components/Channel/Channel.js +19 -14
  16. package/lib/commonjs/components/Channel/Channel.js.map +1 -1
  17. package/lib/commonjs/components/Channel/hooks/useCreateMessagesContext.js +4 -2
  18. package/lib/commonjs/components/Channel/hooks/useCreateMessagesContext.js.map +1 -1
  19. package/lib/commonjs/components/ChannelPreview/hooks/useChannelPreviewDisplayName.js +43 -28
  20. package/lib/commonjs/components/ChannelPreview/hooks/useChannelPreviewDisplayName.js.map +1 -1
  21. package/lib/commonjs/components/Chat/hooks/useIsOnline.js +6 -6
  22. package/lib/commonjs/components/Chat/hooks/useIsOnline.js.map +1 -1
  23. package/lib/commonjs/components/ImageGallery/ImageGallery.js +167 -345
  24. package/lib/commonjs/components/ImageGallery/ImageGallery.js.map +1 -1
  25. package/lib/commonjs/components/ImageGallery/components/AnimatedGalleryImage.js +4 -4
  26. package/lib/commonjs/components/ImageGallery/components/AnimatedGalleryImage.js.map +1 -1
  27. package/lib/commonjs/components/ImageGallery/components/AnimatedGalleryVideo.js +225 -0
  28. package/lib/commonjs/components/ImageGallery/components/AnimatedGalleryVideo.js.map +1 -0
  29. package/lib/commonjs/components/ImageGallery/components/ImageGalleryFooter.js +102 -40
  30. package/lib/commonjs/components/ImageGallery/components/ImageGalleryFooter.js.map +1 -1
  31. package/lib/commonjs/components/ImageGallery/components/ImageGalleryVideoControl.js +145 -0
  32. package/lib/commonjs/components/ImageGallery/components/ImageGalleryVideoControl.js.map +1 -0
  33. package/lib/commonjs/components/ImageGallery/components/ImageGrid.js +31 -34
  34. package/lib/commonjs/components/ImageGallery/components/ImageGrid.js.map +1 -1
  35. package/lib/commonjs/components/ImageGallery/components/ProgressControl.js +153 -0
  36. package/lib/commonjs/components/ImageGallery/components/ProgressControl.js.map +1 -0
  37. package/lib/commonjs/components/ImageGallery/hooks/useImageGalleryGestures.js +373 -0
  38. package/lib/commonjs/components/ImageGallery/hooks/useImageGalleryGestures.js.map +1 -0
  39. package/lib/commonjs/components/Message/Message.js +23 -13
  40. package/lib/commonjs/components/Message/Message.js.map +1 -1
  41. package/lib/commonjs/components/Message/MessageSimple/utils/renderText.js +22 -15
  42. package/lib/commonjs/components/Message/MessageSimple/utils/renderText.js.map +1 -1
  43. package/lib/commonjs/components/Message/hooks/useCreateMessageContext.js +4 -2
  44. package/lib/commonjs/components/Message/hooks/useCreateMessageContext.js.map +1 -1
  45. package/lib/commonjs/components/MessageOverlay/MessageOverlay.js +25 -23
  46. package/lib/commonjs/components/MessageOverlay/MessageOverlay.js.map +1 -1
  47. package/lib/commonjs/components/Reply/Reply.js +32 -12
  48. package/lib/commonjs/components/Reply/Reply.js.map +1 -1
  49. package/lib/commonjs/components/Spinner/Spinner.js +12 -4
  50. package/lib/commonjs/components/Spinner/Spinner.js.map +1 -1
  51. package/lib/commonjs/components/index.js +26 -0
  52. package/lib/commonjs/components/index.js.map +1 -1
  53. package/lib/commonjs/contexts/messageContext/MessageContext.js +2 -2
  54. package/lib/commonjs/contexts/messageContext/MessageContext.js.map +1 -1
  55. package/lib/commonjs/contexts/messageInputContext/MessageInputContext.js +15 -4
  56. package/lib/commonjs/contexts/messageInputContext/MessageInputContext.js.map +1 -1
  57. package/lib/commonjs/contexts/messageOverlayContext/MessageOverlayContext.js +2 -2
  58. package/lib/commonjs/contexts/messageOverlayContext/MessageOverlayContext.js.map +1 -1
  59. package/lib/commonjs/contexts/messagesContext/MessagesContext.js +2 -2
  60. package/lib/commonjs/contexts/messagesContext/MessagesContext.js.map +1 -1
  61. package/lib/commonjs/contexts/themeContext/utils/theme.js +10 -1
  62. package/lib/commonjs/contexts/themeContext/utils/theme.js.map +1 -1
  63. package/lib/commonjs/icons/Pause.js +61 -0
  64. package/lib/commonjs/icons/Pause.js.map +1 -0
  65. package/lib/commonjs/icons/Play.js +42 -0
  66. package/lib/commonjs/icons/Play.js.map +1 -0
  67. package/lib/commonjs/icons/index.js +26 -0
  68. package/lib/commonjs/icons/index.js.map +1 -1
  69. package/lib/commonjs/mock-builders/api/queryMembers.js +98 -1
  70. package/lib/commonjs/mock-builders/api/queryMembers.js.map +1 -1
  71. package/lib/commonjs/native.js +7 -1
  72. package/lib/commonjs/native.js.map +1 -1
  73. package/lib/commonjs/utils/getUrlOfImageAttachment.js +1 -1
  74. package/lib/commonjs/utils/getUrlOfImageAttachment.js.map +1 -1
  75. package/lib/commonjs/version.json +1 -1
  76. package/lib/module/components/Attachment/Attachment.js +22 -13
  77. package/lib/module/components/Attachment/Attachment.js.map +1 -1
  78. package/lib/module/components/Attachment/Card.js +23 -14
  79. package/lib/module/components/Attachment/Card.js.map +1 -1
  80. package/lib/module/components/Attachment/Gallery.js +72 -37
  81. package/lib/module/components/Attachment/Gallery.js.map +1 -1
  82. package/lib/module/components/Attachment/VideoThumbnail.js +83 -0
  83. package/lib/module/components/Attachment/VideoThumbnail.js.map +1 -0
  84. package/lib/module/components/Attachment/hooks/useGoToURL.js +1 -1
  85. package/lib/module/components/Attachment/hooks/useGoToURL.js.map +1 -1
  86. package/lib/module/components/Attachment/utils/buildGallery/buildThumbnail.js +1 -0
  87. package/lib/module/components/Attachment/utils/buildGallery/buildThumbnail.js.map +1 -1
  88. package/lib/module/components/Attachment/utils/getAspectRatio.js +5 -5
  89. package/lib/module/components/Attachment/utils/getAspectRatio.js.map +1 -1
  90. package/lib/module/components/Channel/Channel.js +19 -14
  91. package/lib/module/components/Channel/Channel.js.map +1 -1
  92. package/lib/module/components/Channel/hooks/useCreateMessagesContext.js +4 -2
  93. package/lib/module/components/Channel/hooks/useCreateMessagesContext.js.map +1 -1
  94. package/lib/module/components/ChannelPreview/hooks/useChannelPreviewDisplayName.js +43 -28
  95. package/lib/module/components/ChannelPreview/hooks/useChannelPreviewDisplayName.js.map +1 -1
  96. package/lib/module/components/Chat/hooks/useIsOnline.js +6 -6
  97. package/lib/module/components/Chat/hooks/useIsOnline.js.map +1 -1
  98. package/lib/module/components/ImageGallery/ImageGallery.js +167 -345
  99. package/lib/module/components/ImageGallery/ImageGallery.js.map +1 -1
  100. package/lib/module/components/ImageGallery/components/AnimatedGalleryImage.js +4 -4
  101. package/lib/module/components/ImageGallery/components/AnimatedGalleryImage.js.map +1 -1
  102. package/lib/module/components/ImageGallery/components/AnimatedGalleryVideo.js +225 -0
  103. package/lib/module/components/ImageGallery/components/AnimatedGalleryVideo.js.map +1 -0
  104. package/lib/module/components/ImageGallery/components/ImageGalleryFooter.js +102 -40
  105. package/lib/module/components/ImageGallery/components/ImageGalleryFooter.js.map +1 -1
  106. package/lib/module/components/ImageGallery/components/ImageGalleryVideoControl.js +145 -0
  107. package/lib/module/components/ImageGallery/components/ImageGalleryVideoControl.js.map +1 -0
  108. package/lib/module/components/ImageGallery/components/ImageGrid.js +31 -34
  109. package/lib/module/components/ImageGallery/components/ImageGrid.js.map +1 -1
  110. package/lib/module/components/ImageGallery/components/ProgressControl.js +153 -0
  111. package/lib/module/components/ImageGallery/components/ProgressControl.js.map +1 -0
  112. package/lib/module/components/ImageGallery/hooks/useImageGalleryGestures.js +373 -0
  113. package/lib/module/components/ImageGallery/hooks/useImageGalleryGestures.js.map +1 -0
  114. package/lib/module/components/Message/Message.js +23 -13
  115. package/lib/module/components/Message/Message.js.map +1 -1
  116. package/lib/module/components/Message/MessageSimple/utils/renderText.js +22 -15
  117. package/lib/module/components/Message/MessageSimple/utils/renderText.js.map +1 -1
  118. package/lib/module/components/Message/hooks/useCreateMessageContext.js +4 -2
  119. package/lib/module/components/Message/hooks/useCreateMessageContext.js.map +1 -1
  120. package/lib/module/components/MessageOverlay/MessageOverlay.js +25 -23
  121. package/lib/module/components/MessageOverlay/MessageOverlay.js.map +1 -1
  122. package/lib/module/components/Reply/Reply.js +32 -12
  123. package/lib/module/components/Reply/Reply.js.map +1 -1
  124. package/lib/module/components/Spinner/Spinner.js +12 -4
  125. package/lib/module/components/Spinner/Spinner.js.map +1 -1
  126. package/lib/module/components/index.js +26 -0
  127. package/lib/module/components/index.js.map +1 -1
  128. package/lib/module/contexts/messageContext/MessageContext.js +2 -2
  129. package/lib/module/contexts/messageContext/MessageContext.js.map +1 -1
  130. package/lib/module/contexts/messageInputContext/MessageInputContext.js +15 -4
  131. package/lib/module/contexts/messageInputContext/MessageInputContext.js.map +1 -1
  132. package/lib/module/contexts/messageOverlayContext/MessageOverlayContext.js +2 -2
  133. package/lib/module/contexts/messageOverlayContext/MessageOverlayContext.js.map +1 -1
  134. package/lib/module/contexts/messagesContext/MessagesContext.js +2 -2
  135. package/lib/module/contexts/messagesContext/MessagesContext.js.map +1 -1
  136. package/lib/module/contexts/themeContext/utils/theme.js +10 -1
  137. package/lib/module/contexts/themeContext/utils/theme.js.map +1 -1
  138. package/lib/module/icons/Pause.js +61 -0
  139. package/lib/module/icons/Pause.js.map +1 -0
  140. package/lib/module/icons/Play.js +42 -0
  141. package/lib/module/icons/Play.js.map +1 -0
  142. package/lib/module/icons/index.js +26 -0
  143. package/lib/module/icons/index.js.map +1 -1
  144. package/lib/module/mock-builders/api/queryMembers.js +98 -1
  145. package/lib/module/mock-builders/api/queryMembers.js.map +1 -1
  146. package/lib/module/native.js +7 -1
  147. package/lib/module/native.js.map +1 -1
  148. package/lib/module/utils/getUrlOfImageAttachment.js +1 -1
  149. package/lib/module/utils/getUrlOfImageAttachment.js.map +1 -1
  150. package/lib/module/version.json +1 -1
  151. package/lib/typescript/components/Attachment/Gallery.d.ts +1 -1
  152. package/lib/typescript/components/Attachment/VideoThumbnail.d.ts +4 -0
  153. package/lib/typescript/components/Attachment/utils/buildGallery/types.d.ts +1 -0
  154. package/lib/typescript/components/Attachment/utils/getAspectRatio.d.ts +1 -1
  155. package/lib/typescript/components/Channel/Channel.d.ts +1 -1
  156. package/lib/typescript/components/Channel/hooks/useCreateMessagesContext.d.ts +1 -1
  157. package/lib/typescript/components/ChannelPreview/hooks/__tests__/useChannelPreviewDisplayName.test.d.ts +1 -0
  158. package/lib/typescript/components/ChannelPreview/hooks/useChannelPreviewDisplayName.d.ts +4 -4
  159. package/lib/typescript/components/Chat/hooks/useIsOnline.d.ts +1 -1
  160. package/lib/typescript/components/ImageGallery/ImageGallery.d.ts +2 -0
  161. package/lib/typescript/components/ImageGallery/components/AnimatedGalleryVideo.d.ts +27 -0
  162. package/lib/typescript/components/ImageGallery/components/ImageGalleryFooter.d.ts +18 -2
  163. package/lib/typescript/components/ImageGallery/components/ImageGalleryVideoControl.d.ts +3 -0
  164. package/lib/typescript/components/ImageGallery/components/ProgressControl.d.ts +5 -0
  165. package/lib/typescript/components/ImageGallery/hooks/useImageGalleryGestures.d.ts +36 -0
  166. package/lib/typescript/components/Message/Message.d.ts +9 -3
  167. package/lib/typescript/components/Message/hooks/useCreateMessageContext.d.ts +1 -1
  168. package/lib/typescript/components/Spinner/Spinner.d.ts +7 -1
  169. package/lib/typescript/components/index.d.ts +2 -0
  170. package/lib/typescript/contexts/messageContext/MessageContext.d.ts +3 -1
  171. package/lib/typescript/contexts/messageOverlayContext/MessageOverlayContext.d.ts +1 -0
  172. package/lib/typescript/contexts/messagesContext/MessagesContext.d.ts +2 -0
  173. package/lib/typescript/contexts/themeContext/utils/theme.d.ts +9 -0
  174. package/lib/typescript/icons/Pause.d.ts +3 -0
  175. package/lib/typescript/icons/Play.d.ts +3 -0
  176. package/lib/typescript/icons/index.d.ts +2 -0
  177. package/lib/typescript/mock-builders/api/queryMembers.d.ts +161 -0
  178. package/lib/typescript/mock-builders/api/utils.d.ts +7 -0
  179. package/lib/typescript/mock-builders/generator/user.d.ts +30 -0
  180. package/lib/typescript/mock-builders/mock.d.ts +3 -0
  181. package/lib/typescript/native.d.ts +66 -1
  182. package/package.json +1 -1
  183. package/src/components/Attachment/Attachment.tsx +11 -7
  184. package/src/components/Attachment/Card.tsx +3 -0
  185. package/src/components/Attachment/Gallery.tsx +75 -36
  186. package/src/components/Attachment/VideoThumbnail.tsx +45 -0
  187. package/src/components/Attachment/hooks/useGoToURL.ts +1 -1
  188. package/src/components/Attachment/utils/buildGallery/buildThumbnail.ts +1 -0
  189. package/src/components/Attachment/utils/buildGallery/types.ts +1 -0
  190. package/src/components/Attachment/utils/getAspectRatio.ts +7 -5
  191. package/src/components/Channel/Channel.tsx +4 -0
  192. package/src/components/Channel/hooks/useCreateMessagesContext.ts +2 -0
  193. package/src/components/ChannelPreview/hooks/__tests__/useChannelPreviewDisplayName.test.tsx +83 -0
  194. package/src/components/ChannelPreview/hooks/useChannelPreviewDisplayName.ts +43 -26
  195. package/src/components/Chat/hooks/useIsOnline.ts +7 -7
  196. package/src/components/ImageGallery/ImageGallery.tsx +145 -667
  197. package/src/components/ImageGallery/components/AnimatedGalleryImage.tsx +4 -4
  198. package/src/components/ImageGallery/components/AnimatedGalleryVideo.tsx +224 -0
  199. package/src/components/ImageGallery/components/ImageGalleryFooter.tsx +114 -19
  200. package/src/components/ImageGallery/components/ImageGalleryVideoControl.tsx +103 -0
  201. package/src/components/ImageGallery/components/ImageGrid.tsx +12 -25
  202. package/src/components/ImageGallery/components/ProgressControl.tsx +107 -0
  203. package/src/components/ImageGallery/hooks/useImageGalleryGestures.tsx +722 -0
  204. package/src/components/Message/Message.tsx +18 -7
  205. package/src/components/Message/MessageSimple/utils/renderText.tsx +6 -1
  206. package/src/components/Message/hooks/useCreateMessageContext.ts +2 -0
  207. package/src/components/MessageOverlay/MessageOverlay.tsx +2 -0
  208. package/src/components/Reply/Reply.tsx +36 -23
  209. package/src/components/Spinner/Spinner.tsx +11 -4
  210. package/src/components/index.ts +2 -0
  211. package/src/contexts/messageContext/MessageContext.tsx +2 -0
  212. package/src/contexts/messageInputContext/MessageInputContext.tsx +11 -0
  213. package/src/contexts/messageOverlayContext/MessageOverlayContext.tsx +1 -0
  214. package/src/contexts/messagesContext/MessagesContext.tsx +2 -0
  215. package/src/contexts/themeContext/utils/theme.ts +18 -0
  216. package/src/icons/Pause.tsx +14 -0
  217. package/src/icons/Play.tsx +17 -0
  218. package/src/icons/index.ts +2 -0
  219. package/src/mock-builders/api/queryMembers.js +98 -0
  220. package/src/native.ts +59 -1
  221. package/src/utils/getUrlOfImageAttachment.ts +1 -1
  222. package/src/version.json +1 -1
@@ -53,15 +53,13 @@ import {
53
53
  import type { MessageActionListItemProps } from '../MessageOverlay/MessageActionListItem';
54
54
 
55
55
  export type TouchableEmitter =
56
- | 'card'
57
56
  | 'fileAttachment'
58
57
  | 'gallery'
59
58
  | 'giphy'
60
59
  | 'message'
61
60
  | 'messageContent'
62
61
  | 'messageReplies'
63
- | 'reactionList'
64
- | 'textLink';
62
+ | 'reactionList';
65
63
 
66
64
  export type TextMentionTouchableHandlerPayload<
67
65
  StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
@@ -70,21 +68,27 @@ export type TextMentionTouchableHandlerPayload<
70
68
  additionalInfo?: { user?: UserResponse<StreamChatGenerics> };
71
69
  };
72
70
 
71
+ export type UrlTouchableHandlerPayload = {
72
+ emitter: 'textLink' | 'card';
73
+ additionalInfo?: { url?: string };
74
+ };
75
+
73
76
  export type TouchableHandlerPayload = {
74
77
  defaultHandler?: () => void;
75
78
  event?: GestureResponderEvent;
76
79
  } & (
77
80
  | {
78
- additionalInfo?: Record<string, unknown>;
79
81
  emitter?: TouchableEmitter;
80
82
  }
81
83
  | TextMentionTouchableHandlerPayload
84
+ | UrlTouchableHandlerPayload
82
85
  );
83
86
 
84
87
  export type MessageTouchableHandlerPayload<
85
88
  StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
86
89
  > = TouchableHandlerPayload & {
87
90
  actionHandlers?: MessageActionHandlers;
91
+ additionalInfo?: Record<string, unknown>;
88
92
  message?: MessageType<StreamChatGenerics>;
89
93
  };
90
94
 
@@ -325,9 +329,12 @@ const MessageWithContext = <
325
329
  !isMessageTypeDeleted && Array.isArray(message.attachments)
326
330
  ? message.attachments.reduce(
327
331
  (acc, cur) => {
328
- if (cur.type === 'file' || cur.type === 'video') {
332
+ if (cur.type === 'file') {
329
333
  acc.files.push(cur);
330
334
  acc.other = []; // remove other attachments if a file exists
335
+ } else if (cur.type === 'video' && !cur.og_scrape_url) {
336
+ acc.videos.push({ image_url: cur.asset_url, type: 'video' });
337
+ acc.other = [];
331
338
  } else if (cur.type === 'image' && !cur.title_link && !cur.og_scrape_url) {
332
339
  /**
333
340
  * this next if is not combined with the above one for cases where we have
@@ -338,7 +345,7 @@ const MessageWithContext = <
338
345
  acc.other = []; // remove other attachments if an image exists
339
346
  }
340
347
  // only add other attachments if there are no files/images
341
- } else if (!acc.files.length && !acc.images.length) {
348
+ } else if (!acc.files.length && !acc.images.length && !acc.videos.length) {
342
349
  acc.other.push(cur);
343
350
  }
344
351
 
@@ -348,12 +355,14 @@ const MessageWithContext = <
348
355
  files: [] as Attachment<StreamChatGenerics>[],
349
356
  images: [] as Attachment<StreamChatGenerics>[],
350
357
  other: [] as Attachment<StreamChatGenerics>[],
358
+ videos: [] as Attachment<StreamChatGenerics>[],
351
359
  },
352
360
  )
353
361
  : {
354
362
  files: [] as Attachment<StreamChatGenerics>[],
355
363
  images: [] as Attachment<StreamChatGenerics>[],
356
364
  other: [] as Attachment<StreamChatGenerics>[],
365
+ videos: [] as Attachment<StreamChatGenerics>[],
357
366
  };
358
367
 
359
368
  /**
@@ -375,7 +384,7 @@ const MessageWithContext = <
375
384
  case 'files':
376
385
  return !!attachments.files.length;
377
386
  case 'gallery':
378
- return !!attachments.images.length;
387
+ return !!attachments.images.length || !!attachments.videos.length;
379
388
  case 'text':
380
389
  default:
381
390
  return !!message.text;
@@ -536,6 +545,7 @@ const MessageWithContext = <
536
545
  ownCapabilities,
537
546
  supportedReactions,
538
547
  threadList,
548
+ videos: attachments.videos,
539
549
  });
540
550
 
541
551
  setOverlay('message');
@@ -651,6 +661,7 @@ const MessageWithContext = <
651
661
  showMessageOverlay,
652
662
  showMessageStatus: typeof showMessageStatus === 'boolean' ? showMessageStatus : isMyMessage,
653
663
  threadList,
664
+ videos: attachments.videos,
654
665
  });
655
666
 
656
667
  if (!(isMessageTypeDeleted || messageContentOrder.length)) return null;
@@ -161,10 +161,14 @@ export const renderText = <
161
161
  };
162
162
 
163
163
  const link: ReactNodeOutput = (node, output, { ...state }) => {
164
+ const url = node.target;
164
165
  const onPress = (event: GestureResponderEvent) => {
165
166
  if (!preventPress && onPressParam) {
166
167
  onPressParam({
167
- defaultHandler: () => onLink(node.target),
168
+ additionalInfo: { url },
169
+ defaultHandler: () => {
170
+ onLink(url);
171
+ },
168
172
  emitter: 'textLink',
169
173
  event,
170
174
  });
@@ -174,6 +178,7 @@ export const renderText = <
174
178
  const onLongPress = (event: GestureResponderEvent) => {
175
179
  if (!preventPress && onLongPressParam) {
176
180
  onLongPressParam({
181
+ additionalInfo: { url },
177
182
  emitter: 'textLink',
178
183
  event,
179
184
  });
@@ -42,6 +42,7 @@ export const useCreateMessageContext = <
42
42
  showMessageOverlay,
43
43
  showMessageStatus,
44
44
  threadList,
45
+ videos,
45
46
  }: MessageContextValue<StreamChatGenerics>) => {
46
47
  const groupStylesLength = groupStyles.length;
47
48
  const reactionsValue = reactions.map(({ own, type }) => `${own}${type}`).join();
@@ -93,6 +94,7 @@ export const useCreateMessageContext = <
93
94
  showMessageOverlay,
94
95
  showMessageStatus,
95
96
  threadList,
97
+ videos,
96
98
  }),
97
99
  [
98
100
  actionsEnabled,
@@ -135,6 +135,7 @@ const MessageOverlayWithContext = <
135
135
  OverlayReactionsAvatar = OverlayReactionsAvatarDefault,
136
136
  setOverlay,
137
137
  threadList,
138
+ videos,
138
139
  isMyMessage,
139
140
  messageReactions,
140
141
  error,
@@ -451,6 +452,7 @@ const MessageOverlayWithContext = <
451
452
  key={`gallery_${messageContentOrderIndex}`}
452
453
  message={message}
453
454
  threadList={threadList}
455
+ videos={videos}
454
456
  />
455
457
  )
456
458
  );
@@ -24,6 +24,7 @@ import { getResizedImageUrl } from '../../utils/getResizedImageUrl';
24
24
  import { emojiRegex } from '../../utils/utils';
25
25
 
26
26
  import { FileIcon as FileIconDefault } from '../Attachment/FileIcon';
27
+ import { VideoThumbnail } from '../Attachment/VideoThumbnail';
27
28
  import { MessageAvatar as MessageAvatarDefault } from '../Message/MessageSimple/MessageAvatar';
28
29
  import { MessageTextContainer } from '../Message/MessageSimple/MessageTextContainer';
29
30
 
@@ -52,6 +53,13 @@ const styles = StyleSheet.create({
52
53
  },
53
54
  text: { fontSize: 12 },
54
55
  textContainer: { maxWidth: undefined, paddingHorizontal: 8 },
56
+ videoAttachment: {
57
+ borderRadius: 8,
58
+ height: 50,
59
+ marginLeft: 8,
60
+ marginVertical: 8,
61
+ width: 50,
62
+ },
55
63
  });
56
64
 
57
65
  type ReplyPropsWithContext<
@@ -76,10 +84,9 @@ const getMessageType = <
76
84
  ) => {
77
85
  let messageType;
78
86
 
79
- const isLastAttachmentFile =
80
- lastAttachment.type === 'file' ||
81
- lastAttachment.type === 'audio' ||
82
- lastAttachment.type === 'video';
87
+ const isLastAttachmentFile = lastAttachment.type === 'file' || lastAttachment.type === 'audio';
88
+
89
+ const isLastAttachmentVideo = lastAttachment.type === 'video';
83
90
 
84
91
  const isLastAttachmentGiphy = lastAttachment.type === 'giphy' || lastAttachment.type === 'imgur';
85
92
 
@@ -90,6 +97,8 @@ const getMessageType = <
90
97
 
91
98
  if (isLastAttachmentFile) {
92
99
  messageType = 'file';
100
+ } else if (isLastAttachmentVideo) {
101
+ messageType = 'video';
93
102
  } else if (isLastAttachmentImageOrGiphy) {
94
103
  if (isLastAttachmentImage) messageType = 'image';
95
104
  else messageType = undefined;
@@ -194,6 +203,7 @@ const ReplyWithContext = <
194
203
  />
195
204
  ) : null
196
205
  ) : null}
206
+ {messageType === 'video' ? <VideoThumbnail style={[styles.videoAttachment]} /> : null}
197
207
  <MessageTextContainer<StreamChatGenerics>
198
208
  markdownStyles={
199
209
  quotedMessage.deleted_at
@@ -210,6 +220,8 @@ const ReplyWithContext = <
210
220
  : quotedMessage.text
211
221
  : messageType === 'image'
212
222
  ? t('Photo')
223
+ : messageType === 'video'
224
+ ? 'Video'
213
225
  : messageType === 'file'
214
226
  ? lastAttachment?.title || ''
215
227
  : '',
@@ -218,25 +230,26 @@ const ReplyWithContext = <
218
230
  styles={{
219
231
  textContainer: [
220
232
  {
221
- marginRight: hasImage
222
- ? Number(
223
- stylesProp.imageAttachment?.height ||
224
- imageAttachment.height ||
225
- styles.imageAttachment.height,
226
- ) +
227
- Number(
228
- stylesProp.imageAttachment?.marginLeft ||
229
- imageAttachment.marginLeft ||
230
- styles.imageAttachment.marginLeft,
231
- )
232
- : messageType === 'file'
233
- ? attachmentSize +
234
- Number(
235
- stylesProp.fileAttachmentContainer?.paddingLeft ||
236
- fileAttachmentContainer.paddingLeft ||
237
- styles.fileAttachmentContainer.paddingLeft,
238
- )
239
- : undefined,
233
+ marginRight:
234
+ hasImage || messageType === 'video'
235
+ ? Number(
236
+ stylesProp.imageAttachment?.height ||
237
+ imageAttachment.height ||
238
+ styles.imageAttachment.height,
239
+ ) +
240
+ Number(
241
+ stylesProp.imageAttachment?.marginLeft ||
242
+ imageAttachment.marginLeft ||
243
+ styles.imageAttachment.marginLeft,
244
+ )
245
+ : messageType === 'file'
246
+ ? attachmentSize +
247
+ Number(
248
+ stylesProp.fileAttachmentContainer?.paddingLeft ||
249
+ fileAttachmentContainer.paddingLeft ||
250
+ styles.fileAttachmentContainer.paddingLeft,
251
+ )
252
+ : undefined,
240
253
  },
241
254
  styles.textContainer,
242
255
  textContainer,
@@ -1,5 +1,5 @@
1
1
  import React, { useEffect } from 'react';
2
- import { StyleSheet, ViewStyle } from 'react-native';
2
+ import { StyleProp, StyleSheet, ViewStyle } from 'react-native';
3
3
  import Animated, {
4
4
  Easing,
5
5
  useAnimatedStyle,
@@ -20,8 +20,15 @@ const styles = StyleSheet.create({
20
20
  },
21
21
  });
22
22
 
23
- export const Spinner: React.FC = () => {
23
+ export type SpinnerProps = {
24
+ height?: number;
25
+ style?: StyleProp<ViewStyle>;
26
+ width?: number;
27
+ };
28
+
29
+ export const Spinner: React.FC<SpinnerProps> = (props) => {
24
30
  const rotation = useSharedValue(0);
31
+ const { height, style, width } = props;
25
32
 
26
33
  const {
27
34
  theme: {
@@ -49,8 +56,8 @@ export const Spinner: React.FC = () => {
49
56
  }, []);
50
57
 
51
58
  return (
52
- <Animated.View style={[styles.spinner, animatedStyle, spinner]}>
53
- <Loading stopColor={accent_blue} />
59
+ <Animated.View style={[style, styles.spinner, animatedStyle, spinner, { height, width }]}>
60
+ <Loading height={height} stopColor={accent_blue} width={width} />
54
61
  </Animated.View>
55
62
  );
56
63
  };
@@ -6,6 +6,7 @@ export * from './Attachment/FileAttachmentGroup';
6
6
  export * from './Attachment/FileIcon';
7
7
  export * from './Attachment/Gallery';
8
8
  export * from './Attachment/Giphy';
9
+ export * from './Attachment/VideoThumbnail';
9
10
  export * from './Attachment/utils/buildGallery/buildGallery';
10
11
 
11
12
  export * from './AttachmentPicker/AttachmentPicker';
@@ -74,6 +75,7 @@ export * from './Chat/hooks/useMutedUsers';
74
75
 
75
76
  export * from './ImageGallery/ImageGallery';
76
77
  export * from './ImageGallery/components/AnimatedGalleryImage';
78
+ export * from './ImageGallery/components/AnimatedGalleryVideo';
77
79
  export * from './ImageGallery/components/ImageGalleryFooter';
78
80
  export * from './ImageGallery/components/ImageGalleryHeader';
79
81
  export * from './ImageGallery/components/ImageGalleryOverlay';
@@ -91,6 +91,8 @@ export type MessageContextValue<
91
91
  showMessageStatus: boolean;
92
92
  /** Whether or not the Message is part of a Thread */
93
93
  threadList: boolean;
94
+ /** The videos attached to a message */
95
+ videos: Attachment<StreamChatGenerics>[];
94
96
  goToMessage?: (messageId: string) => void;
95
97
  /** Latest message id on current channel */
96
98
  lastReceivedId?: string;
@@ -665,6 +665,8 @@ export const MessageInputProvider = <
665
665
  attachments.push({
666
666
  fallback: image.file.name,
667
667
  image_url: image.url,
668
+ original_height: image.height,
669
+ original_width: image.width,
668
670
  type: 'image',
669
671
  } as Attachment<StreamChatGenerics>);
670
672
  }
@@ -686,6 +688,15 @@ export const MessageInputProvider = <
686
688
  image_url: file.url,
687
689
  type: 'image',
688
690
  } as Attachment<StreamChatGenerics>);
691
+ } else if (file.file.type?.startsWith('audio/')) {
692
+ attachments.push({
693
+ asset_url: file.url,
694
+ duration: file.file.duration,
695
+ file_size: file.file.size,
696
+ mime_type: file.file.type,
697
+ title: file.file.name,
698
+ type: 'audio',
699
+ } as Attachment<StreamChatGenerics>);
689
700
  } else if (file.file.type?.startsWith('video/')) {
690
701
  attachments.push({
691
702
  asset_url: file.url,
@@ -40,6 +40,7 @@ export type MessageOverlayData<
40
40
  ownCapabilities?: OwnCapabilitiesContextValue;
41
41
  supportedReactions?: ReactionData[];
42
42
  threadList?: boolean;
43
+ videos?: Attachment<StreamChatGenerics>[];
43
44
  };
44
45
 
45
46
  export type MessageOverlayContextValue<
@@ -14,6 +14,7 @@ import type { FileAttachmentGroupProps } from '../../components/Attachment/FileA
14
14
  import type { FileIconProps } from '../../components/Attachment/FileIcon';
15
15
  import type { GalleryProps } from '../../components/Attachment/Gallery';
16
16
  import type { GiphyProps } from '../../components/Attachment/Giphy';
17
+ import type { VideoThumbnailProps } from '../../components/Attachment/VideoThumbnail';
17
18
  import type {
18
19
  MessageProps,
19
20
  MessageTouchableHandlerPayload,
@@ -228,6 +229,7 @@ export type MessagesContextValue<
228
229
  * Defaults to https://github.com/GetStream/stream-chat-react-native/blob/main/package/src/components/Attachment/Card.tsx
229
230
  */
230
231
  UrlPreview: React.ComponentType<CardProps<StreamChatGenerics>>;
232
+ VideoThumbnail: React.ComponentType<VideoThumbnailProps>;
231
233
  /**
232
234
  * Provide any additional props for `TouchableOpacity` which wraps inner MessageContent component here.
233
235
  * Please check docs for TouchableOpacity for supported props - https://reactnative.dev/docs/touchableopacity#props
@@ -196,6 +196,11 @@ export type Theme = {
196
196
  rightContainer: ViewStyle;
197
197
  usernameText: TextStyle;
198
198
  };
199
+ videoControl: {
200
+ durationTextStyle: TextStyle;
201
+ roundedView: ViewStyle;
202
+ videoContainer: ViewStyle;
203
+ };
199
204
  backgroundColor?: string;
200
205
  pager?: ViewStyle;
201
206
  slide?: ImageStyle;
@@ -476,6 +481,10 @@ export type Theme = {
476
481
  timeIcon: IconProps;
477
482
  };
478
483
  targetedMessageUnderlay: ViewStyle;
484
+ videoThumbnail: {
485
+ container: ViewStyle;
486
+ roundedView: ViewStyle;
487
+ };
479
488
  };
480
489
  overlay: {
481
490
  container: ViewStyle;
@@ -669,6 +678,11 @@ export const defaultTheme: Theme = {
669
678
  rightContainer: {},
670
679
  usernameText: {},
671
680
  },
681
+ videoControl: {
682
+ durationTextStyle: {},
683
+ roundedView: {},
684
+ videoContainer: {},
685
+ },
672
686
  },
673
687
  inlineDateSeparator: {
674
688
  container: {},
@@ -983,6 +997,10 @@ export const defaultTheme: Theme = {
983
997
  },
984
998
  },
985
999
  targetedMessageUnderlay: {},
1000
+ videoThumbnail: {
1001
+ container: {},
1002
+ roundedView: {},
1003
+ },
986
1004
  },
987
1005
  overlay: {
988
1006
  container: {},
@@ -0,0 +1,14 @@
1
+ import React from 'react';
2
+ import { Rect } from 'react-native-svg';
3
+
4
+ import { IconProps, RootSvg } from './utils/base';
5
+
6
+ export const Pause: React.FC<IconProps> = (props) => {
7
+ const { height, width } = props;
8
+ return (
9
+ <RootSvg height={height} viewBox={`0 0 ${height} ${width}`} width={width} {...props}>
10
+ <Rect fill={'black'} height={14} width={4} x={6} y={5} />
11
+ <Rect fill={'black'} height={14} width={4} x={14} y={5} />
12
+ </RootSvg>
13
+ );
14
+ };
@@ -0,0 +1,17 @@
1
+ import React from 'react';
2
+
3
+ import { IconProps, RootPath, RootSvg } from './utils/base';
4
+
5
+ export const Play: React.FC<IconProps> = (props) => (
6
+ <RootSvg
7
+ height={props.height}
8
+ viewBox={`0 0 ${props.height} ${props.width}`}
9
+ width={props.width}
10
+ {...props}
11
+ >
12
+ <RootPath
13
+ d='M 9.5547 5.03647 C 8.89014 4.59343 8 5.06982 8 5.86852 V 18.1315 C 8 18.9302 8.89015 19.4066 9.5547 18.9635 L 18.7519 12.8321 C 19.3457 12.4362 19.3457 11.5638 18.7519 11.1679 L 9.5547 5.03647 Z'
14
+ {...props}
15
+ />
16
+ </RootSvg>
17
+ );
@@ -45,10 +45,12 @@ export * from './MessageIcon';
45
45
  export * from './Mute';
46
46
  export * from './Notification';
47
47
  export * from './ODT';
48
+ export * from './Pause';
48
49
  export * from './PDF';
49
50
  export * from './Picture';
50
51
  export * from './Pin';
51
52
  export * from './PinHeader';
53
+ export * from './Play';
52
54
  export * from './PPT';
53
55
  export * from './PPTX';
54
56
  export * from './RAR';
@@ -14,3 +14,101 @@ export const queryMembersApi = (members = []) => {
14
14
 
15
15
  return mockedApiResponse(result, 'get');
16
16
  };
17
+
18
+ export const ONE_CHANNEL_MEMBER_MOCK = {
19
+ okey: {
20
+ banned: false,
21
+ channel_role: 'channel_member',
22
+ created_at: '2021-01-27T11:54:34.173125Z',
23
+ role: 'member',
24
+ shadow_banned: false,
25
+ updated_at: '2021-02-12T12:12:35.862282Z',
26
+ user: {
27
+ id: 'okechukwu nwagba martin',
28
+ name: 'okechukwu nwagba martin',
29
+ },
30
+ user_id: 'okechukwu nwagba martin',
31
+ },
32
+ };
33
+
34
+ export const GROUP_CHANNEL_MEMBERS_MOCK = {
35
+ ben: {
36
+ banned: false,
37
+ channel_role: 'channel_member',
38
+ created_at: '2021-01-27T11:54:34.173125Z',
39
+ role: 'member',
40
+ shadow_banned: false,
41
+ updated_at: '2021-02-12T12:12:35.862282Z',
42
+ user: {
43
+ id: 'ben',
44
+ name: 'ben',
45
+ },
46
+ user_id: 'ben',
47
+ },
48
+ nick: {
49
+ banned: false,
50
+ channel_role: 'channel_member',
51
+ created_at: '2021-01-27T11:54:34.173125Z',
52
+ role: 'member',
53
+ shadow_banned: false,
54
+ updated_at: '2021-02-12T12:12:35.862282Z',
55
+ user: {
56
+ id: 'nick',
57
+ name: 'nick',
58
+ },
59
+ user_id: 'nick',
60
+ },
61
+ okey: {
62
+ banned: false,
63
+ channel_role: 'channel_member',
64
+ created_at: '2021-01-27T11:54:34.173125Z',
65
+ role: 'member',
66
+ shadow_banned: false,
67
+ updated_at: '2021-02-12T12:12:35.862282Z',
68
+ user: {
69
+ id: 'okechukwu nwagba',
70
+ name: 'okechukwu nwagba',
71
+ },
72
+ user_id: 'okechukwu nwagba',
73
+ },
74
+ qatest1: {
75
+ banned: false,
76
+ channel_role: 'channel_member',
77
+ created_at: '2021-01-28T09:08:43.274508Z',
78
+ role: 'member',
79
+ shadow_banned: false,
80
+ updated_at: '2021-02-12T12:12:35.862282Z',
81
+ user: {
82
+ id: 'qatest1',
83
+ name: 'qatest1',
84
+ },
85
+ user_id: 'qatest1',
86
+ },
87
+
88
+ thierry: {
89
+ banned: false,
90
+ channel_role: 'channel_member',
91
+ created_at: '2021-01-27T11:54:34.173125Z',
92
+ role: 'member',
93
+ shadow_banned: false,
94
+ updated_at: '2021-02-12T12:12:35.862282Z',
95
+ user: {
96
+ id: 'thierry',
97
+ name: 'thierry',
98
+ },
99
+ user_id: 'thierry',
100
+ },
101
+ };
102
+
103
+ export const ONE_MEMBER_WITH_EMPTY_USER_MOCK = {
104
+ okey: {
105
+ banned: false,
106
+ channel_role: 'channel_member',
107
+ created_at: '2021-01-27T11:54:34.173125Z',
108
+ role: 'member',
109
+ shadow_banned: false,
110
+ updated_at: '2021-02-12T12:12:35.862282Z',
111
+ user: {},
112
+ user_id: 'okechukwu nwagba martin',
113
+ },
114
+ };
package/src/native.ts CHANGED
@@ -1,4 +1,5 @@
1
- import { FlatList as DefaultFlatList } from 'react-native';
1
+ import type React from 'react';
2
+ import { FlatList as DefaultFlatList, StyleProp, ViewStyle } from 'react-native';
2
3
 
3
4
  import type { NetInfoSubscription } from '@react-native-community/netinfo';
4
5
 
@@ -94,6 +95,58 @@ export let triggerHaptic: TriggerHaptic = fail;
94
95
 
95
96
  export let SDK: string;
96
97
 
98
+ export type PlaybackStatus = {
99
+ didJustFinish: boolean;
100
+ durationMillis: number;
101
+ error: string;
102
+ isBuffering: boolean;
103
+ isLoaded: boolean;
104
+ isLooping: boolean;
105
+ isPlaying: boolean;
106
+ positionMillis: number;
107
+ };
108
+
109
+ export type VideoProgressData = {
110
+ currentTime?: number;
111
+ playableDuration?: number;
112
+ seekableDuration?: number;
113
+ };
114
+
115
+ export type VideoPayloadData = {
116
+ audioTracks?: { index: number; language: string; title: string; type: string }[];
117
+ currentPosition?: number;
118
+ duration?: number;
119
+ naturalSize?: { height: number; orientation: 'portrait' | 'landscape'; width: number };
120
+ textTracks?: { index: number; language: string; title: string; type: string }[];
121
+ videoTracks?: {
122
+ bitrate: number;
123
+ codecs: string;
124
+ height: number;
125
+ trackId: number;
126
+ width: number;
127
+ }[];
128
+ };
129
+
130
+ export type VideoType = {
131
+ paused: boolean;
132
+ uri: string;
133
+ videoRef: React.RefObject<VideoType>;
134
+ onBuffer?: (props: { isBuffering: boolean }) => void;
135
+ onEnd?: () => void;
136
+ onLoad?: (payload: VideoPayloadData) => void;
137
+ onLoadStart?: () => void;
138
+ onPlaybackStatusUpdate?: (playbackStatus: PlaybackStatus) => void;
139
+ onProgress?: (data: VideoProgressData) => void;
140
+ onReadyForDisplay?: () => void;
141
+ replayAsync?: () => void;
142
+ resizeMode?: string;
143
+ seek?: (progress: number) => void;
144
+ setPositionAsync?: (position: number) => void;
145
+ style?: StyleProp<ViewStyle>;
146
+ };
147
+
148
+ export let Video: React.ComponentType<VideoType> = fail;
149
+
97
150
  type Handlers = {
98
151
  compressImage?: CompressImage;
99
152
  deleteFile?: DeleteFile;
@@ -107,6 +160,7 @@ type Handlers = {
107
160
  shareImage?: ShareImage;
108
161
  takePhoto?: TakePhoto;
109
162
  triggerHaptic?: TriggerHaptic;
163
+ Video?: React.ComponentType<VideoType>;
110
164
  };
111
165
 
112
166
  export const registerNativeHandlers = (handlers: Handlers) => {
@@ -160,4 +214,8 @@ export const registerNativeHandlers = (handlers: Handlers) => {
160
214
  if (handlers.triggerHaptic) {
161
215
  triggerHaptic = handlers.triggerHaptic;
162
216
  }
217
+
218
+ if (handlers.Video) {
219
+ Video = handlers.Video;
220
+ }
163
221
  };
@@ -6,5 +6,5 @@ import type { Attachment } from 'stream-chat';
6
6
  * @returns {string}
7
7
  */
8
8
  export function getUrlOfImageAttachment(image: Attachment) {
9
- return image.image_url || image.thumb_url;
9
+ return image.image_url || image.thumb_url || image.asset_url;
10
10
  }
package/src/version.json CHANGED
@@ -1,3 +1,3 @@
1
1
  {
2
- "version": "4.6.1"
2
+ "version": "4.7.0-beta.3"
3
3
  }