stream-chat-react-native-core 5.1.0-beta.1 → 5.2.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 (66) hide show
  1. package/lib/commonjs/components/ChannelList/ChannelListMessenger.js +32 -15
  2. package/lib/commonjs/components/ChannelList/ChannelListMessenger.js.map +1 -1
  3. package/lib/commonjs/components/Chat/Chat.js +17 -5
  4. package/lib/commonjs/components/Chat/Chat.js.map +1 -1
  5. package/lib/commonjs/components/ImageGallery/ImageGallery.js +106 -100
  6. package/lib/commonjs/components/ImageGallery/ImageGallery.js.map +1 -1
  7. package/lib/commonjs/components/ImageGallery/components/AnimatedGalleryVideo.js +14 -16
  8. package/lib/commonjs/components/ImageGallery/components/AnimatedGalleryVideo.js.map +1 -1
  9. package/lib/commonjs/components/ImageGallery/components/ImageGalleryFooter.js +13 -16
  10. package/lib/commonjs/components/ImageGallery/components/ImageGalleryFooter.js.map +1 -1
  11. package/lib/commonjs/components/ImageGallery/components/ImageGalleryVideoControl.js +6 -6
  12. package/lib/commonjs/components/ImageGallery/components/ImageGalleryVideoControl.js.map +1 -1
  13. package/lib/commonjs/components/MessageList/MessageList.js +39 -26
  14. package/lib/commonjs/components/MessageList/MessageList.js.map +1 -1
  15. package/lib/commonjs/components/ProgressControl/ProgressControl.js +6 -6
  16. package/lib/commonjs/components/ProgressControl/ProgressControl.js.map +1 -1
  17. package/lib/commonjs/contexts/debugContext/DebugContext.js +63 -0
  18. package/lib/commonjs/contexts/debugContext/DebugContext.js.map +1 -0
  19. package/lib/commonjs/contexts/index.js +13 -0
  20. package/lib/commonjs/contexts/index.js.map +1 -1
  21. package/lib/commonjs/native.js.map +1 -1
  22. package/lib/commonjs/version.json +1 -1
  23. package/lib/module/components/ChannelList/ChannelListMessenger.js +32 -15
  24. package/lib/module/components/ChannelList/ChannelListMessenger.js.map +1 -1
  25. package/lib/module/components/Chat/Chat.js +17 -5
  26. package/lib/module/components/Chat/Chat.js.map +1 -1
  27. package/lib/module/components/ImageGallery/ImageGallery.js +106 -100
  28. package/lib/module/components/ImageGallery/ImageGallery.js.map +1 -1
  29. package/lib/module/components/ImageGallery/components/AnimatedGalleryVideo.js +14 -16
  30. package/lib/module/components/ImageGallery/components/AnimatedGalleryVideo.js.map +1 -1
  31. package/lib/module/components/ImageGallery/components/ImageGalleryFooter.js +13 -16
  32. package/lib/module/components/ImageGallery/components/ImageGalleryFooter.js.map +1 -1
  33. package/lib/module/components/ImageGallery/components/ImageGalleryVideoControl.js +6 -6
  34. package/lib/module/components/ImageGallery/components/ImageGalleryVideoControl.js.map +1 -1
  35. package/lib/module/components/MessageList/MessageList.js +39 -26
  36. package/lib/module/components/MessageList/MessageList.js.map +1 -1
  37. package/lib/module/components/ProgressControl/ProgressControl.js +6 -6
  38. package/lib/module/components/ProgressControl/ProgressControl.js.map +1 -1
  39. package/lib/module/contexts/debugContext/DebugContext.js +63 -0
  40. package/lib/module/contexts/debugContext/DebugContext.js.map +1 -0
  41. package/lib/module/contexts/index.js +13 -0
  42. package/lib/module/contexts/index.js.map +1 -1
  43. package/lib/module/native.js.map +1 -1
  44. package/lib/module/version.json +1 -1
  45. package/lib/typescript/components/ImageGallery/ImageGallery.d.ts +3 -0
  46. package/lib/typescript/components/ImageGallery/components/AnimatedGalleryVideo.d.ts +5 -3
  47. package/lib/typescript/components/ImageGallery/components/ImageGalleryFooter.d.ts +1 -3
  48. package/lib/typescript/components/ProgressControl/ProgressControl.d.ts +1 -1
  49. package/lib/typescript/contexts/debugContext/DebugContext.d.ts +27 -0
  50. package/lib/typescript/contexts/index.d.ts +1 -0
  51. package/lib/typescript/native.d.ts +3 -2
  52. package/package.json +2 -2
  53. package/src/components/ChannelList/ChannelListMessenger.tsx +17 -0
  54. package/src/components/Chat/Chat.tsx +13 -0
  55. package/src/components/ImageGallery/ImageGallery.tsx +87 -65
  56. package/src/components/ImageGallery/__tests__/AnimatedVideoGallery.test.tsx +2 -2
  57. package/src/components/ImageGallery/__tests__/ImageGallery.test.tsx +40 -28
  58. package/src/components/ImageGallery/components/AnimatedGalleryVideo.tsx +16 -9
  59. package/src/components/ImageGallery/components/ImageGalleryFooter.tsx +1 -6
  60. package/src/components/ImageGallery/components/ImageGalleryVideoControl.tsx +5 -6
  61. package/src/components/MessageList/MessageList.tsx +15 -0
  62. package/src/components/ProgressControl/ProgressControl.tsx +8 -4
  63. package/src/contexts/debugContext/DebugContext.tsx +77 -0
  64. package/src/contexts/index.ts +1 -0
  65. package/src/native.ts +3 -2
  66. package/src/version.json +1 -1
@@ -20,9 +20,10 @@ const halfScreenWidth = vw(50);
20
20
  const oneEighth = 1 / 8;
21
21
 
22
22
  export type AnimatedGalleryVideoType = {
23
+ attachmentId: string;
23
24
  handleEnd: () => void;
24
- handleLoad: (payload: VideoPayloadData) => void;
25
- handleProgress: (data: VideoProgressData) => void;
25
+ handleLoad: (index: string, duration: number) => void;
26
+ handleProgress: (index: string, progress: number, hasEnd?: boolean) => void;
26
27
  index: number;
27
28
  offsetScale: Animated.SharedValue<number>;
28
29
  paused: boolean;
@@ -35,6 +36,7 @@ export type AnimatedGalleryVideoType = {
35
36
  translateX: Animated.SharedValue<number>;
36
37
  translateY: Animated.SharedValue<number>;
37
38
  videoRef: React.RefObject<VideoType>;
39
+ repeat?: boolean;
38
40
  style?: StyleProp<ViewStyle>;
39
41
  };
40
42
 
@@ -51,7 +53,9 @@ const styles = StyleSheet.create({
51
53
  export const AnimatedGalleryVideo: React.FC<AnimatedGalleryVideoType> = React.memo(
52
54
  (props) => {
53
55
  const [opacity, setOpacity] = useState<number>(1);
56
+
54
57
  const {
58
+ attachmentId,
55
59
  handleEnd,
56
60
  handleLoad,
57
61
  handleProgress,
@@ -59,6 +63,7 @@ export const AnimatedGalleryVideo: React.FC<AnimatedGalleryVideoType> = React.me
59
63
  offsetScale,
60
64
  paused,
61
65
  previous,
66
+ repeat,
62
67
  scale,
63
68
  screenHeight,
64
69
  selected,
@@ -76,7 +81,7 @@ export const AnimatedGalleryVideo: React.FC<AnimatedGalleryVideoType> = React.me
76
81
 
77
82
  const onLoad = (payload: VideoPayloadData) => {
78
83
  setOpacity(0);
79
- handleLoad(payload);
84
+ handleLoad(attachmentId, payload.duration);
80
85
  };
81
86
 
82
87
  const onEnd = () => {
@@ -84,7 +89,7 @@ export const AnimatedGalleryVideo: React.FC<AnimatedGalleryVideoType> = React.me
84
89
  };
85
90
 
86
91
  const onProgress = (data: VideoProgressData) => {
87
- handleProgress(data);
92
+ handleProgress(attachmentId, data.currentTime / data.seekableDuration);
88
93
  };
89
94
 
90
95
  const onBuffer = ({ isBuffering }: { isBuffering: boolean }) => {
@@ -102,13 +107,13 @@ export const AnimatedGalleryVideo: React.FC<AnimatedGalleryVideoType> = React.me
102
107
  } else {
103
108
  // Update your UI for the loaded state
104
109
  setOpacity(0);
105
- handleLoad({ duration: playbackStatus.durationMillis / 1000 });
110
+ handleLoad(attachmentId, playbackStatus.durationMillis / 1000);
106
111
  if (playbackStatus.isPlaying) {
107
112
  // Update your UI for the playing state
108
- handleProgress({
109
- currentTime: playbackStatus.positionMillis / 1000,
110
- seekableDuration: playbackStatus.durationMillis / 1000,
111
- });
113
+ handleProgress(
114
+ attachmentId,
115
+ playbackStatus.positionMillis / 1000 / (playbackStatus.durationMillis / 1000),
116
+ );
112
117
  }
113
118
 
114
119
  if (playbackStatus.isBuffering) {
@@ -189,6 +194,7 @@ export const AnimatedGalleryVideo: React.FC<AnimatedGalleryVideoType> = React.me
189
194
  onPlaybackStatusUpdate={onPlayBackStatusUpdate}
190
195
  onProgress={onProgress}
191
196
  paused={paused}
197
+ repeat={repeat}
192
198
  resizeMode='contain'
193
199
  style={style}
194
200
  testID='video-player'
@@ -219,6 +225,7 @@ export const AnimatedGalleryVideo: React.FC<AnimatedGalleryVideoType> = React.me
219
225
  (prevProps, nextProps) => {
220
226
  if (
221
227
  prevProps.paused === nextProps.paused &&
228
+ prevProps.repeat === nextProps.repeat &&
222
229
  prevProps.shouldRender === nextProps.shouldRender &&
223
230
  prevProps.source.uri === nextProps.source.uri &&
224
231
  prevProps.screenHeight === nextProps.screenHeight &&
@@ -65,7 +65,6 @@ export type ImageGalleryFooterCustomComponent<
65
65
  export type ImageGalleryFooterVideoControlProps = {
66
66
  duration: number;
67
67
  onPlayPause: (status?: boolean) => void;
68
- onProgressDrag: (progress: number) => void;
69
68
  paused: boolean;
70
69
  progress: number;
71
70
  };
@@ -73,7 +72,6 @@ export type ImageGalleryFooterVideoControlProps = {
73
72
  export type ImageGalleryFooterVideoControlComponent = ({
74
73
  duration,
75
74
  onPlayPause,
76
- onProgressDrag,
77
75
  paused,
78
76
  progress,
79
77
  }: ImageGalleryFooterVideoControlProps) => React.ReactElement | null;
@@ -95,7 +93,6 @@ type ImageGalleryFooterPropsWithContext<
95
93
  accessibilityLabel: string;
96
94
  duration: number;
97
95
  onPlayPause: () => void;
98
- onProgressDrag: (progress: number) => void;
99
96
  opacity: Animated.SharedValue<number>;
100
97
  openGridView: () => void;
101
98
  paused: boolean;
@@ -118,7 +115,6 @@ export const ImageGalleryFooterWithContext = <
118
115
  GridIcon,
119
116
  leftElement,
120
117
  onPlayPause,
121
- onProgressDrag,
122
118
  opacity,
123
119
  openGridView,
124
120
  paused,
@@ -192,12 +188,11 @@ export const ImageGalleryFooterWithContext = <
192
188
  <ReanimatedSafeAreaView style={[container, footerStyle, { backgroundColor: white }]}>
193
189
  {photo.type === 'video' ? (
194
190
  videoControlElement ? (
195
- videoControlElement({ duration, onPlayPause, onProgressDrag, paused, progress })
191
+ videoControlElement({ duration, onPlayPause, paused, progress })
196
192
  ) : (
197
193
  <ImageGalleryVideoControl
198
194
  duration={duration}
199
195
  onPlayPause={onPlayPause}
200
- onProgressDrag={onProgressDrag}
201
196
  paused={paused}
202
197
  progress={progress}
203
198
  />
@@ -35,7 +35,7 @@ const styles = StyleSheet.create({
35
35
 
36
36
  export const ImageGalleryVideoControl: React.FC<ImageGalleryFooterVideoControlProps> = React.memo(
37
37
  (props) => {
38
- const { duration, onPlayPause, onProgressDrag, paused, progress } = props;
38
+ const { duration, onPlayPause, paused, progress } = props;
39
39
 
40
40
  const videoDuration = duration
41
41
  ? duration / 3600 >= 1
@@ -53,7 +53,7 @@ export const ImageGalleryVideoControl: React.FC<ImageGalleryFooterVideoControlPr
53
53
 
54
54
  const {
55
55
  theme: {
56
- colors: { static_black, static_white },
56
+ colors: { accent_blue, black, static_black, static_white },
57
57
  imageGallery: {
58
58
  videoControl: { durationTextStyle, roundedView, videoContainer },
59
59
  },
@@ -83,22 +83,21 @@ export const ImageGalleryVideoControl: React.FC<ImageGalleryFooterVideoControlPr
83
83
  </TouchableOpacity>
84
84
  <Text
85
85
  accessibilityLabel='Progress Duration'
86
- style={[styles.durationTextStyle, durationTextStyle, { color: static_white }]}
86
+ style={[styles.durationTextStyle, durationTextStyle, { color: black }]}
87
87
  >
88
88
  {progressDuration ? progressDuration : '00:00'}
89
89
  </Text>
90
90
  <ProgressControl
91
91
  duration={duration}
92
- filledColor={static_white}
92
+ filledColor={accent_blue}
93
93
  onPlayPause={onPlayPause}
94
- onProgressDrag={onProgressDrag}
95
94
  progress={progress}
96
95
  testID={'progress-control'}
97
96
  width={180}
98
97
  />
99
98
  <Text
100
99
  accessibilityLabel='Video Duration'
101
- style={[styles.durationTextStyle, durationTextStyle, { color: static_white }]}
100
+ style={[styles.durationTextStyle, durationTextStyle, { color: black }]}
102
101
  >
103
102
  {videoDuration ? videoDuration : '00:00'}
104
103
  </Text>
@@ -30,6 +30,7 @@ import {
30
30
  useChannelContext,
31
31
  } from '../../contexts/channelContext/ChannelContext';
32
32
  import { ChatContextValue, useChatContext } from '../../contexts/chatContext/ChatContext';
33
+ import { useDebugContext } from '../../contexts/debugContext/DebugContext';
33
34
  import {
34
35
  ImageGalleryContextValue,
35
36
  useImageGalleryContext,
@@ -936,6 +937,20 @@ const MessageListWithContext = <
936
937
  setFlatListRef(ref);
937
938
  }
938
939
  };
940
+
941
+ const debugRef = useDebugContext();
942
+
943
+ const isDebugModeEnabled = __DEV__ && debugRef && debugRef.current;
944
+
945
+ if (isDebugModeEnabled) {
946
+ if (debugRef.current.setEventType) debugRef.current.setEventType('send');
947
+ if (debugRef.current.setSendEventParams)
948
+ debugRef.current.setSendEventParams({
949
+ action: thread ? 'ThreadList' : 'Messages',
950
+ data: messageList,
951
+ });
952
+ }
953
+
939
954
  const renderListEmptyComponent = () => (
940
955
  <View style={[styles.flex, styles.invert]} testID='empty-state'>
941
956
  <EmptyStateIndicator listType='message' />
@@ -15,10 +15,10 @@ export type ProgressControlProps = {
15
15
  duration: number;
16
16
  filledColor: string;
17
17
  onPlayPause: (status?: boolean) => void;
18
- onProgressDrag: (progress: number) => void;
19
18
  progress: number;
20
19
  testID: string;
21
20
  width: number;
21
+ onProgressDrag?: (progress: number) => void;
22
22
  };
23
23
 
24
24
  const height = 2;
@@ -94,7 +94,7 @@ export const ProgressControl: React.FC<ProgressControlProps> = React.memo(
94
94
  onFinish: () => {
95
95
  translateX.value = state.value;
96
96
  const dragFinishLocationInSeconds = (state.value / width) * duration;
97
- runOnJS(onProgressDrag)(dragFinishLocationInSeconds);
97
+ if (onProgressDrag) runOnJS(onProgressDrag)(dragFinishLocationInSeconds);
98
98
  runOnJS(onPlayPause)(false);
99
99
  },
100
100
  onStart: () => {
@@ -109,9 +109,13 @@ export const ProgressControl: React.FC<ProgressControlProps> = React.memo(
109
109
  <View style={[styles.containerStyle, { backgroundColor: grey_dark, width }]}>
110
110
  <Animated.View style={[styles.innerStyle, animatedStyles]} />
111
111
 
112
- <PanGestureHandler maxPointers={1} onGestureEvent={onGestureEvent} testID={testID}>
112
+ <PanGestureHandler
113
+ maxPointers={1}
114
+ onGestureEvent={onProgressDrag ? onGestureEvent : undefined}
115
+ testID={testID}
116
+ >
113
117
  <Animated.View style={[thumbStyles]}>
114
- <ProgressControlThumb />
118
+ {onProgressDrag && <ProgressControlThumb />}
115
119
  </Animated.View>
116
120
  </PanGestureHandler>
117
121
  </View>
@@ -0,0 +1,77 @@
1
+ import React, { PropsWithChildren, useContext, useRef } from 'react';
2
+
3
+ import type { Channel, ChannelState, StreamChat } from 'stream-chat';
4
+
5
+ import type { MessageType } from '../../components/MessageList/hooks/useMessageList';
6
+ import type { DefaultStreamChatGenerics } from '../../types/types';
7
+
8
+ import { DEFAULT_BASE_CONTEXT_VALUE } from '../utils/defaultBaseContextValue';
9
+
10
+ export type DebugDataType<
11
+ StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
12
+ > =
13
+ | StreamChat<StreamChatGenerics>['user']
14
+ | {
15
+ data: Channel<StreamChatGenerics>['data'];
16
+ members: ChannelState<StreamChatGenerics>['members'];
17
+ }[]
18
+ | MessageType<StreamChatGenerics>[];
19
+
20
+ export type DebugContextValue<
21
+ StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
22
+ > = {
23
+ eventType?: string;
24
+ sendEventParams?: {
25
+ action: string;
26
+ data: DebugDataType<StreamChatGenerics>;
27
+ };
28
+ setEventType?: (data: string) => void;
29
+ setSendEventParams?: (data: { action: string; data: DebugDataType<StreamChatGenerics> }) => void;
30
+ };
31
+
32
+ export const DebugContext = React.createContext(
33
+ DEFAULT_BASE_CONTEXT_VALUE as React.MutableRefObject<DebugContextValue>,
34
+ );
35
+
36
+ export const DebugContextProvider = <
37
+ StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
38
+ >({
39
+ children,
40
+ useFlipper,
41
+ }: PropsWithChildren<{
42
+ useFlipper: () => {
43
+ updateData: (ref: React.RefObject<DebugContextValue<StreamChatGenerics>>) => void;
44
+ };
45
+ }>) => {
46
+ const debugRef = useRef<DebugContextValue<StreamChatGenerics>>({
47
+ eventType: undefined,
48
+ sendEventParams: undefined,
49
+ });
50
+
51
+ const { updateData } = useFlipper();
52
+
53
+ const ref = useRef<DebugContextValue<StreamChatGenerics>>({
54
+ setEventType: (data: string) => {
55
+ debugRef.current.eventType = data;
56
+ updateData(debugRef);
57
+ },
58
+ setSendEventParams: (data: { action: string; data: DebugDataType<StreamChatGenerics> }) => {
59
+ debugRef.current.sendEventParams = data;
60
+ updateData(debugRef);
61
+ },
62
+ });
63
+
64
+ return (
65
+ <DebugContext.Provider value={ref as unknown as React.MutableRefObject<DebugContextValue>}>
66
+ {children}
67
+ </DebugContext.Provider>
68
+ );
69
+ };
70
+
71
+ export const useDebugContext = () => {
72
+ const contextValue = useContext(
73
+ DebugContext,
74
+ ) as unknown as React.MutableRefObject<DebugContextValue>;
75
+
76
+ return contextValue;
77
+ };
@@ -2,6 +2,7 @@ export * from './attachmentPickerContext/AttachmentPickerContext';
2
2
  export * from './channelContext/ChannelContext';
3
3
  export * from './channelsContext/ChannelsContext';
4
4
  export * from './chatContext/ChatContext';
5
+ export * from './debugContext/DebugContext';
5
6
  export * from './imageGalleryContext/ImageGalleryContext';
6
7
  export * from './keyboardContext/KeyboardContext';
7
8
  export * from './messageContext/MessageContext';
package/src/native.ts CHANGED
@@ -164,9 +164,9 @@ export type SoundType = {
164
164
  export let Sound: SoundType;
165
165
 
166
166
  export type VideoProgressData = {
167
- currentTime?: number;
167
+ currentTime: number;
168
+ seekableDuration: number;
168
169
  playableDuration?: number;
169
- seekableDuration?: number;
170
170
  };
171
171
 
172
172
  export type VideoPayloadData = {
@@ -196,6 +196,7 @@ export type VideoType = {
196
196
  onPlaybackStatusUpdate?: (playbackStatus: PlaybackStatus) => void;
197
197
  onProgress?: (data: VideoProgressData) => void;
198
198
  onReadyForDisplay?: () => void;
199
+ repeat?: boolean;
199
200
  replayAsync?: () => void;
200
201
  resizeMode?: string;
201
202
  seek?: (progress: number) => void;
package/src/version.json CHANGED
@@ -1,3 +1,3 @@
1
1
  {
2
- "version": "5.1.0-beta.1"
2
+ "version": "5.2.0-beta.1"
3
3
  }