stream-chat-react-native-core 7.0.1-beta.4 → 7.0.1-beta.6

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 (24) hide show
  1. package/lib/commonjs/components/Attachment/FileAttachmentGroup.js +9 -0
  2. package/lib/commonjs/components/Attachment/FileAttachmentGroup.js.map +1 -1
  3. package/lib/commonjs/components/Message/Message.js +18 -10
  4. package/lib/commonjs/components/Message/Message.js.map +1 -1
  5. package/lib/commonjs/components/Message/MessageSimple/MessageSimple.js +21 -10
  6. package/lib/commonjs/components/Message/MessageSimple/MessageSimple.js.map +1 -1
  7. package/lib/commonjs/version.json +1 -1
  8. package/lib/module/components/Attachment/FileAttachmentGroup.js +9 -0
  9. package/lib/module/components/Attachment/FileAttachmentGroup.js.map +1 -1
  10. package/lib/module/components/Message/Message.js +18 -10
  11. package/lib/module/components/Message/Message.js.map +1 -1
  12. package/lib/module/components/Message/MessageSimple/MessageSimple.js +21 -10
  13. package/lib/module/components/Message/MessageSimple/MessageSimple.js.map +1 -1
  14. package/lib/module/version.json +1 -1
  15. package/lib/typescript/components/Attachment/FileAttachmentGroup.d.ts.map +1 -1
  16. package/lib/typescript/components/Message/Message.d.ts +1 -1
  17. package/lib/typescript/components/Message/Message.d.ts.map +1 -1
  18. package/lib/typescript/components/Message/MessageSimple/MessageSimple.d.ts +10 -1
  19. package/lib/typescript/components/Message/MessageSimple/MessageSimple.d.ts.map +1 -1
  20. package/package.json +1 -1
  21. package/src/components/Attachment/FileAttachmentGroup.tsx +7 -1
  22. package/src/components/Message/Message.tsx +17 -5
  23. package/src/components/Message/MessageSimple/MessageSimple.tsx +38 -7
  24. package/src/version.json +1 -1
@@ -135,9 +135,12 @@ export type MessagePropsWithContext = Pick<
135
135
  > &
136
136
  Pick<KeyboardContextValue, 'dismissKeyboard'> &
137
137
  Partial<
138
- Omit<MessageContextValue, 'groupStyles' | 'handleReaction' | 'message' | 'isMessageAIGenerated'>
138
+ Omit<
139
+ MessageContextValue,
140
+ 'groupStyles' | 'handleReaction' | 'message' | 'isMessageAIGenerated' | 'readBy'
141
+ >
139
142
  > &
140
- Pick<MessageContextValue, 'groupStyles' | 'message' | 'isMessageAIGenerated'> &
143
+ Pick<MessageContextValue, 'groupStyles' | 'message' | 'isMessageAIGenerated' | 'readBy'> &
141
144
  Pick<
142
145
  MessagesContextValue,
143
146
  | 'sendReaction'
@@ -262,8 +265,8 @@ const MessageWithContext = (props: MessagePropsWithContext) => {
262
265
  t,
263
266
  threadList = false,
264
267
  updateMessage,
268
+ readBy,
265
269
  } = props;
266
- const { read } = useChannelContext();
267
270
  const isMessageAIGenerated = messagesContext.isMessageAIGenerated;
268
271
  const isAIGenerated = useMemo(
269
272
  () => isMessageAIGenerated(message),
@@ -278,7 +281,6 @@ const MessageWithContext = (props: MessagePropsWithContext) => {
278
281
  screenPadding,
279
282
  },
280
283
  } = useTheme();
281
- const readBy = useMemo(() => getReadState(message, read), [message, read]);
282
284
 
283
285
  const showMessageOverlay = async (showMessageReactions = false, selectedReaction?: string) => {
284
286
  await dismissKeyboard();
@@ -759,6 +761,7 @@ const areEqual = (prevProps: MessagePropsWithContext, nextProps: MessagePropsWit
759
761
  message: prevMessage,
760
762
  messagesContext: prevMessagesContext,
761
763
  showUnreadUnderlay: prevShowUnreadUnderlay,
764
+ readBy: prevReadBy,
762
765
  t: prevT,
763
766
  } = prevProps;
764
767
  const {
@@ -771,9 +774,15 @@ const areEqual = (prevProps: MessagePropsWithContext, nextProps: MessagePropsWit
771
774
  message: nextMessage,
772
775
  messagesContext: nextMessagesContext,
773
776
  showUnreadUnderlay: nextShowUnreadUnderlay,
777
+ readBy: nextReadBy,
774
778
  t: nextT,
775
779
  } = nextProps;
776
780
 
781
+ const readByEqual = prevReadBy === nextReadBy;
782
+ if (!readByEqual) {
783
+ return false;
784
+ }
785
+
777
786
  const membersEqual = Object.keys(prevMembers).length === Object.keys(nextMembers).length;
778
787
  if (!membersEqual) {
779
788
  return false;
@@ -925,12 +934,14 @@ export type MessageProps = Partial<
925
934
  * @example ./Message.md
926
935
  */
927
936
  export const Message = (props: MessageProps) => {
928
- const { channel, enforceUniqueReaction, members } = useChannelContext();
937
+ const { message } = props;
938
+ const { channel, enforceUniqueReaction, members, read } = useChannelContext();
929
939
  const chatContext = useChatContext();
930
940
  const { dismissKeyboard } = useKeyboardContext();
931
941
  const messagesContext = useMessagesContext();
932
942
  const { openThread } = useThreadContext();
933
943
  const { t } = useTranslationContext();
944
+ const readBy = useMemo(() => getReadState(message, read), [message, read]);
934
945
 
935
946
  return (
936
947
  <MemoizedMessage
@@ -943,6 +954,7 @@ export const Message = (props: MessageProps) => {
943
954
  members,
944
955
  messagesContext,
945
956
  openThread,
957
+ readBy,
946
958
  t,
947
959
  }}
948
960
  {...props}
@@ -90,7 +90,16 @@ export type MessageSimplePropsWithContext = Pick<
90
90
  | 'reactionListPosition'
91
91
  | 'ReactionListTop'
92
92
  | 'setQuotedMessageState'
93
- >;
93
+ > & {
94
+ /**
95
+ * Will determine whether the swipeable wrapper is always rendered for each
96
+ * message. If set to false, the animated wrapper will be rendered only when
97
+ * a swiping gesture is active and not otherwise.
98
+ * Since stateful components would lose their state if we remount them while
99
+ * an animation is happening, this should always be set to true in those instances.
100
+ */
101
+ shouldRenderSwipeableWrapper: boolean;
102
+ };
94
103
 
95
104
  const MessageSimpleWithContext = (props: MessageSimplePropsWithContext) => {
96
105
  const [messageContentWidth, setMessageContentWidth] = useState(0);
@@ -123,6 +132,7 @@ const MessageSimpleWithContext = (props: MessageSimplePropsWithContext) => {
123
132
  ReactionListTop,
124
133
  setQuotedMessageState,
125
134
  showMessageStatus,
135
+ shouldRenderSwipeableWrapper,
126
136
  } = props;
127
137
 
128
138
  const {
@@ -202,7 +212,9 @@ const MessageSimpleWithContext = (props: MessageSimplePropsWithContext) => {
202
212
  const translateX = useSharedValue(0);
203
213
  const touchStart = useSharedValue<{ x: number; y: number } | null>(null);
204
214
  const isSwiping = useSharedValue<boolean>(false);
205
- const [isBeingSwiped, setIsBeingSwiped] = useState<boolean>(false);
215
+ const [shouldRenderAnimatedWrapper, setShouldRenderAnimatedWrapper] = useState<boolean>(
216
+ shouldRenderSwipeableWrapper,
217
+ );
206
218
 
207
219
  const onSwipeToReply = useCallback(() => {
208
220
  clearQuotedMessageState();
@@ -233,7 +245,9 @@ const MessageSimpleWithContext = (props: MessageSimplePropsWithContext) => {
233
245
  if (isHorizontalPanning) {
234
246
  state.activate();
235
247
  isSwiping.value = true;
236
- runOnJS(setIsBeingSwiped)(isSwiping.value);
248
+ if (!shouldRenderSwipeableWrapper) {
249
+ runOnJS(setShouldRenderAnimatedWrapper)(isSwiping.value);
250
+ }
237
251
  } else {
238
252
  state.fail();
239
253
  }
@@ -263,11 +277,21 @@ const MessageSimpleWithContext = (props: MessageSimplePropsWithContext) => {
263
277
  stiffness: 1,
264
278
  },
265
279
  () => {
266
- runOnJS(setIsBeingSwiped)(isSwiping.value);
280
+ if (!shouldRenderSwipeableWrapper) {
281
+ runOnJS(setShouldRenderAnimatedWrapper)(isSwiping.value);
282
+ }
267
283
  },
268
284
  );
269
285
  }),
270
- [isSwiping, messageSwipeToReplyHitSlop, onSwipeToReply, touchStart, translateX, triggerHaptic],
286
+ [
287
+ isSwiping,
288
+ messageSwipeToReplyHitSlop,
289
+ onSwipeToReply,
290
+ touchStart,
291
+ translateX,
292
+ triggerHaptic,
293
+ shouldRenderSwipeableWrapper,
294
+ ],
271
295
  );
272
296
 
273
297
  const messageBubbleAnimatedStyle = useAnimatedStyle(
@@ -326,7 +350,7 @@ const MessageSimpleWithContext = (props: MessageSimplePropsWithContext) => {
326
350
  () => (
327
351
  <GestureDetector gesture={swipeGesture}>
328
352
  <View hitSlop={messageSwipeToReplyHitSlop} style={[styles.contentWrapper, contentWrapper]}>
329
- {isBeingSwiped ? (
353
+ {shouldRenderAnimatedWrapper ? (
330
354
  <>
331
355
  <AnimatedWrapper
332
356
  style={[
@@ -350,7 +374,7 @@ const MessageSimpleWithContext = (props: MessageSimplePropsWithContext) => {
350
374
  [
351
375
  MessageSwipeContent,
352
376
  contentWrapper,
353
- isBeingSwiped,
377
+ shouldRenderAnimatedWrapper,
354
378
  messageBubbleAnimatedStyle,
355
379
  messageSwipeToReplyHitSlop,
356
380
  renderMessageBubble,
@@ -586,6 +610,7 @@ export const MessageSimple = (props: MessageSimpleProps) => {
586
610
  onlyEmojis,
587
611
  otherAttachments,
588
612
  showMessageStatus,
613
+ isMessageAIGenerated,
589
614
  } = useMessageContext();
590
615
  const {
591
616
  clearQuotedMessageState,
@@ -607,6 +632,11 @@ export const MessageSimple = (props: MessageSimpleProps) => {
607
632
  ReactionListTop,
608
633
  setQuotedMessageState,
609
634
  } = useMessagesContext();
635
+ const isAIGenerated = useMemo(
636
+ () => isMessageAIGenerated(message),
637
+ [message, isMessageAIGenerated],
638
+ );
639
+ const shouldRenderSwipeableWrapper = (message?.attachments || []).length > 0 || isAIGenerated;
610
640
 
611
641
  return (
612
642
  <MemoizedMessageSimple
@@ -639,6 +669,7 @@ export const MessageSimple = (props: MessageSimpleProps) => {
639
669
  reactionListPosition,
640
670
  ReactionListTop,
641
671
  setQuotedMessageState,
672
+ shouldRenderSwipeableWrapper,
642
673
  showMessageStatus,
643
674
  }}
644
675
  {...props}
package/src/version.json CHANGED
@@ -1,3 +1,3 @@
1
1
  {
2
- "version": "7.0.1-beta.4"
2
+ "version": "7.0.1-beta.6"
3
3
  }