stream-chat-react-native-core 5.1.1-beta.1 → 5.3.0-beta.1

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 (127) hide show
  1. package/lib/commonjs/components/Attachment/Card.js +29 -18
  2. package/lib/commonjs/components/Attachment/Card.js.map +1 -1
  3. package/lib/commonjs/components/Attachment/Gallery.js +16 -20
  4. package/lib/commonjs/components/Attachment/Gallery.js.map +1 -1
  5. package/lib/commonjs/components/Attachment/GalleryImage.js +34 -6
  6. package/lib/commonjs/components/Attachment/GalleryImage.js.map +1 -1
  7. package/lib/commonjs/components/Attachment/Giphy.js +37 -29
  8. package/lib/commonjs/components/Attachment/Giphy.js.map +1 -1
  9. package/lib/commonjs/components/Avatar/Avatar.js +10 -8
  10. package/lib/commonjs/components/Avatar/Avatar.js.map +1 -1
  11. package/lib/commonjs/components/Avatar/GroupAvatar.js +3 -1
  12. package/lib/commonjs/components/Avatar/GroupAvatar.js.map +1 -1
  13. package/lib/commonjs/components/ChannelList/ChannelListMessenger.js +32 -15
  14. package/lib/commonjs/components/ChannelList/ChannelListMessenger.js.map +1 -1
  15. package/lib/commonjs/components/ChannelPreview/ChannelAvatar.js +30 -6
  16. package/lib/commonjs/components/ChannelPreview/ChannelAvatar.js.map +1 -1
  17. package/lib/commonjs/components/Chat/Chat.js +20 -5
  18. package/lib/commonjs/components/Chat/Chat.js.map +1 -1
  19. package/lib/commonjs/components/Chat/hooks/useCreateChatContext.js +2 -0
  20. package/lib/commonjs/components/Chat/hooks/useCreateChatContext.js.map +1 -1
  21. package/lib/commonjs/components/ImageBackground.js +64 -0
  22. package/lib/commonjs/components/ImageBackground.js.map +1 -0
  23. package/lib/commonjs/components/Message/Message.js +15 -16
  24. package/lib/commonjs/components/Message/Message.js.map +1 -1
  25. package/lib/commonjs/components/Message/MessageSimple/MessageAvatar.js +12 -4
  26. package/lib/commonjs/components/Message/MessageSimple/MessageAvatar.js.map +1 -1
  27. package/lib/commonjs/components/Message/MessageSimple/MessageRepliesAvatars.js +26 -5
  28. package/lib/commonjs/components/Message/MessageSimple/MessageRepliesAvatars.js.map +1 -1
  29. package/lib/commonjs/components/MessageList/MessageList.js +39 -26
  30. package/lib/commonjs/components/MessageList/MessageList.js.map +1 -1
  31. package/lib/commonjs/components/MessageOverlay/MessageOverlay.js +58 -47
  32. package/lib/commonjs/components/MessageOverlay/MessageOverlay.js.map +1 -1
  33. package/lib/commonjs/components/MessageOverlay/OverlayReactions.js +19 -19
  34. package/lib/commonjs/components/MessageOverlay/OverlayReactions.js.map +1 -1
  35. package/lib/commonjs/contexts/chatContext/ChatContext.js +2 -2
  36. package/lib/commonjs/contexts/chatContext/ChatContext.js.map +1 -1
  37. package/lib/commonjs/contexts/debugContext/DebugContext.js +63 -0
  38. package/lib/commonjs/contexts/debugContext/DebugContext.js.map +1 -0
  39. package/lib/commonjs/contexts/index.js +13 -0
  40. package/lib/commonjs/contexts/index.js.map +1 -1
  41. package/lib/commonjs/contexts/messageOverlayContext/MessageOverlayContext.js +2 -2
  42. package/lib/commonjs/contexts/messageOverlayContext/MessageOverlayContext.js.map +1 -1
  43. package/lib/commonjs/version.json +1 -1
  44. package/lib/module/components/Attachment/Card.js +29 -18
  45. package/lib/module/components/Attachment/Card.js.map +1 -1
  46. package/lib/module/components/Attachment/Gallery.js +16 -20
  47. package/lib/module/components/Attachment/Gallery.js.map +1 -1
  48. package/lib/module/components/Attachment/GalleryImage.js +34 -6
  49. package/lib/module/components/Attachment/GalleryImage.js.map +1 -1
  50. package/lib/module/components/Attachment/Giphy.js +37 -29
  51. package/lib/module/components/Attachment/Giphy.js.map +1 -1
  52. package/lib/module/components/Avatar/Avatar.js +10 -8
  53. package/lib/module/components/Avatar/Avatar.js.map +1 -1
  54. package/lib/module/components/Avatar/GroupAvatar.js +3 -1
  55. package/lib/module/components/Avatar/GroupAvatar.js.map +1 -1
  56. package/lib/module/components/ChannelList/ChannelListMessenger.js +32 -15
  57. package/lib/module/components/ChannelList/ChannelListMessenger.js.map +1 -1
  58. package/lib/module/components/ChannelPreview/ChannelAvatar.js +30 -6
  59. package/lib/module/components/ChannelPreview/ChannelAvatar.js.map +1 -1
  60. package/lib/module/components/Chat/Chat.js +20 -5
  61. package/lib/module/components/Chat/Chat.js.map +1 -1
  62. package/lib/module/components/Chat/hooks/useCreateChatContext.js +2 -0
  63. package/lib/module/components/Chat/hooks/useCreateChatContext.js.map +1 -1
  64. package/lib/module/components/ImageBackground.js +64 -0
  65. package/lib/module/components/ImageBackground.js.map +1 -0
  66. package/lib/module/components/Message/Message.js +15 -16
  67. package/lib/module/components/Message/Message.js.map +1 -1
  68. package/lib/module/components/Message/MessageSimple/MessageAvatar.js +12 -4
  69. package/lib/module/components/Message/MessageSimple/MessageAvatar.js.map +1 -1
  70. package/lib/module/components/Message/MessageSimple/MessageRepliesAvatars.js +26 -5
  71. package/lib/module/components/Message/MessageSimple/MessageRepliesAvatars.js.map +1 -1
  72. package/lib/module/components/MessageList/MessageList.js +39 -26
  73. package/lib/module/components/MessageList/MessageList.js.map +1 -1
  74. package/lib/module/components/MessageOverlay/MessageOverlay.js +58 -47
  75. package/lib/module/components/MessageOverlay/MessageOverlay.js.map +1 -1
  76. package/lib/module/components/MessageOverlay/OverlayReactions.js +19 -19
  77. package/lib/module/components/MessageOverlay/OverlayReactions.js.map +1 -1
  78. package/lib/module/contexts/chatContext/ChatContext.js +2 -2
  79. package/lib/module/contexts/chatContext/ChatContext.js.map +1 -1
  80. package/lib/module/contexts/debugContext/DebugContext.js +63 -0
  81. package/lib/module/contexts/debugContext/DebugContext.js.map +1 -0
  82. package/lib/module/contexts/index.js +13 -0
  83. package/lib/module/contexts/index.js.map +1 -1
  84. package/lib/module/contexts/messageOverlayContext/MessageOverlayContext.js +2 -2
  85. package/lib/module/contexts/messageOverlayContext/MessageOverlayContext.js.map +1 -1
  86. package/lib/module/version.json +1 -1
  87. package/lib/typescript/components/Attachment/Card.d.ts +3 -2
  88. package/lib/typescript/components/Attachment/GalleryImage.d.ts +8 -2
  89. package/lib/typescript/components/Attachment/Giphy.d.ts +2 -1
  90. package/lib/typescript/components/Avatar/Avatar.d.ts +2 -1
  91. package/lib/typescript/components/Avatar/GroupAvatar.d.ts +2 -1
  92. package/lib/typescript/components/ChannelPreview/ChannelAvatar.d.ts +2 -0
  93. package/lib/typescript/components/Chat/Chat.d.ts +1 -1
  94. package/lib/typescript/components/Chat/hooks/useCreateChatContext.d.ts +1 -1
  95. package/lib/typescript/components/ImageBackground.d.ts +33 -0
  96. package/lib/typescript/components/Message/Message.d.ts +2 -1
  97. package/lib/typescript/components/Message/MessageSimple/MessageAvatar.d.ts +2 -1
  98. package/lib/typescript/components/Message/MessageSimple/MessageRepliesAvatars.d.ts +2 -0
  99. package/lib/typescript/components/MessageOverlay/OverlayReactions.d.ts +1 -0
  100. package/lib/typescript/contexts/chatContext/ChatContext.d.ts +3 -1
  101. package/lib/typescript/contexts/debugContext/DebugContext.d.ts +27 -0
  102. package/lib/typescript/contexts/index.d.ts +1 -0
  103. package/lib/typescript/contexts/messageOverlayContext/MessageOverlayContext.d.ts +4 -0
  104. package/package.json +2 -2
  105. package/src/components/Attachment/Card.tsx +11 -2
  106. package/src/components/Attachment/Gallery.tsx +1 -7
  107. package/src/components/Attachment/GalleryImage.tsx +31 -9
  108. package/src/components/Attachment/Giphy.tsx +8 -2
  109. package/src/components/Avatar/Avatar.tsx +12 -2
  110. package/src/components/Avatar/GroupAvatar.tsx +4 -4
  111. package/src/components/ChannelList/ChannelListMessenger.tsx +17 -0
  112. package/src/components/ChannelList/hooks/listeners/__tests__/useChannelUpdated.test.tsx +2 -1
  113. package/src/components/ChannelPreview/ChannelAvatar.tsx +23 -4
  114. package/src/components/Chat/Chat.tsx +111 -95
  115. package/src/components/Chat/hooks/useCreateChatContext.ts +2 -0
  116. package/src/components/ImageBackground.tsx +77 -0
  117. package/src/components/Message/Message.tsx +8 -8
  118. package/src/components/Message/MessageSimple/MessageAvatar.tsx +6 -2
  119. package/src/components/Message/MessageSimple/MessageRepliesAvatars.tsx +15 -3
  120. package/src/components/MessageList/MessageList.tsx +15 -0
  121. package/src/components/MessageOverlay/MessageOverlay.tsx +210 -205
  122. package/src/components/MessageOverlay/OverlayReactions.tsx +1 -0
  123. package/src/contexts/chatContext/ChatContext.tsx +3 -1
  124. package/src/contexts/debugContext/DebugContext.tsx +77 -0
  125. package/src/contexts/index.ts +1 -0
  126. package/src/contexts/messageOverlayContext/MessageOverlayContext.tsx +8 -1
  127. package/src/version.json +1 -1
@@ -1,4 +1,5 @@
1
1
  import React, { PropsWithChildren } from 'react';
2
+ import type { ImageProps } from 'react-native';
2
3
  import type { Attachment, TranslationLanguages } from 'stream-chat';
3
4
  import type { GroupType, MessageType } from '../../components/MessageList/hooks/useMessageList';
4
5
  import type { MessageActionListProps } from '../../components/MessageOverlay/MessageActionList';
@@ -8,15 +9,18 @@ import type { OverlayReactionsProps } from '../../components/MessageOverlay/Over
8
9
  import type { OverlayReactionsAvatarProps } from '../../components/MessageOverlay/OverlayReactionsAvatar';
9
10
  import type { DefaultStreamChatGenerics, UnknownType } from '../../types/types';
10
11
  import type { ReactionData } from '../../utils/utils';
12
+ import type { ChatContextValue } from '../chatContext/ChatContext';
11
13
  import type { Alignment, MessageContextValue } from '../messageContext/MessageContext';
12
14
  import type { MessagesContextValue } from '../messagesContext/MessagesContext';
13
15
  import type { OwnCapabilitiesContextValue } from '../ownCapabilitiesContext/OwnCapabilitiesContext';
14
16
  export declare type MessageOverlayData<StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics> = {
15
17
  alignment?: Alignment;
18
+ chatContext?: ChatContextValue<StreamChatGenerics>;
16
19
  clientId?: string;
17
20
  files?: Attachment<StreamChatGenerics>[];
18
21
  groupStyles?: GroupType[];
19
22
  handleReaction?: (reactionType: string) => Promise<void>;
23
+ ImageComponent?: React.ComponentType<ImageProps>;
20
24
  images?: Attachment<StreamChatGenerics>[];
21
25
  message?: MessageType<StreamChatGenerics>;
22
26
  messageActions?: MessageActionType[];
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "stream-chat-react-native-core",
3
3
  "description": "The official React Native and Expo components for Stream Chat, a service for building chat applications",
4
- "version": "5.1.1-beta.1",
4
+ "version": "5.3.0-beta.1",
5
5
  "author": {
6
6
  "company": "Stream.io Inc",
7
7
  "name": "Stream.io Inc"
@@ -94,13 +94,13 @@
94
94
  "@babel/preset-env": "7.13.12",
95
95
  "@babel/preset-typescript": "7.13.0",
96
96
  "@babel/runtime": "^7.12.5",
97
- "@types/better-sqlite3": "^7.6.0",
98
97
  "@react-native-community/eslint-config": "2.0.0",
99
98
  "@react-native-community/eslint-plugin": "1.1.0",
100
99
  "@react-native-community/netinfo": "6.0.0",
101
100
  "@testing-library/jest-native": "4.0.4",
102
101
  "@testing-library/react-hooks": "7.0.2",
103
102
  "@testing-library/react-native": "9.0.0",
103
+ "@types/better-sqlite3": "^7.6.0",
104
104
  "@types/eslint": "7.2.10",
105
105
  "@types/jest": "26.0.23",
106
106
  "@types/lodash": "4.14.169",
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  import {
3
- ImageBackground,
3
+ Image,
4
4
  ImageStyle,
5
5
  StyleProp,
6
6
  StyleSheet,
@@ -15,6 +15,8 @@ import type { Attachment } from 'stream-chat';
15
15
 
16
16
  import { openUrlSafely } from './utils/openUrlSafely';
17
17
 
18
+ import { ChatContextValue, useChatContext } from '../../contexts/chatContext/ChatContext';
19
+
18
20
  import {
19
21
  MessageContextValue,
20
22
  useMessageContext,
@@ -27,6 +29,7 @@ import { useTheme } from '../../contexts/themeContext/ThemeContext';
27
29
  import { Play } from '../../icons/Play';
28
30
  import type { DefaultStreamChatGenerics } from '../../types/types';
29
31
  import { makeImageCompatibleUrl } from '../../utils/utils';
32
+ import { ImageBackground } from '../ImageBackground';
30
33
 
31
34
  const styles = StyleSheet.create({
32
35
  authorName: { fontSize: 14.5, fontWeight: '600' },
@@ -82,6 +85,7 @@ const styles = StyleSheet.create({
82
85
  export type CardPropsWithContext<
83
86
  StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
84
87
  > = Attachment<StreamChatGenerics> &
88
+ Pick<ChatContextValue, 'ImageComponent'> &
85
89
  Pick<
86
90
  MessageContextValue<StreamChatGenerics>,
87
91
  'onLongPress' | 'onPress' | 'onPressIn' | 'preventPress'
@@ -117,6 +121,7 @@ const CardWithContext = <
117
121
  CardCover,
118
122
  CardFooter,
119
123
  CardHeader,
124
+ ImageComponent = Image,
120
125
  image_url,
121
126
  og_scrape_url,
122
127
  onLongPress,
@@ -198,6 +203,7 @@ const CardWithContext = <
198
203
  {uri && !CardCover && (
199
204
  <View>
200
205
  <ImageBackground
206
+ ImageComponent={ImageComponent}
201
207
  imageStyle={styles.cardCover}
202
208
  resizeMode='cover'
203
209
  source={{ uri: makeImageCompatibleUrl(uri) }}
@@ -287,7 +293,8 @@ export type CardProps<
287
293
  StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
288
294
  > = Attachment<StreamChatGenerics> &
289
295
  Partial<
290
- Pick<MessageContextValue<StreamChatGenerics>, 'onLongPress' | 'onPress' | 'onPressIn'> &
296
+ Pick<ChatContextValue<StreamChatGenerics>, 'ImageComponent'> &
297
+ Pick<MessageContextValue<StreamChatGenerics>, 'onLongPress' | 'onPress' | 'onPressIn'> &
291
298
  Pick<
292
299
  MessagesContextValue<StreamChatGenerics>,
293
300
  'additionalTouchableProps' | 'CardCover' | 'CardFooter' | 'CardHeader'
@@ -302,6 +309,7 @@ export const Card = <
302
309
  >(
303
310
  props: CardProps<StreamChatGenerics>,
304
311
  ) => {
312
+ const { ImageComponent } = useChatContext<StreamChatGenerics>();
305
313
  const { message, onLongPress, onPress, onPressIn, preventPress } =
306
314
  useMessageContext<StreamChatGenerics>();
307
315
  const { additionalTouchableProps, CardCover, CardFooter, CardHeader } =
@@ -316,6 +324,7 @@ export const Card = <
316
324
  CardFooter,
317
325
  CardHeader,
318
326
  channelId: message.cid,
327
+ ImageComponent,
319
328
  messageId: message.id,
320
329
  onLongPress,
321
330
  onPress,
@@ -34,12 +34,6 @@ import { isVideoPackageAvailable } from '../../native';
34
34
  import type { DefaultStreamChatGenerics } from '../../types/types';
35
35
  import { getUrlWithoutParams } from '../../utils/utils';
36
36
 
37
- const MemoizedGalleryImage = React.memo(
38
- GalleryImage,
39
- (prevProps, nextProps) =>
40
- getUrlWithoutParams(prevProps.uri) === getUrlWithoutParams(nextProps.uri),
41
- ) as typeof GalleryImage;
42
-
43
37
  const styles = StyleSheet.create({
44
38
  errorTextSize: { fontSize: 10 },
45
39
  galleryContainer: {
@@ -476,7 +470,7 @@ const GalleryImageThumbnail = <
476
470
  <ImageLoadingFailedIndicator style={[styles.imageLoadingErrorIndicatorStyle]} />
477
471
  ) : (
478
472
  <>
479
- <MemoizedGalleryImage
473
+ <GalleryImage
480
474
  onError={(error) => {
481
475
  console.warn(error);
482
476
  setLoadingImage(false);
@@ -1,17 +1,20 @@
1
1
  import React from 'react';
2
- import { ImageBackground, ImageProps } from 'react-native';
2
+ import { Image, ImageProps } from 'react-native';
3
3
 
4
- import { makeImageCompatibleUrl } from '../../utils/utils';
4
+ import { ChatContextValue, useChatContext } from '../../contexts/chatContext/ChatContext';
5
5
 
6
- export const GalleryImage: React.FC<
7
- Omit<ImageProps, 'height' | 'source'> & {
8
- uri: string;
9
- }
10
- > = (props) => {
11
- const { uri, ...rest } = props;
6
+ import type { DefaultStreamChatGenerics } from '../../types/types';
7
+ import { getUrlWithoutParams, makeImageCompatibleUrl } from '../../utils/utils';
8
+
9
+ export type GalleryImageWithContextProps<
10
+ StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
11
+ > = GalleryImageProps & Pick<ChatContextValue<StreamChatGenerics>, 'ImageComponent'>;
12
+
13
+ export const GalleryImageWithContext: React.FC<GalleryImageWithContextProps> = (props) => {
14
+ const { ImageComponent = Image, uri, ...rest } = props;
12
15
 
13
16
  return (
14
- <ImageBackground
17
+ <ImageComponent
15
18
  {...rest}
16
19
  accessibilityLabel='Gallery Image'
17
20
  source={{
@@ -20,3 +23,22 @@ export const GalleryImage: React.FC<
20
23
  />
21
24
  );
22
25
  };
26
+
27
+ export const MemoizedGalleryImage = React.memo(
28
+ GalleryImageWithContext,
29
+ (prevProps, nextProps) =>
30
+ getUrlWithoutParams(prevProps.uri) === getUrlWithoutParams(nextProps.uri),
31
+ );
32
+ export type GalleryImageProps = Omit<ImageProps, 'height' | 'source'> & {
33
+ uri: string;
34
+ };
35
+
36
+ export const GalleryImage = <
37
+ StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
38
+ >(
39
+ props: GalleryImageProps,
40
+ ) => {
41
+ const { ImageComponent } = useChatContext<StreamChatGenerics>();
42
+
43
+ return <MemoizedGalleryImage ImageComponent={ImageComponent} {...props} />;
44
+ };
@@ -3,6 +3,8 @@ import { Image, StyleSheet, Text, TouchableOpacity, View } from 'react-native';
3
3
 
4
4
  import type { Attachment } from 'stream-chat';
5
5
 
6
+ import { ChatContextValue, useChatContext } from '../../contexts/chatContext/ChatContext';
7
+
6
8
  import {
7
9
  ImageGalleryContextValue,
8
10
  useImageGalleryContext,
@@ -145,6 +147,7 @@ export type GiphyPropsWithContext<
145
147
  | 'onPressIn'
146
148
  | 'preventPress'
147
149
  > &
150
+ Pick<ChatContextValue<StreamChatGenerics>, 'ImageComponent'> &
148
151
  Pick<
149
152
  MessagesContextValue<StreamChatGenerics>,
150
153
  | 'giphyVersion'
@@ -165,6 +168,7 @@ const GiphyWithContext = <
165
168
  attachment,
166
169
  giphyVersion,
167
170
  handleAction,
171
+ ImageComponent = Image,
168
172
  ImageLoadingFailedIndicator,
169
173
  ImageLoadingIndicator,
170
174
  isMyMessage,
@@ -241,7 +245,7 @@ const GiphyWithContext = <
241
245
  >{`/giphy ${title}`}</Text>
242
246
  </View>
243
247
  <View style={styles.selectionImageContainer}>
244
- <Image
248
+ <ImageComponent
245
249
  onError={(error) => {
246
250
  console.warn(error);
247
251
  setLoadingImage(false);
@@ -339,7 +343,7 @@ const GiphyWithContext = <
339
343
  container,
340
344
  ]}
341
345
  >
342
- <Image
346
+ <ImageComponent
343
347
  accessibilityLabel='Giphy Attachment Image'
344
348
  onError={(error) => {
345
349
  console.warn(error);
@@ -446,6 +450,7 @@ export const Giphy = <
446
450
  ) => {
447
451
  const { handleAction, isMyMessage, message, onLongPress, onPress, onPressIn, preventPress } =
448
452
  useMessageContext<StreamChatGenerics>();
453
+ const { ImageComponent } = useChatContext<StreamChatGenerics>();
449
454
  const { additionalTouchableProps, giphyVersion } = useMessagesContext<StreamChatGenerics>();
450
455
  const { setMessages, setSelectedMessage } = useImageGalleryContext<StreamChatGenerics>();
451
456
  const { setOverlay } = useOverlayContext();
@@ -464,6 +469,7 @@ export const Giphy = <
464
469
  additionalTouchableProps,
465
470
  giphyVersion,
466
471
  handleAction,
472
+ ImageComponent,
467
473
  ImageLoadingFailedIndicator,
468
474
  ImageLoadingIndicator,
469
475
  isMyMessage,
@@ -1,5 +1,13 @@
1
1
  import React from 'react';
2
- import { Image, ImageStyle, StyleProp, StyleSheet, View, ViewStyle } from 'react-native';
2
+ import {
3
+ Image,
4
+ ImageProps,
5
+ ImageStyle,
6
+ StyleProp,
7
+ StyleSheet,
8
+ View,
9
+ ViewStyle,
10
+ } from 'react-native';
3
11
  import Svg, { Circle, CircleProps } from 'react-native-svg';
4
12
 
5
13
  import { useTheme } from '../../contexts/themeContext/ThemeContext';
@@ -38,6 +46,7 @@ export type AvatarProps = {
38
46
  containerStyle?: StyleProp<ViewStyle>;
39
47
  /** image url */
40
48
  image?: string;
49
+ ImageComponent?: React.ComponentType<ImageProps>;
41
50
  /** name of the picture, used for fallback */
42
51
  imageStyle?: StyleProp<ImageStyle>;
43
52
  name?: string;
@@ -53,6 +62,7 @@ export type AvatarProps = {
53
62
  export const Avatar: React.FC<AvatarProps> = (props) => {
54
63
  const {
55
64
  containerStyle,
65
+ ImageComponent = Image,
56
66
  image: imageProp,
57
67
  imageStyle,
58
68
  name,
@@ -95,7 +105,7 @@ export const Avatar: React.FC<AvatarProps> = (props) => {
95
105
  }}
96
106
  />
97
107
  ) : (
98
- <Image
108
+ <ImageComponent
99
109
  accessibilityLabel={testID || 'Avatar Image'}
100
110
  onError={() => setLoadingImageError(true)}
101
111
  source={{
@@ -1,10 +1,9 @@
1
1
  import React from 'react';
2
- import { Image, StyleProp, StyleSheet, View, ViewStyle } from 'react-native';
2
+ import { Image, ImageProps, StyleProp, StyleSheet, View, ViewStyle } from 'react-native';
3
3
 
4
4
  import { useTheme } from '../../contexts/themeContext/ThemeContext';
5
5
  import { useLoadingImage } from '../../hooks/useLoadingImage';
6
6
  import { getResizedImageUrl } from '../../utils/getResizedImageUrl';
7
-
8
7
  const randomImageBaseUrl = 'https://getstream.io/random_png/';
9
8
  const randomSvgBaseUrl = 'https://getstream.io/random_svg/';
10
9
  const streamCDN = 'stream-io-cdn.com';
@@ -27,6 +26,7 @@ export type GroupAvatarProps = {
27
26
  /** total size in pixels */
28
27
  size: number;
29
28
  containerStyle?: StyleProp<ViewStyle>;
29
+ ImageComponent?: React.ComponentType<ImageProps>;
30
30
  /** image urls */
31
31
  images?: string[];
32
32
  /** name of the users, used for fallback */
@@ -38,7 +38,7 @@ export type GroupAvatarProps = {
38
38
  * GroupAvatar - A round group of avatar images with fallbacks to users' initials
39
39
  */
40
40
  export const GroupAvatar: React.FC<GroupAvatarProps> = (props) => {
41
- const { containerStyle, images, names, size, testID } = props;
41
+ const { containerStyle, ImageComponent = Image, images, names, size, testID } = props;
42
42
  const {
43
43
  theme: {
44
44
  groupAvatar: { container, image },
@@ -136,7 +136,7 @@ export const GroupAvatar: React.FC<GroupAvatarProps> = (props) => {
136
136
  ]}
137
137
  >
138
138
  {column.map(({ height, name, url, width }, rowIndex) => (
139
- <Image
139
+ <ImageComponent
140
140
  accessibilityLabel={testID || 'Avatar Image'}
141
141
  key={`avatar-${url}-${rowIndex}`}
142
142
  onError={() => setLoadingImageError(true)}
@@ -10,6 +10,7 @@ import {
10
10
  useChannelsContext,
11
11
  } from '../../contexts/channelsContext/ChannelsContext';
12
12
  import { useChatContext } from '../../contexts/chatContext/ChatContext';
13
+ import { useDebugContext } from '../../contexts/debugContext/DebugContext';
13
14
  import { useTheme } from '../../contexts/themeContext/ThemeContext';
14
15
 
15
16
  import type { DefaultStreamChatGenerics } from '../../types/types';
@@ -116,12 +117,28 @@ const ChannelListMessengerWithContext = <
116
117
  * change to loadingChannels is registered.
117
118
  */
118
119
  const [loading, setLoading] = useState(true);
120
+ const debugRef = useDebugContext();
121
+
119
122
  useEffect(() => {
120
123
  if (!!loadingChannels !== loading) {
121
124
  setLoading(!!loadingChannels);
122
125
  }
123
126
  }, [loading, loadingChannels]);
124
127
 
128
+ const isDebugModeEnabled = __DEV__ && debugRef && debugRef.current;
129
+
130
+ if (isDebugModeEnabled) {
131
+ if (debugRef.current.setEventType) debugRef.current.setEventType('send');
132
+ if (debugRef.current.setSendEventParams)
133
+ debugRef.current.setSendEventParams({
134
+ action: 'Channels',
135
+ data: channels.map((channel) => ({
136
+ data: channel.data,
137
+ members: channel.state.members,
138
+ })),
139
+ });
140
+ }
141
+
125
142
  if (error && !refreshing && !loadingChannels && !channels?.length) {
126
143
  return (
127
144
  <LoadingErrorIndicator
@@ -1,5 +1,5 @@
1
1
  import React, { useState } from 'react';
2
- import { Text } from 'react-native';
2
+ import { Image, Text } from 'react-native';
3
3
 
4
4
  import { act } from 'react-test-renderer';
5
5
 
@@ -59,6 +59,7 @@ describe('useChannelUpdated', () => {
59
59
  client: mockClient,
60
60
  connectionRecovering: false,
61
61
  enableOfflineSupport: false,
62
+ ImageComponent: Image,
62
63
  isOnline: true,
63
64
  mutedUsers: [],
64
65
  setActiveChannel: () => null,
@@ -4,6 +4,7 @@ import type { ChannelPreviewProps } from './ChannelPreview';
4
4
  import { useChannelPreviewDisplayAvatar } from './hooks/useChannelPreviewDisplayAvatar';
5
5
  import { useChannelPreviewDisplayPresence } from './hooks/useChannelPreviewDisplayPresence';
6
6
 
7
+ import { ChatContextValue, useChatContext } from '../../contexts/chatContext/ChatContext';
7
8
  import type { DefaultStreamChatGenerics } from '../../types/types';
8
9
  import { Avatar } from '../Avatar/Avatar';
9
10
  import { GroupAvatar } from '../Avatar/GroupAvatar';
@@ -15,26 +16,44 @@ export type ChannelAvatarProps<
15
16
  /**
16
17
  * This UI component displays an avatar for a particular channel.
17
18
  */
18
- export const ChannelAvatar = <
19
+ export const ChannelAvatarWithContext = <
19
20
  StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
20
21
  >(
21
- props: ChannelAvatarProps<StreamChatGenerics>,
22
+ props: ChannelAvatarProps<StreamChatGenerics> & Pick<ChatContextValue, 'ImageComponent'>,
22
23
  ) => {
23
- const { channel } = props;
24
+ const { channel, ImageComponent } = props;
24
25
 
25
26
  const displayAvatar = useChannelPreviewDisplayAvatar(channel);
26
27
  const displayPresence = useChannelPreviewDisplayPresence(channel);
27
28
 
28
29
  if (displayAvatar.images) {
29
- return <GroupAvatar images={displayAvatar.images} names={displayAvatar.names} size={40} />;
30
+ return (
31
+ <GroupAvatar
32
+ ImageComponent={ImageComponent}
33
+ images={displayAvatar.images}
34
+ names={displayAvatar.names}
35
+ size={40}
36
+ />
37
+ );
30
38
  }
31
39
 
32
40
  return (
33
41
  <Avatar
34
42
  image={displayAvatar.image}
43
+ ImageComponent={ImageComponent}
35
44
  name={displayAvatar.name}
36
45
  online={displayPresence}
37
46
  size={40}
38
47
  />
39
48
  );
40
49
  };
50
+
51
+ export const ChannelAvatar = <
52
+ StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
53
+ >(
54
+ props: ChannelAvatarProps<StreamChatGenerics>,
55
+ ) => {
56
+ const { ImageComponent } = useChatContext<StreamChatGenerics>();
57
+
58
+ return <ChannelAvatarWithContext {...props} ImageComponent={ImageComponent} />;
59
+ };