stream-chat-react-native-core 4.12.0-beta.3 → 4.12.0

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 (71) hide show
  1. package/lib/commonjs/components/Attachment/AudioAttachment.js +27 -56
  2. package/lib/commonjs/components/Attachment/AudioAttachment.js.map +1 -1
  3. package/lib/commonjs/components/Attachment/FileAttachmentGroup.js +31 -14
  4. package/lib/commonjs/components/Attachment/FileAttachmentGroup.js.map +1 -1
  5. package/lib/commonjs/components/Attachment/Gallery.js +22 -18
  6. package/lib/commonjs/components/Attachment/Gallery.js.map +1 -1
  7. package/lib/commonjs/components/Channel/Channel.js +14 -14
  8. package/lib/commonjs/components/Channel/Channel.js.map +1 -1
  9. package/lib/commonjs/components/Channel/hooks/useCreateInputMessageInputContext.js +0 -2
  10. package/lib/commonjs/components/Channel/hooks/useCreateInputMessageInputContext.js.map +1 -1
  11. package/lib/commonjs/components/Channel/hooks/useCreateMessagesContext.js +2 -0
  12. package/lib/commonjs/components/Channel/hooks/useCreateMessagesContext.js.map +1 -1
  13. package/lib/commonjs/components/MessageInput/FileUploadPreview.js +31 -16
  14. package/lib/commonjs/components/MessageInput/FileUploadPreview.js.map +1 -1
  15. package/lib/commonjs/components/MessageOverlay/MessageOverlay.js +14 -13
  16. package/lib/commonjs/components/MessageOverlay/MessageOverlay.js.map +1 -1
  17. package/lib/commonjs/contexts/messageInputContext/MessageInputContext.js +2 -2
  18. package/lib/commonjs/contexts/messageInputContext/MessageInputContext.js.map +1 -1
  19. package/lib/commonjs/contexts/messageInputContext/hooks/useCreateMessageInputContext.js +0 -2
  20. package/lib/commonjs/contexts/messageInputContext/hooks/useCreateMessageInputContext.js.map +1 -1
  21. package/lib/commonjs/contexts/messagesContext/MessagesContext.js +2 -2
  22. package/lib/commonjs/contexts/messagesContext/MessagesContext.js.map +1 -1
  23. package/lib/commonjs/version.json +1 -1
  24. package/lib/module/components/Attachment/AudioAttachment.js +27 -56
  25. package/lib/module/components/Attachment/AudioAttachment.js.map +1 -1
  26. package/lib/module/components/Attachment/FileAttachmentGroup.js +31 -14
  27. package/lib/module/components/Attachment/FileAttachmentGroup.js.map +1 -1
  28. package/lib/module/components/Attachment/Gallery.js +22 -18
  29. package/lib/module/components/Attachment/Gallery.js.map +1 -1
  30. package/lib/module/components/Channel/Channel.js +14 -14
  31. package/lib/module/components/Channel/Channel.js.map +1 -1
  32. package/lib/module/components/Channel/hooks/useCreateInputMessageInputContext.js +0 -2
  33. package/lib/module/components/Channel/hooks/useCreateInputMessageInputContext.js.map +1 -1
  34. package/lib/module/components/Channel/hooks/useCreateMessagesContext.js +2 -0
  35. package/lib/module/components/Channel/hooks/useCreateMessagesContext.js.map +1 -1
  36. package/lib/module/components/MessageInput/FileUploadPreview.js +31 -16
  37. package/lib/module/components/MessageInput/FileUploadPreview.js.map +1 -1
  38. package/lib/module/components/MessageOverlay/MessageOverlay.js +14 -13
  39. package/lib/module/components/MessageOverlay/MessageOverlay.js.map +1 -1
  40. package/lib/module/contexts/messageInputContext/MessageInputContext.js +2 -2
  41. package/lib/module/contexts/messageInputContext/MessageInputContext.js.map +1 -1
  42. package/lib/module/contexts/messageInputContext/hooks/useCreateMessageInputContext.js +0 -2
  43. package/lib/module/contexts/messageInputContext/hooks/useCreateMessageInputContext.js.map +1 -1
  44. package/lib/module/contexts/messagesContext/MessagesContext.js +2 -2
  45. package/lib/module/contexts/messagesContext/MessagesContext.js.map +1 -1
  46. package/lib/module/version.json +1 -1
  47. package/lib/typescript/components/Attachment/AudioAttachment.d.ts +4 -7
  48. package/lib/typescript/components/Attachment/FileAttachmentGroup.d.ts +1 -2
  49. package/lib/typescript/components/Channel/Channel.d.ts +1 -1
  50. package/lib/typescript/components/Channel/hooks/useCreateInputMessageInputContext.d.ts +1 -1
  51. package/lib/typescript/components/Channel/hooks/useCreateMessagesContext.d.ts +1 -1
  52. package/lib/typescript/components/MessageInput/FileUploadPreview.d.ts +1 -1
  53. package/lib/typescript/contexts/messageContext/MessageContext.d.ts +1 -1
  54. package/lib/typescript/contexts/messageInputContext/MessageInputContext.d.ts +1 -4
  55. package/lib/typescript/contexts/messageInputContext/hooks/useCreateMessageInputContext.d.ts +1 -1
  56. package/lib/typescript/contexts/messagesContext/MessagesContext.d.ts +3 -0
  57. package/package.json +1 -1
  58. package/src/components/Attachment/AudioAttachment.tsx +72 -116
  59. package/src/components/Attachment/FileAttachmentGroup.tsx +32 -11
  60. package/src/components/Attachment/Gallery.tsx +7 -1
  61. package/src/components/Channel/Channel.tsx +2 -1
  62. package/src/components/Channel/hooks/useCreateInputMessageInputContext.ts +0 -2
  63. package/src/components/Channel/hooks/useCreateMessagesContext.ts +2 -0
  64. package/src/components/MessageInput/FileUploadPreview.tsx +29 -12
  65. package/src/components/MessageInput/__tests__/AudioAttachmentUploadPreviewExpo.test.tsx +13 -3
  66. package/src/components/MessageInput/__tests__/AudioAttachmentUploadPreviewNative.test.tsx +13 -3
  67. package/src/components/MessageOverlay/MessageOverlay.tsx +1 -0
  68. package/src/contexts/messageInputContext/MessageInputContext.tsx +0 -4
  69. package/src/contexts/messageInputContext/hooks/useCreateMessageInputContext.ts +0 -2
  70. package/src/contexts/messagesContext/MessagesContext.tsx +3 -0
  71. package/src/version.json +1 -1
@@ -4,12 +4,7 @@ import { I18nManager, StyleSheet, Text, TouchableOpacity, View } from 'react-nat
4
4
  import dayjs from 'dayjs';
5
5
  import duration from 'dayjs/plugin/duration';
6
6
 
7
- import {
8
- FileUpload,
9
- MessageInputContextValue,
10
- useMessageInputContext,
11
- useTheme,
12
- } from '../../contexts';
7
+ import { FileUpload, useTheme } from '../../contexts';
13
8
  import { Pause, Play } from '../../icons';
14
9
  import {
15
10
  PlaybackStatus,
@@ -18,7 +13,6 @@ import {
18
13
  VideoPayloadData,
19
14
  VideoProgressData,
20
15
  } from '../../native';
21
- import type { DefaultStreamChatGenerics } from '../../types/types';
22
16
  import { ProgressControl } from '../ProgressControl/ProgressControl';
23
17
 
24
18
  dayjs.extend(duration);
@@ -76,13 +70,7 @@ const styles = StyleSheet.create({
76
70
  },
77
71
  });
78
72
 
79
- export type AudioAttachmentPropsWithContext<
80
- StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
81
- > = Pick<
82
- MessageInputContextValue<StreamChatGenerics>,
83
- 'fileUploads' | 'removeFile' | 'uploadFile'
84
- > & {
85
- index: number;
73
+ export type AudioAttachmentPropsWithContext = {
86
74
  item: Omit<FileUpload, 'state'>;
87
75
  onLoad: (index: string, duration: number) => void;
88
76
  onPlayPause: (index: string, pausedStatus?: boolean) => void;
@@ -90,13 +78,9 @@ export type AudioAttachmentPropsWithContext<
90
78
  testID?: string;
91
79
  };
92
80
 
93
- const AudioAttachmentWithContext = <
94
- StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
95
- >(
96
- props: AudioAttachmentPropsWithContext<StreamChatGenerics>,
97
- ) => {
81
+ const AudioAttachmentWithContext = (props: AudioAttachmentPropsWithContext) => {
98
82
  const soundRef = React.useRef<SoundReturnType | null>(null);
99
- const { fileUploads, index, item, onLoad, onPlayPause, onProgress } = props;
83
+ const { item, onLoad, onPlayPause, onProgress } = props;
100
84
 
101
85
  const handleLoad = (payload: VideoPayloadData) => {
102
86
  onLoad(item.id, payload.duration);
@@ -212,11 +196,10 @@ const AudioAttachmentWithContext = <
212
196
 
213
197
  const {
214
198
  theme: {
215
- colors: { accent_blue, black, grey_dark, grey_whisper, static_black, static_white, white },
199
+ colors: { accent_blue, black, grey_dark, static_black, static_white },
216
200
  messageInput: {
217
201
  fileUploadPreview: {
218
202
  audioAttachment: { progressControlView, progressDurationText, roundedView },
219
- fileContainer,
220
203
  fileContentContainer,
221
204
  filenameText,
222
205
  fileTextContainer,
@@ -236,92 +219,74 @@ const AudioAttachmentWithContext = <
236
219
  const lastIndexOfDot = item.file.name.lastIndexOf('.');
237
220
 
238
221
  return (
239
- <View
240
- style={[
241
- styles.fileContainer,
242
- index === fileUploads.length - 1
243
- ? {
244
- marginBottom: 0,
245
- }
246
- : {},
247
- {
248
- backgroundColor: white,
249
- borderColor: grey_whisper,
250
- width: -16,
251
- },
252
- fileContainer,
253
- ]}
254
- testID='audio-attachment-upload-preview'
255
- >
256
- <View style={[styles.fileContentContainer, fileContentContainer]}>
257
- <TouchableOpacity
258
- accessibilityLabel='Play Pause Button'
259
- onPress={() => handlePlayPause()}
222
+ <View style={[styles.fileContentContainer, fileContentContainer]}>
223
+ <TouchableOpacity
224
+ accessibilityLabel='Play Pause Button'
225
+ onPress={() => handlePlayPause()}
226
+ style={[
227
+ styles.roundedView,
228
+ roundedView,
229
+ { backgroundColor: static_white, shadowColor: black },
230
+ ]}
231
+ >
232
+ {item.paused ? (
233
+ <Play height={24} pathFill={static_black} width={24} />
234
+ ) : (
235
+ <Pause height={24} pathFill={static_black} width={24} />
236
+ )}
237
+ </TouchableOpacity>
238
+ <View style={[styles.fileTextContainer, fileTextContainer]}>
239
+ <Text
240
+ accessibilityLabel='File Name'
241
+ numberOfLines={1}
260
242
  style={[
261
- styles.roundedView,
262
- roundedView,
263
- { backgroundColor: static_white, shadowColor: black },
243
+ styles.filenameText,
244
+ {
245
+ color: black,
246
+ width:
247
+ 16 - // 16 = horizontal padding
248
+ 40 - // 40 = file icon size
249
+ 24 - // 24 = close icon size
250
+ 24, // 24 = internal padding
251
+ },
252
+ I18nManager.isRTL ? { writingDirection: 'rtl' } : { writingDirection: 'ltr' },
253
+ filenameText,
264
254
  ]}
265
255
  >
266
- {item.paused ? (
267
- <Play height={24} pathFill={static_black} width={24} />
268
- ) : (
269
- <Pause height={24} pathFill={static_black} width={24} />
256
+ {item.file.name.slice(0, 12) + '...' + item.file.name.slice(lastIndexOfDot)}
257
+ </Text>
258
+ <View
259
+ style={{
260
+ alignItems: 'center',
261
+ display: 'flex',
262
+ flexDirection: 'row',
263
+ }}
264
+ >
265
+ {/* <ExpoSoundPlayer filePaused={!!item.paused} soundRef={soundRef} /> */}
266
+ {Sound.Player && (
267
+ <Sound.Player
268
+ onEnd={handleEnd}
269
+ onLoad={handleLoad}
270
+ onProgress={handleProgress}
271
+ paused={item.paused as boolean}
272
+ soundRef={soundRef}
273
+ testID='sound-player'
274
+ uri={item.file.uri}
275
+ />
270
276
  )}
271
- </TouchableOpacity>
272
- <View style={[styles.fileTextContainer, fileTextContainer]}>
273
- <Text
274
- accessibilityLabel='File Name'
275
- numberOfLines={1}
276
- style={[
277
- styles.filenameText,
278
- {
279
- color: black,
280
- width:
281
- 16 - // 16 = horizontal padding
282
- 40 - // 40 = file icon size
283
- 24 - // 24 = close icon size
284
- 24, // 24 = internal padding
285
- },
286
- I18nManager.isRTL ? { writingDirection: 'rtl' } : { writingDirection: 'ltr' },
287
- filenameText,
288
- ]}
289
- >
290
- {item.file.name.slice(0, 12) + '...' + item.file.name.slice(lastIndexOfDot)}
277
+ <Text style={[styles.progressDurationText, { color: grey_dark }, progressDurationText]}>
278
+ {progressDuration}
291
279
  </Text>
292
- <View
293
- style={{
294
- alignItems: 'center',
295
- display: 'flex',
296
- flexDirection: 'row',
297
- }}
298
- >
299
- {/* <ExpoSoundPlayer filePaused={!!item.paused} soundRef={soundRef} /> */}
300
- {Sound.Player && (
301
- <Sound.Player
302
- onEnd={handleEnd}
303
- onLoad={handleLoad}
304
- onProgress={handleProgress}
305
- paused={item.paused as boolean}
306
- soundRef={soundRef}
307
- testID='sound-player'
308
- uri={item.file.uri}
309
- />
310
- )}
311
- <Text style={[styles.progressDurationText, { color: grey_dark }, progressDurationText]}>
312
- {progressDuration}
313
- </Text>
314
- <View style={[styles.progressControlView, progressControlView]}>
315
- <ProgressControl
316
- duration={item.duration as number}
317
- filledColor={accent_blue}
318
- onPlayPause={handlePlayPause}
319
- onProgressDrag={handleProgressDrag}
320
- progress={item.progress as number}
321
- testID='progress-control'
322
- width={120}
323
- />
324
- </View>
280
+ <View style={[styles.progressControlView, progressControlView]}>
281
+ <ProgressControl
282
+ duration={item.duration as number}
283
+ filledColor={accent_blue}
284
+ onPlayPause={handlePlayPause}
285
+ onProgressDrag={handleProgressDrag}
286
+ progress={item.progress as number}
287
+ testID='progress-control'
288
+ width={120}
289
+ />
325
290
  </View>
326
291
  </View>
327
292
  </View>
@@ -329,10 +294,7 @@ const AudioAttachmentWithContext = <
329
294
  );
330
295
  };
331
296
 
332
- export type AudioAttachmentProps<
333
- StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
334
- > = Partial<AudioAttachmentPropsWithContext<StreamChatGenerics>> & {
335
- index: number;
297
+ export type AudioAttachmentProps = Partial<AudioAttachmentPropsWithContext> & {
336
298
  item: Omit<FileUpload, 'state'>;
337
299
  onLoad: (index: string, duration: number) => void;
338
300
  onPlayPause: (index: string, pausedStatus?: boolean) => void;
@@ -344,14 +306,8 @@ export type AudioAttachmentProps<
344
306
  * AudioAttachment
345
307
  * UI Component to preview the audio files
346
308
  */
347
- export const AudioAttachment = <
348
- StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
349
- >(
350
- props: AudioAttachmentProps<StreamChatGenerics>,
351
- ) => {
352
- const { fileUploads, removeFile, uploadFile } = useMessageInputContext<StreamChatGenerics>();
353
-
354
- return <AudioAttachmentWithContext {...{ fileUploads, removeFile, uploadFile }} {...props} />;
355
- };
309
+ export const AudioAttachment = (props: AudioAttachmentProps) => (
310
+ <AudioAttachmentWithContext {...props} />
311
+ );
356
312
 
357
313
  AudioAttachment.displayName = 'AudioAttachment{messageInput{autoAttachment}}';
@@ -9,10 +9,7 @@ import {
9
9
  MessageContextValue,
10
10
  useMessageContext,
11
11
  } from '../../contexts/messageContext/MessageContext';
12
- import {
13
- MessageInputContextValue,
14
- useMessageInputContext,
15
- } from '../../contexts/messageInputContext/MessageInputContext';
12
+
16
13
  import {
17
14
  MessagesContextValue,
18
15
  useMessagesContext,
@@ -22,17 +19,27 @@ import { isAudioPackageAvailable } from '../../native';
22
19
 
23
20
  import type { DefaultStreamChatGenerics } from '../../types/types';
24
21
 
22
+ const FILE_PREVIEW_HEIGHT = 60;
23
+
25
24
  const styles = StyleSheet.create({
26
25
  container: {
27
26
  padding: 4,
28
27
  },
28
+ fileContainer: {
29
+ borderRadius: 12,
30
+ borderWidth: 1,
31
+ flexDirection: 'row',
32
+ height: FILE_PREVIEW_HEIGHT,
33
+ justifyContent: 'space-between',
34
+ paddingLeft: 8,
35
+ paddingRight: 8,
36
+ },
29
37
  });
30
38
 
31
39
  export type FileAttachmentGroupPropsWithContext<
32
40
  StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
33
41
  > = Pick<MessageContextValue<StreamChatGenerics>, 'files'> &
34
- Pick<MessageInputContextValue<StreamChatGenerics>, 'AudioAttachment'> &
35
- Pick<MessagesContextValue<StreamChatGenerics>, 'Attachment'> & {
42
+ Pick<MessagesContextValue<StreamChatGenerics>, 'Attachment' | 'AudioAttachment'> & {
36
43
  /**
37
44
  * The unique id for the message with file attachments
38
45
  */
@@ -113,6 +120,7 @@ const FileAttachmentGroupWithContext = <
113
120
 
114
121
  const {
115
122
  theme: {
123
+ colors: { grey_whisper, white },
116
124
  messageSimple: {
117
125
  fileAttachmentGroup: { container },
118
126
  },
@@ -130,9 +138,23 @@ const FileAttachmentGroupWithContext = <
130
138
  ]}
131
139
  >
132
140
  {file.type === 'audio' && isAudioPackageAvailable() ? (
133
- <View accessibilityLabel='audio-attachment-preview'>
141
+ <View
142
+ accessibilityLabel='audio-attachment-preview'
143
+ style={[
144
+ styles.fileContainer,
145
+ index === filesToDisplay.length - 1
146
+ ? {
147
+ marginBottom: 0,
148
+ }
149
+ : {},
150
+ {
151
+ backgroundColor: white,
152
+ borderColor: grey_whisper,
153
+ width: -16,
154
+ },
155
+ ]}
156
+ >
134
157
  <AudioAttachment
135
- index={index}
136
158
  item={{
137
159
  duration: file.duration,
138
160
  file: { name: file.title as string, uri: file.asset_url },
@@ -184,9 +206,8 @@ export const FileAttachmentGroup = <
184
206
 
185
207
  const { files: contextFiles } = useMessageContext<StreamChatGenerics>();
186
208
 
187
- const { Attachment = AttachmentDefault } = useMessagesContext<StreamChatGenerics>();
188
-
189
- const { AudioAttachment } = useMessageInputContext<StreamChatGenerics>();
209
+ const { Attachment = AttachmentDefault, AudioAttachment } =
210
+ useMessagesContext<StreamChatGenerics>();
190
211
 
191
212
  const files = propFiles || contextFiles;
192
213
 
@@ -62,6 +62,12 @@ const styles = StyleSheet.create({
62
62
  left: 4,
63
63
  position: 'absolute',
64
64
  },
65
+ imageLoadingIndicatorContainer: {
66
+ height: '100%',
67
+ justifyContent: 'center',
68
+ position: 'absolute',
69
+ width: '100%',
70
+ },
65
71
  imageLoadingIndicatorStyle: {
66
72
  alignItems: 'center',
67
73
  justifyContent: 'center',
@@ -490,7 +496,7 @@ const GalleryImageThumbnail = <
490
496
  uri={thumbnail.url}
491
497
  />
492
498
  {isLoadingImage && (
493
- <View style={{ position: 'absolute' }}>
499
+ <View style={[styles.imageLoadingIndicatorContainer]}>
494
500
  <ImageLoadingIndicator style={styles.imageLoadingIndicatorStyle} />
495
501
  </View>
496
502
  )}
@@ -229,6 +229,7 @@ export type ChannelPropsWithContext<
229
229
  | 'additionalTouchableProps'
230
230
  | 'Attachment'
231
231
  | 'AttachmentActions'
232
+ | 'AudioAttachment'
232
233
  | 'Card'
233
234
  | 'CardCover'
234
235
  | 'CardFooter'
@@ -1620,7 +1621,6 @@ const ChannelWithContext = <
1620
1621
  const inputMessageInputContext = useCreateInputMessageInputContext<StreamChatGenerics>({
1621
1622
  additionalTextInputProps,
1622
1623
  AttachButton,
1623
- AudioAttachment,
1624
1624
  autoCompleteSuggestionsLimit,
1625
1625
  autoCompleteTriggerSettings,
1626
1626
  channelId,
@@ -1679,6 +1679,7 @@ const ChannelWithContext = <
1679
1679
  additionalTouchableProps,
1680
1680
  Attachment,
1681
1681
  AttachmentActions,
1682
+ AudioAttachment,
1682
1683
  Card,
1683
1684
  CardCover,
1684
1685
  CardFooter,
@@ -8,7 +8,6 @@ export const useCreateInputMessageInputContext = <
8
8
  >({
9
9
  additionalTextInputProps,
10
10
  AttachButton,
11
- AudioAttachment,
12
11
  autoCompleteSuggestionsLimit,
13
12
  autoCompleteTriggerSettings,
14
13
  channelId,
@@ -65,7 +64,6 @@ export const useCreateInputMessageInputContext = <
65
64
  () => ({
66
65
  additionalTextInputProps,
67
66
  AttachButton,
68
- AudioAttachment,
69
67
  autoCompleteSuggestionsLimit,
70
68
  autoCompleteTriggerSettings,
71
69
  clearEditingState,
@@ -9,6 +9,7 @@ export const useCreateMessagesContext = <
9
9
  additionalTouchableProps,
10
10
  Attachment,
11
11
  AttachmentActions,
12
+ AudioAttachment,
12
13
  Card,
13
14
  CardCover,
14
15
  CardFooter,
@@ -99,6 +100,7 @@ export const useCreateMessagesContext = <
99
100
  additionalTouchableProps,
100
101
  Attachment,
101
102
  AttachmentActions,
103
+ AudioAttachment,
102
104
  Card,
103
105
  CardCover,
104
106
  CardFooter,
@@ -123,9 +123,9 @@ type FileUploadPreviewPropsWithContext<
123
123
  StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
124
124
  > = Pick<
125
125
  MessageInputContextValue<StreamChatGenerics>,
126
- 'fileUploads' | 'removeFile' | 'uploadFile' | 'setFileUploads' | 'AudioAttachment'
126
+ 'fileUploads' | 'removeFile' | 'uploadFile' | 'setFileUploads'
127
127
  > &
128
- Pick<MessagesContextValue<StreamChatGenerics>, 'FileAttachmentIcon'>;
128
+ Pick<MessagesContextValue<StreamChatGenerics>, 'AudioAttachment' | 'FileAttachmentIcon'>;
129
129
 
130
130
  const FileUploadPreviewWithContext = <
131
131
  StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
@@ -194,7 +194,7 @@ const FileUploadPreviewWithContext = <
194
194
 
195
195
  const {
196
196
  theme: {
197
- colors: { black, grey_dark, grey_gainsboro, grey_whisper },
197
+ colors: { black, grey_dark, grey_gainsboro, grey_whisper, white },
198
198
  messageInput: {
199
199
  fileUploadPreview: {
200
200
  audioAttachmentFileContainer,
@@ -230,14 +230,31 @@ const FileUploadPreviewWithContext = <
230
230
  audioAttachmentFileContainer,
231
231
  ]}
232
232
  >
233
- <AudioAttachment
234
- index={index}
235
- item={item}
236
- onLoad={onLoad}
237
- onPlayPause={onPlayPause}
238
- onProgress={onProgress}
233
+ <View
234
+ style={[
235
+ styles.fileContainer,
236
+ index === fileUploads.length - 1
237
+ ? {
238
+ marginBottom: 0,
239
+ }
240
+ : {},
241
+ {
242
+ backgroundColor: white,
243
+ borderColor: grey_whisper,
244
+ width: -16,
245
+ },
246
+ fileContainer,
247
+ ]}
239
248
  testID='audio-attachment-upload-preview'
240
- />
249
+ >
250
+ <AudioAttachment
251
+ item={item}
252
+ onLoad={onLoad}
253
+ onPlayPause={onPlayPause}
254
+ onProgress={onProgress}
255
+ testID='audio-attachment-upload-preview'
256
+ />
257
+ </View>
241
258
  </View>
242
259
  ) : (
243
260
  <View
@@ -371,9 +388,9 @@ export const FileUploadPreview = <
371
388
  >(
372
389
  props: FileUploadPreviewProps<StreamChatGenerics>,
373
390
  ) => {
374
- const { AudioAttachment, fileUploads, removeFile, setFileUploads, uploadFile } =
391
+ const { fileUploads, removeFile, setFileUploads, uploadFile } =
375
392
  useMessageInputContext<StreamChatGenerics>();
376
- const { FileAttachmentIcon } = useMessagesContext<StreamChatGenerics>();
393
+ const { AudioAttachment, FileAttachmentIcon } = useMessagesContext<StreamChatGenerics>();
377
394
 
378
395
  return (
379
396
  <MemoizedFileUploadPreview
@@ -4,7 +4,11 @@ import { act } from 'react-test-renderer';
4
4
 
5
5
  import { fireEvent, render } from '@testing-library/react-native';
6
6
 
7
- import type { FileUpload } from '../../../contexts/messageInputContext/MessageInputContext';
7
+ import {
8
+ FileUpload,
9
+ MessageInputContext,
10
+ MessageInputContextValue,
11
+ } from '../../../contexts/messageInputContext/MessageInputContext';
8
12
  import { ThemeProvider } from '../../../contexts/themeContext/ThemeContext';
9
13
  import { defaultTheme } from '../../../contexts/themeContext/utils/theme';
10
14
 
@@ -26,9 +30,15 @@ jest.mock('react-native/Libraries/ReactNative/I18nManager', () => ({
26
30
  isRTL: true,
27
31
  }));
28
32
 
29
- const getComponent = (props: Partial<AudioAttachmentProps>) => (
33
+ const getComponent = (
34
+ props: Partial<AudioAttachmentProps & Pick<MessageInputContextValue, 'fileUploads'>>,
35
+ ) => (
30
36
  <ThemeProvider theme={defaultTheme}>
31
- <AudioAttachment {...(props as unknown as AudioAttachmentProps)} />,
37
+ <MessageInputContext.Provider
38
+ value={{ fileUploads: props.fileUploads } as unknown as MessageInputContextValue}
39
+ >
40
+ <AudioAttachment {...(props as unknown as AudioAttachmentProps)} />,
41
+ </MessageInputContext.Provider>
32
42
  </ThemeProvider>
33
43
  );
34
44
 
@@ -4,7 +4,11 @@ import { act } from 'react-test-renderer';
4
4
 
5
5
  import { fireEvent, render } from '@testing-library/react-native';
6
6
 
7
- import type { FileUpload } from '../../../contexts/messageInputContext/MessageInputContext';
7
+ import {
8
+ FileUpload,
9
+ MessageInputContext,
10
+ MessageInputContextValue,
11
+ } from '../../../contexts/messageInputContext/MessageInputContext';
8
12
  import { ThemeProvider } from '../../../contexts/themeContext/ThemeContext';
9
13
  import { defaultTheme } from '../../../contexts/themeContext/utils/theme';
10
14
 
@@ -25,9 +29,15 @@ jest.mock('../../../native.ts', () => {
25
29
  };
26
30
  });
27
31
 
28
- const getComponent = (props: Partial<AudioAttachmentProps>) => (
32
+ const getComponent = (
33
+ props: Partial<AudioAttachmentProps & Pick<MessageInputContextValue, 'fileUploads'>>,
34
+ ) => (
29
35
  <ThemeProvider theme={defaultTheme}>
30
- <AudioAttachment {...(props as unknown as AudioAttachmentProps)} />,
36
+ <MessageInputContext.Provider
37
+ value={{ fileUploads: props.fileUploads } as unknown as MessageInputContextValue}
38
+ >
39
+ <AudioAttachment {...(props as unknown as AudioAttachmentProps)} />,
40
+ </MessageInputContext.Provider>
31
41
  </ThemeProvider>
32
42
  );
33
43
 
@@ -327,6 +327,7 @@ const MessageOverlayWithContext = <
327
327
  <Animated.View style={[styles.flex, panStyle]}>
328
328
  {message && (
329
329
  <View
330
+ pointerEvents='none'
330
331
  style={[
331
332
  styles.center,
332
333
  styles.overlayPadding,
@@ -21,7 +21,6 @@ import {
21
21
  import { useCreateMessageInputContext } from './hooks/useCreateMessageInputContext';
22
22
  import { isEditingBoolean, useMessageDetailsForState } from './hooks/useMessageDetailsForState';
23
23
 
24
- import type { AudioAttachmentProps } from '../../components/Attachment/AudioAttachment';
25
24
  import type { AttachButtonProps } from '../../components/MessageInput/AttachButton';
26
25
  import type { CommandsButtonProps } from '../../components/MessageInput/CommandsButton';
27
26
  import type { InputEditingStateHeaderProps } from '../../components/MessageInput/components/InputEditingStateHeader';
@@ -225,9 +224,6 @@ export type InputMessageInputContextValue<
225
224
  */
226
225
  AttachButton: React.ComponentType<AttachButtonProps<StreamChatGenerics>>;
227
226
 
228
- /** Custom UI component for AudioAttachment. */
229
- AudioAttachment: React.ComponentType<AudioAttachmentProps<StreamChatGenerics>>;
230
-
231
227
  clearEditingState: () => void;
232
228
  clearQuotedMessageState: () => void;
233
229
  /**
@@ -12,7 +12,6 @@ export const useCreateMessageInputContext = <
12
12
  asyncIds,
13
13
  asyncUploads,
14
14
  AttachButton,
15
- AudioAttachment,
16
15
  autoCompleteSuggestionsLimit,
17
16
  clearEditingState,
18
17
  clearQuotedMessageState,
@@ -116,7 +115,6 @@ export const useCreateMessageInputContext = <
116
115
  asyncIds,
117
116
  asyncUploads,
118
117
  AttachButton,
119
- AudioAttachment,
120
118
  autoCompleteSuggestionsLimit,
121
119
  clearEditingState,
122
120
  clearQuotedMessageState,
@@ -11,6 +11,7 @@ import type { Attachment, ChannelState, MessageResponse } from 'stream-chat';
11
11
 
12
12
  import type { AttachmentProps } from '../../components/Attachment/Attachment';
13
13
  import type { AttachmentActionsProps } from '../../components/Attachment/AttachmentActions';
14
+ import type { AudioAttachmentProps } from '../../components/Attachment/AudioAttachment';
14
15
  import type { CardProps } from '../../components/Attachment/Card';
15
16
  import type { FileAttachmentProps } from '../../components/Attachment/FileAttachment';
16
17
  import type { FileAttachmentGroupProps } from '../../components/Attachment/FileAttachmentGroup';
@@ -72,6 +73,8 @@ export type MessagesContextValue<
72
73
  * Defaults to: [AttachmentActions](https://github.com/GetStream/stream-chat-react-native/blob/main/package/src/components/Attachment/AttachmentActions.tsx)
73
74
  */
74
75
  AttachmentActions: React.ComponentType<AttachmentActionsProps<StreamChatGenerics>>;
76
+ /** Custom UI component for AudioAttachment. */
77
+ AudioAttachment: React.ComponentType<AudioAttachmentProps>;
75
78
  /**
76
79
  * UI component to display generic media type e.g. giphy, url preview etc
77
80
  * Defaults to: [Card](https://github.com/GetStream/stream-chat-react-native/blob/main/package/src/components/Attachment/Card.tsx)
package/src/version.json CHANGED
@@ -1,3 +1,3 @@
1
1
  {
2
- "version": "4.12.0-beta.3"
2
+ "version": "4.12.0"
3
3
  }