stream-chat-react-native-core 5.0.0-offline-support.6 → 5.0.0-offline-support.9

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 (57) hide show
  1. package/lib/commonjs/components/Attachment/Gallery.js +5 -5
  2. package/lib/commonjs/components/Attachment/Gallery.js.map +1 -1
  3. package/lib/commonjs/components/Attachment/VideoThumbnail.js +18 -16
  4. package/lib/commonjs/components/Attachment/VideoThumbnail.js.map +1 -1
  5. package/lib/commonjs/components/ChannelList/hooks/listeners/handleEventToSyncDB.js +2 -2
  6. package/lib/commonjs/components/ChannelList/hooks/listeners/handleEventToSyncDB.js.map +1 -1
  7. package/lib/commonjs/components/ChannelPreview/ChannelPreview.js +15 -8
  8. package/lib/commonjs/components/ChannelPreview/ChannelPreview.js.map +1 -1
  9. package/lib/commonjs/components/ImageGallery/components/ImageGalleryFooter.js +3 -2
  10. package/lib/commonjs/components/ImageGallery/components/ImageGalleryFooter.js.map +1 -1
  11. package/lib/commonjs/components/MessageInput/FileUploadPreview.js +4 -2
  12. package/lib/commonjs/components/MessageInput/FileUploadPreview.js.map +1 -1
  13. package/lib/commonjs/components/MessageInput/ImageUploadPreview.js +4 -1
  14. package/lib/commonjs/components/MessageInput/ImageUploadPreview.js.map +1 -1
  15. package/lib/commonjs/components/Reply/Reply.js +21 -13
  16. package/lib/commonjs/components/Reply/Reply.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/themeContext/utils/theme.js +5 -1
  20. package/lib/commonjs/contexts/themeContext/utils/theme.js.map +1 -1
  21. package/lib/commonjs/version.json +1 -1
  22. package/lib/module/components/Attachment/Gallery.js +5 -5
  23. package/lib/module/components/Attachment/Gallery.js.map +1 -1
  24. package/lib/module/components/Attachment/VideoThumbnail.js +18 -16
  25. package/lib/module/components/Attachment/VideoThumbnail.js.map +1 -1
  26. package/lib/module/components/ChannelList/hooks/listeners/handleEventToSyncDB.js +2 -2
  27. package/lib/module/components/ChannelList/hooks/listeners/handleEventToSyncDB.js.map +1 -1
  28. package/lib/module/components/ChannelPreview/ChannelPreview.js +15 -8
  29. package/lib/module/components/ChannelPreview/ChannelPreview.js.map +1 -1
  30. package/lib/module/components/ImageGallery/components/ImageGalleryFooter.js +3 -2
  31. package/lib/module/components/ImageGallery/components/ImageGalleryFooter.js.map +1 -1
  32. package/lib/module/components/MessageInput/FileUploadPreview.js +4 -2
  33. package/lib/module/components/MessageInput/FileUploadPreview.js.map +1 -1
  34. package/lib/module/components/MessageInput/ImageUploadPreview.js +4 -1
  35. package/lib/module/components/MessageInput/ImageUploadPreview.js.map +1 -1
  36. package/lib/module/components/Reply/Reply.js +21 -13
  37. package/lib/module/components/Reply/Reply.js.map +1 -1
  38. package/lib/module/contexts/messageInputContext/MessageInputContext.js +2 -2
  39. package/lib/module/contexts/messageInputContext/MessageInputContext.js.map +1 -1
  40. package/lib/module/contexts/themeContext/utils/theme.js +5 -1
  41. package/lib/module/contexts/themeContext/utils/theme.js.map +1 -1
  42. package/lib/module/version.json +1 -1
  43. package/lib/typescript/components/Attachment/VideoThumbnail.d.ts +4 -2
  44. package/lib/typescript/contexts/themeContext/utils/theme.d.ts +4 -0
  45. package/package.json +1 -1
  46. package/src/components/Attachment/Gallery.tsx +5 -5
  47. package/src/components/Attachment/VideoThumbnail.tsx +14 -4
  48. package/src/components/ChannelList/hooks/listeners/handleEventToSyncDB.ts +2 -2
  49. package/src/components/ChannelPreview/ChannelPreview.tsx +12 -10
  50. package/src/components/ImageGallery/components/ImageGalleryFooter.tsx +2 -2
  51. package/src/components/MessageInput/FileUploadPreview.tsx +3 -3
  52. package/src/components/MessageInput/ImageUploadPreview.tsx +2 -2
  53. package/src/components/Reply/Reply.tsx +14 -2
  54. package/src/contexts/messageInputContext/MessageInputContext.tsx +7 -7
  55. package/src/contexts/messageInputContext/__tests__/__snapshots__/sendMessage.test.tsx.snap +3 -3
  56. package/src/contexts/themeContext/utils/theme.ts +8 -0
  57. package/src/version.json +1 -1
@@ -525,6 +525,10 @@ export declare type Theme = {
525
525
  markdownStyles: MarkdownStyle;
526
526
  messageContainer: ViewStyle;
527
527
  textContainer: ViewStyle;
528
+ videoThumbnail: {
529
+ container: ViewStyle;
530
+ image: ImageStyle;
531
+ };
528
532
  };
529
533
  screenPadding: number;
530
534
  spinner: ViewStyle;
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.0.0-offline-support.6",
4
+ "version": "5.0.0-offline-support.9",
5
5
  "author": {
6
6
  "company": "Stream.io Inc",
7
7
  "name": "Stream.io Inc"
@@ -58,16 +58,16 @@ const styles = StyleSheet.create({
58
58
  padding: 1,
59
59
  },
60
60
  imageContainerStyle: { alignItems: 'center', flex: 1, justifyContent: 'center' },
61
+ imageLoadingErrorIndicatorStyle: {
62
+ bottom: 4,
63
+ left: 4,
64
+ position: 'absolute',
65
+ },
61
66
  imageLoadingIndicatorStyle: {
62
67
  alignItems: 'center',
63
68
  justifyContent: 'center',
64
69
  position: 'absolute',
65
70
  },
66
- imageLoadingErrorIndicatorStyle: {
67
- position: 'absolute',
68
- bottom: 4,
69
- left: 4,
70
- },
71
71
  moreImagesContainer: {
72
72
  alignItems: 'center',
73
73
  justifyContent: 'center',
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { ImageBackground, StyleSheet, View, ViewProps } from 'react-native';
2
+ import { ImageBackground, ImageStyle, StyleProp, StyleSheet, View, ViewStyle } from 'react-native';
3
3
 
4
4
  import { useTheme } from '../../contexts/themeContext/ThemeContext';
5
5
  import { Play } from '../../icons';
@@ -18,13 +18,23 @@ const styles = StyleSheet.create({
18
18
  backgroundColor: '#fff',
19
19
  borderRadius: 50,
20
20
  display: 'flex',
21
+ elevation: 6,
21
22
  height: 36,
22
23
  justifyContent: 'center',
24
+ shadowColor: '#000',
25
+ shadowOffset: {
26
+ height: 3,
27
+ width: 0,
28
+ },
29
+ shadowOpacity: 0.27,
30
+ shadowRadius: 4.65,
23
31
  width: 36,
24
32
  },
25
33
  });
26
34
 
27
- export type VideoThumbnailProps = ViewProps & {
35
+ export type VideoThumbnailProps = {
36
+ imageStyle?: StyleProp<ImageStyle>;
37
+ style?: StyleProp<ViewStyle>;
28
38
  thumb_url?: string;
29
39
  };
30
40
 
@@ -36,12 +46,12 @@ export const VideoThumbnail: React.FC<VideoThumbnailProps> = (props) => {
36
46
  },
37
47
  },
38
48
  } = useTheme();
39
- const { style, thumb_url, ...rest } = props;
49
+ const { imageStyle, style, thumb_url } = props;
40
50
  return (
41
51
  <ImageBackground
42
52
  accessibilityLabel='video-thumbnail'
53
+ imageStyle={imageStyle}
43
54
  source={{ uri: thumb_url }}
44
- {...rest}
45
55
  style={[styles.container, container, style]}
46
56
  >
47
57
  <View style={[styles.roundedView, roundedView]}>
@@ -30,7 +30,7 @@ export const handleEventToSyncDB = (event: Event, flush?: boolean) => {
30
30
  }
31
31
 
32
32
  if (type === 'message.new') {
33
- if (event.message && !event.message.parent_id) {
33
+ if (event.message && (!event.message.parent_id || event.message.show_in_channel)) {
34
34
  return upsertMessages({
35
35
  flush,
36
36
  messages: [event.message],
@@ -53,7 +53,7 @@ export const handleEventToSyncDB = (event: Event, flush?: boolean) => {
53
53
  if (event.message && event.reaction) {
54
54
  // We update the entire message to make sure we also update
55
55
  // reaction_counts.
56
- updateMessage({
56
+ return updateMessage({
57
57
  flush,
58
58
  message: event.message,
59
59
  });
@@ -69,25 +69,27 @@ const ChannelPreviewWithContext = <
69
69
  }, [channelLastMessageString]);
70
70
 
71
71
  useEffect(() => {
72
- const handleEvent = (event: Event<StreamChatGenerics>) => {
73
- if (event.message) {
72
+ const handleNewMessageEvent = (event: Event<StreamChatGenerics>) => {
73
+ const message = event.message;
74
+ if (message && (!message.parent_id || message.show_in_channel)) {
74
75
  setLastMessage(event.message);
76
+ setUnread(channel.countUnread());
75
77
  }
78
+ };
76
79
 
77
- if (event.type === 'message.new') {
78
- setUnread(channel.countUnread());
80
+ const handleUpdatedOrDeletedMessage = (event: Event<StreamChatGenerics>) => {
81
+ if (event.message?.id === lastMessage?.id) {
82
+ setLastMessage(event.message);
79
83
  }
80
84
  };
81
85
 
82
86
  const listeners = [
83
- channel.on('message.new', handleEvent),
84
- channel.on('message.updated', handleEvent),
85
- channel.on('message.deleted', handleEvent),
87
+ channel.on('message.new', handleNewMessageEvent),
88
+ channel.on('message.updated', handleUpdatedOrDeletedMessage),
89
+ channel.on('message.deleted', handleUpdatedOrDeletedMessage),
86
90
  ];
87
91
 
88
- return () => {
89
- listeners.forEach((l) => l.unsubscribe());
90
- };
92
+ return () => listeners.forEach((l) => l.unsubscribe());
91
93
  }, []);
92
94
 
93
95
  useEffect(() => {
@@ -172,7 +172,7 @@ export const ImageGalleryFooterWithContext = <
172
172
  fromUrl: photo.uri,
173
173
  });
174
174
  // `image/jpeg` is added for the case where the mime_type isn't available for a file/image
175
- await shareImage({ type: photo.mime_type ?? 'image/jpeg', url: localFile });
175
+ await shareImage({ type: photo.mime_type || 'image/jpeg', url: localFile });
176
176
  await deleteFile({ uri: localFile });
177
177
  } catch (error) {
178
178
  console.log(error);
@@ -206,7 +206,7 @@ export const ImageGalleryFooterWithContext = <
206
206
  ) : (
207
207
  <TouchableOpacity disabled={shareMenuOpen} onPress={share}>
208
208
  <View style={[styles.leftContainer, leftContainer]}>
209
- {ShareIcon ? ShareIcon : <ShareIconDefault />}
209
+ {ShareIcon ? ShareIcon : <ShareIconDefault pathFill={black} />}
210
210
  </View>
211
211
  </TouchableOpacity>
212
212
  )}
@@ -132,7 +132,7 @@ const FileUploadPreviewWithContext = <
132
132
 
133
133
  const {
134
134
  theme: {
135
- colors: { black, grey_whisper, overlay },
135
+ colors: { black, grey_dark, grey_gainsboro, grey_whisper },
136
136
  messageInput: {
137
137
  fileUploadPreview: {
138
138
  dismiss,
@@ -209,10 +209,10 @@ const FileUploadPreviewWithContext = <
209
209
  onPress={() => {
210
210
  removeFile(item.id);
211
211
  }}
212
- style={[styles.dismiss, { backgroundColor: overlay }, dismiss]}
212
+ style={[styles.dismiss, { backgroundColor: grey_gainsboro }, dismiss]}
213
213
  testID='remove-file-upload-preview'
214
214
  >
215
- <Close />
215
+ <Close pathFill={grey_dark} />
216
216
  </TouchableOpacity>
217
217
  </>
218
218
  );
@@ -87,7 +87,7 @@ const ImageUploadPreviewWithContext = <
87
87
 
88
88
  const {
89
89
  theme: {
90
- colors: { overlay },
90
+ colors: { overlay, white },
91
91
  messageInput: {
92
92
  imageUploadPreview: { dismiss, flatList, itemContainer, upload },
93
93
  },
@@ -147,7 +147,7 @@ const ImageUploadPreviewWithContext = <
147
147
  style={[styles.dismiss, { backgroundColor: overlay }, dismiss]}
148
148
  testID='remove-image-upload-preview'
149
149
  >
150
- <Close />
150
+ <Close pathFill={white} />
151
151
  </TouchableOpacity>
152
152
  <UnsupportedImageTypeIndicator indicatorType={indicatorType} />
153
153
  </View>
@@ -53,13 +53,16 @@ const styles = StyleSheet.create({
53
53
  },
54
54
  text: { fontSize: 12 },
55
55
  textContainer: { maxWidth: undefined, paddingHorizontal: 8 },
56
- videoAttachment: {
56
+ videoThumbnailContainerStyle: {
57
57
  borderRadius: 8,
58
58
  height: 50,
59
59
  marginLeft: 8,
60
60
  marginVertical: 8,
61
61
  width: 50,
62
62
  },
63
+ videoThumbnailImageStyle: {
64
+ borderRadius: 10,
65
+ },
63
66
  });
64
67
 
65
68
  type ReplyPropsWithContext<
@@ -140,6 +143,10 @@ const ReplyWithContext = <
140
143
  markdownStyles,
141
144
  messageContainer,
142
145
  textContainer,
146
+ videoThumbnail: {
147
+ container: videoThumbnailContainerStyle,
148
+ image: videoThumbnailImageStyle,
149
+ },
143
150
  },
144
151
  },
145
152
  } = useTheme();
@@ -153,6 +160,7 @@ const ReplyWithContext = <
153
160
  !error &&
154
161
  lastAttachment &&
155
162
  messageType !== 'file' &&
163
+ messageType !== 'video' &&
156
164
  (lastAttachment.image_url || lastAttachment.thumb_url || lastAttachment.og_scrape_url);
157
165
 
158
166
  const onlyEmojis = !lastAttachment && !!quotedMessage.text && emojiRegex.test(quotedMessage.text);
@@ -207,7 +215,11 @@ const ReplyWithContext = <
207
215
  ) : null
208
216
  ) : null}
209
217
  {messageType === 'video' && !lastAttachment.og_scrape_url ? (
210
- <VideoThumbnail style={[styles.videoAttachment]} />
218
+ <VideoThumbnail
219
+ imageStyle={[styles.videoThumbnailImageStyle, videoThumbnailImageStyle]}
220
+ style={[styles.videoThumbnailContainerStyle, videoThumbnailContainerStyle]}
221
+ thumb_url={lastAttachment.thumb_url}
222
+ />
211
223
  ) : null}
212
224
  <MessageTextContainer<StreamChatGenerics>
213
225
  markdownStyles={
@@ -676,11 +676,11 @@ export const MessageInputProvider = <
676
676
  attachments.push({
677
677
  fallback: image.file.name,
678
678
  image_url: image.url,
679
- mime_type,
679
+ mime_type: mime_type ? mime_type : undefined,
680
680
  original_height: image.height,
681
681
  original_width: image.width,
682
682
  type: 'image',
683
- } as Attachment<StreamChatGenerics>);
683
+ });
684
684
  }
685
685
  }
686
686
 
@@ -700,9 +700,9 @@ export const MessageInputProvider = <
700
700
  attachments.push({
701
701
  fallback: file.file.name,
702
702
  image_url: file.url,
703
- mime_type,
703
+ mime_type: mime_type ? mime_type : undefined,
704
704
  type: 'image',
705
- } as Attachment<StreamChatGenerics>);
705
+ });
706
706
  } else if (file.file.type?.startsWith('audio/')) {
707
707
  attachments.push({
708
708
  asset_url: file.url,
@@ -711,7 +711,7 @@ export const MessageInputProvider = <
711
711
  mime_type: file.file.type,
712
712
  title: file.file.name,
713
713
  type: 'audio',
714
- } as Attachment<StreamChatGenerics>);
714
+ });
715
715
  } else if (file.file.type?.startsWith('video/')) {
716
716
  attachments.push({
717
717
  asset_url: file.url,
@@ -721,7 +721,7 @@ export const MessageInputProvider = <
721
721
  thumb_url: file.thumb_url,
722
722
  title: file.file.name,
723
723
  type: 'video',
724
- } as Attachment<StreamChatGenerics>);
724
+ });
725
725
  } else {
726
726
  attachments.push({
727
727
  asset_url: file.url,
@@ -729,7 +729,7 @@ export const MessageInputProvider = <
729
729
  mime_type: file.file.type,
730
730
  title: file.file.name,
731
731
  type: 'file',
732
- } as Attachment<StreamChatGenerics>);
732
+ });
733
733
  }
734
734
  }
735
735
  }
@@ -6,7 +6,7 @@ Object {
6
6
  Object {
7
7
  "fallback": undefined,
8
8
  "image_url": undefined,
9
- "mime_type": false,
9
+ "mime_type": undefined,
10
10
  "original_height": undefined,
11
11
  "original_width": undefined,
12
12
  "type": "image",
@@ -87,7 +87,7 @@ Object {
87
87
  Object {
88
88
  "fallback": undefined,
89
89
  "image_url": undefined,
90
- "mime_type": false,
90
+ "mime_type": undefined,
91
91
  "original_height": undefined,
92
92
  "original_width": undefined,
93
93
  "type": "image",
@@ -95,7 +95,7 @@ Object {
95
95
  Object {
96
96
  "fallback": undefined,
97
97
  "image_url": undefined,
98
- "mime_type": false,
98
+ "mime_type": undefined,
99
99
  "original_height": undefined,
100
100
  "original_width": undefined,
101
101
  "type": "image",
@@ -529,6 +529,10 @@ export type Theme = {
529
529
  markdownStyles: MarkdownStyle;
530
530
  messageContainer: ViewStyle;
531
531
  textContainer: ViewStyle;
532
+ videoThumbnail: {
533
+ container: ViewStyle;
534
+ image: ImageStyle;
535
+ };
532
536
  };
533
537
  screenPadding: number;
534
538
  spinner: ViewStyle;
@@ -1058,6 +1062,10 @@ export const defaultTheme: Theme = {
1058
1062
  markdownStyles: {},
1059
1063
  messageContainer: {},
1060
1064
  textContainer: {},
1065
+ videoThumbnail: {
1066
+ container: {},
1067
+ image: {},
1068
+ },
1061
1069
  },
1062
1070
  screenPadding: 8,
1063
1071
  spinner: {},
package/src/version.json CHANGED
@@ -1,3 +1,3 @@
1
1
  {
2
- "version": "5.0.0-offline-support.6"
2
+ "version": "5.0.0-offline-support.9"
3
3
  }