stream-chat-react-native-core 4.3.0-beta.4 → 4.3.1-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.
- package/lib/commonjs/components/Attachment/Attachment.js +21 -12
- package/lib/commonjs/components/Attachment/Attachment.js.map +1 -1
- package/lib/commonjs/components/Channel/Channel.js +15 -13
- package/lib/commonjs/components/Channel/Channel.js.map +1 -1
- package/lib/commonjs/components/Channel/hooks/useCreateMessagesContext.js +2 -0
- package/lib/commonjs/components/Channel/hooks/useCreateMessagesContext.js.map +1 -1
- package/lib/commonjs/components/ImageGallery/ImageGallery.js +21 -20
- package/lib/commonjs/components/ImageGallery/ImageGallery.js.map +1 -1
- package/lib/commonjs/components/Message/Message.js +11 -8
- package/lib/commonjs/components/Message/Message.js.map +1 -1
- package/lib/commonjs/components/Message/MessageSimple/MessageContent.js +28 -23
- package/lib/commonjs/components/Message/MessageSimple/MessageContent.js.map +1 -1
- package/lib/commonjs/components/Message/MessageSimple/MessageSimple.js +7 -6
- package/lib/commonjs/components/Message/MessageSimple/MessageSimple.js.map +1 -1
- package/lib/commonjs/contexts/messagesContext/MessagesContext.js +2 -2
- package/lib/commonjs/contexts/messagesContext/MessagesContext.js.map +1 -1
- package/lib/commonjs/contexts/overlayContext/OverlayContext.js.map +1 -1
- package/lib/commonjs/contexts/overlayContext/OverlayProvider.js +1 -2
- package/lib/commonjs/contexts/overlayContext/OverlayProvider.js.map +1 -1
- package/lib/commonjs/version.json +1 -1
- package/lib/module/components/Attachment/Attachment.js +21 -12
- package/lib/module/components/Attachment/Attachment.js.map +1 -1
- package/lib/module/components/Channel/Channel.js +15 -13
- package/lib/module/components/Channel/Channel.js.map +1 -1
- package/lib/module/components/Channel/hooks/useCreateMessagesContext.js +2 -0
- package/lib/module/components/Channel/hooks/useCreateMessagesContext.js.map +1 -1
- package/lib/module/components/ImageGallery/ImageGallery.js +21 -20
- package/lib/module/components/ImageGallery/ImageGallery.js.map +1 -1
- package/lib/module/components/Message/Message.js +11 -8
- package/lib/module/components/Message/Message.js.map +1 -1
- package/lib/module/components/Message/MessageSimple/MessageContent.js +28 -23
- package/lib/module/components/Message/MessageSimple/MessageContent.js.map +1 -1
- package/lib/module/components/Message/MessageSimple/MessageSimple.js +7 -6
- package/lib/module/components/Message/MessageSimple/MessageSimple.js.map +1 -1
- package/lib/module/contexts/messagesContext/MessagesContext.js +2 -2
- package/lib/module/contexts/messagesContext/MessagesContext.js.map +1 -1
- package/lib/module/contexts/overlayContext/OverlayContext.js.map +1 -1
- package/lib/module/contexts/overlayContext/OverlayProvider.js +1 -2
- package/lib/module/contexts/overlayContext/OverlayProvider.js.map +1 -1
- package/lib/module/version.json +1 -1
- package/lib/typescript/components/Attachment/Attachment.d.ts +2 -2
- package/lib/typescript/components/Channel/Channel.d.ts +1 -1
- package/lib/typescript/components/Channel/hooks/useCreateMessagesContext.d.ts +1 -1
- package/lib/typescript/components/ImageGallery/ImageGallery.d.ts +1 -7
- package/lib/typescript/components/Message/Message.d.ts +1 -1
- package/lib/typescript/components/Message/MessageSimple/MessageContent.d.ts +1 -1
- package/lib/typescript/contexts/messagesContext/MessagesContext.d.ts +2 -0
- package/lib/typescript/contexts/overlayContext/OverlayContext.d.ts +1 -1
- package/package.json +1 -1
- package/src/components/Attachment/Attachment.tsx +11 -2
- package/src/components/Channel/Channel.tsx +3 -0
- package/src/components/Channel/__tests__/isAttachmentEqualHandler.test.js +100 -0
- package/src/components/Channel/hooks/useCreateMessagesContext.ts +2 -0
- package/src/components/ImageGallery/ImageGallery.tsx +9 -8
- package/src/components/Message/Message.tsx +19 -8
- package/src/components/Message/MessageSimple/MessageContent.tsx +23 -14
- package/src/components/Message/MessageSimple/MessageSimple.tsx +14 -11
- package/src/contexts/messagesContext/MessagesContext.tsx +5 -0
- package/src/contexts/overlayContext/OverlayContext.tsx +1 -1
- package/src/contexts/overlayContext/OverlayProvider.tsx +1 -1
- package/src/version.json +1 -1
|
@@ -2,13 +2,13 @@ import type { Attachment as AttachmentType } from 'stream-chat';
|
|
|
2
2
|
import { MessagesContextValue } from '../../contexts/messagesContext/MessagesContext';
|
|
3
3
|
import type { DefaultStreamChatGenerics } from '../../types/types';
|
|
4
4
|
export declare type ActionHandler = (name: string, value: string) => void;
|
|
5
|
-
export declare type AttachmentPropsWithContext<StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics> = Pick<MessagesContextValue<StreamChatGenerics>, 'AttachmentActions' | 'Card' | 'FileAttachment' | 'Gallery' | 'giphyVersion' | 'Giphy' | 'UrlPreview'> & {
|
|
5
|
+
export declare type AttachmentPropsWithContext<StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics> = Pick<MessagesContextValue<StreamChatGenerics>, 'AttachmentActions' | 'Card' | 'FileAttachment' | 'Gallery' | 'giphyVersion' | 'Giphy' | 'isAttachmentEqual' | 'UrlPreview'> & {
|
|
6
6
|
/**
|
|
7
7
|
* The attachment to render
|
|
8
8
|
*/
|
|
9
9
|
attachment: AttachmentType<StreamChatGenerics>;
|
|
10
10
|
};
|
|
11
|
-
export declare type AttachmentProps<StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics> = Partial<Pick<MessagesContextValue<StreamChatGenerics>, 'AttachmentActions' | 'Card' | 'FileAttachment' | 'Gallery' | 'Giphy' | 'giphyVersion' | 'UrlPreview'>> & Pick<AttachmentPropsWithContext<StreamChatGenerics>, 'attachment'>;
|
|
11
|
+
export declare type AttachmentProps<StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics> = Partial<Pick<MessagesContextValue<StreamChatGenerics>, 'AttachmentActions' | 'Card' | 'FileAttachment' | 'Gallery' | 'Giphy' | 'giphyVersion' | 'UrlPreview' | 'isAttachmentEqual'>> & Pick<AttachmentPropsWithContext<StreamChatGenerics>, 'attachment'>;
|
|
12
12
|
/**
|
|
13
13
|
* Attachment - The message attachment
|
|
14
14
|
*/
|
|
@@ -15,7 +15,7 @@ import type { DefaultStreamChatGenerics } from '../../types/types';
|
|
|
15
15
|
import { ReactionData } from '../../utils/utils';
|
|
16
16
|
import { LoadingErrorProps } from '../Indicators/LoadingErrorIndicator';
|
|
17
17
|
export declare const reactionData: ReactionData[];
|
|
18
|
-
export declare type ChannelPropsWithContext<StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics> = Pick<ChannelContextValue<StreamChatGenerics>, 'channel'> & Partial<Pick<ChannelContextValue<StreamChatGenerics>, 'EmptyStateIndicator' | 'enableMessageGroupingByUser' | 'enforceUniqueReaction' | 'giphyEnabled' | 'hideStickyDateHeader' | 'hideDateSeparators' | 'LoadingIndicator' | 'maxTimeBetweenGroupedMessages' | 'NetworkDownIndicator' | 'StickyHeader'>> & Pick<ChatContextValue<StreamChatGenerics>, 'client'> & Partial<Omit<InputMessageInputContextValue<StreamChatGenerics>, 'quotedMessage' | 'editing' | 'clearEditingState' | 'clearQuotedMessageState' | 'sendMessage'>> & Partial<Pick<SuggestionsContextValue<StreamChatGenerics>, 'AutoCompleteSuggestionHeader' | 'AutoCompleteSuggestionItem' | 'AutoCompleteSuggestionList'>> & Pick<TranslationContextValue, 't'> & Partial<Pick<PaginatedMessageListContextValue<StreamChatGenerics>, 'messages' | 'loadingMore' | 'loadingMoreRecent'>> & UseChannelStateValue<StreamChatGenerics> & Partial<Pick<MessagesContextValue<StreamChatGenerics>, 'additionalTouchableProps' | 'Attachment' | 'AttachmentActions' | 'Card' | 'CardCover' | 'CardFooter' | 'CardHeader' | 'DateHeader' | 'deletedMessagesVisibilityType' | 'disableTypingIndicator' | 'dismissKeyboardOnMessageTouch' | 'FileAttachment' | 'FileAttachmentIcon' | 'FileAttachmentGroup' | 'FlatList' | 'forceAlignMessages' | 'formatDate' | 'Gallery' | 'Giphy' | 'giphyVersion' | 'handleBlock' | 'handleCopy' | 'handleDelete' | 'handleEdit' | 'handleFlag' | 'handleMute' | 'handlePinMessage' | 'handleReaction' | 'handleQuotedReply' | 'handleRetry' | 'handleThreadReply' | 'InlineDateSeparator' | 'InlineUnreadIndicator' | 'legacyImageViewerSwipeBehaviour' | 'markdownRules' | 'Message' | 'messageActions' | 'MessageAvatar' | 'MessageContent' | 'messageContentOrder' | 'MessageDeleted' | 'MessageFooter' | 'MessageHeader' | 'MessageList' | 'MessagePinnedHeader' | 'MessageReplies' | 'MessageRepliesAvatars' | 'MessageSimple' | 'MessageStatus' | 'MessageSystem' | 'MessageText' | 'myMessageTheme' | 'onLongPressMessage' | 'onPressInMessage' | 'onPressMessage' | 'OverlayReactionList' | 'ReactionList' | 'Reply' | 'ScrollToBottomButton' | 'selectReaction' | 'supportedReactions' | 'TypingIndicator' | 'TypingIndicatorContainer' | 'UrlPreview'>> & Partial<Pick<ThreadContextValue<StreamChatGenerics>, 'allowThreadMessagesInChannel' | 'thread'>> & {
|
|
18
|
+
export declare type ChannelPropsWithContext<StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics> = Pick<ChannelContextValue<StreamChatGenerics>, 'channel'> & Partial<Pick<ChannelContextValue<StreamChatGenerics>, 'EmptyStateIndicator' | 'enableMessageGroupingByUser' | 'enforceUniqueReaction' | 'giphyEnabled' | 'hideStickyDateHeader' | 'hideDateSeparators' | 'LoadingIndicator' | 'maxTimeBetweenGroupedMessages' | 'NetworkDownIndicator' | 'StickyHeader'>> & Pick<ChatContextValue<StreamChatGenerics>, 'client'> & Partial<Omit<InputMessageInputContextValue<StreamChatGenerics>, 'quotedMessage' | 'editing' | 'clearEditingState' | 'clearQuotedMessageState' | 'sendMessage'>> & Partial<Pick<SuggestionsContextValue<StreamChatGenerics>, 'AutoCompleteSuggestionHeader' | 'AutoCompleteSuggestionItem' | 'AutoCompleteSuggestionList'>> & Pick<TranslationContextValue, 't'> & Partial<Pick<PaginatedMessageListContextValue<StreamChatGenerics>, 'messages' | 'loadingMore' | 'loadingMoreRecent'>> & UseChannelStateValue<StreamChatGenerics> & Partial<Pick<MessagesContextValue<StreamChatGenerics>, 'additionalTouchableProps' | 'Attachment' | 'AttachmentActions' | 'Card' | 'CardCover' | 'CardFooter' | 'CardHeader' | 'DateHeader' | 'deletedMessagesVisibilityType' | 'disableTypingIndicator' | 'dismissKeyboardOnMessageTouch' | 'FileAttachment' | 'FileAttachmentIcon' | 'FileAttachmentGroup' | 'FlatList' | 'forceAlignMessages' | 'formatDate' | 'Gallery' | 'Giphy' | 'giphyVersion' | 'handleBlock' | 'handleCopy' | 'handleDelete' | 'handleEdit' | 'handleFlag' | 'handleMute' | 'handlePinMessage' | 'handleReaction' | 'handleQuotedReply' | 'handleRetry' | 'handleThreadReply' | 'InlineDateSeparator' | 'InlineUnreadIndicator' | 'isAttachmentEqual' | 'legacyImageViewerSwipeBehaviour' | 'markdownRules' | 'Message' | 'messageActions' | 'MessageAvatar' | 'MessageContent' | 'messageContentOrder' | 'MessageDeleted' | 'MessageFooter' | 'MessageHeader' | 'MessageList' | 'MessagePinnedHeader' | 'MessageReplies' | 'MessageRepliesAvatars' | 'MessageSimple' | 'MessageStatus' | 'MessageSystem' | 'MessageText' | 'myMessageTheme' | 'onLongPressMessage' | 'onPressInMessage' | 'onPressMessage' | 'OverlayReactionList' | 'ReactionList' | 'Reply' | 'ScrollToBottomButton' | 'selectReaction' | 'supportedReactions' | 'TypingIndicator' | 'TypingIndicatorContainer' | 'UrlPreview'>> & Partial<Pick<ThreadContextValue<StreamChatGenerics>, 'allowThreadMessagesInChannel' | 'thread'>> & {
|
|
19
19
|
shouldSyncChannel: boolean;
|
|
20
20
|
/**
|
|
21
21
|
* Additional props passed to keyboard avoiding view
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { MessagesContextValue } from '../../../contexts/messagesContext/MessagesContext';
|
|
2
2
|
import type { DefaultStreamChatGenerics } from '../../../types/types';
|
|
3
|
-
export declare const useCreateMessagesContext: <StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics>({ additionalTouchableProps, Attachment, AttachmentActions, Card, CardCover, CardFooter, CardHeader, channelId, DateHeader, deletedMessagesVisibilityType, disableTypingIndicator, dismissKeyboardOnMessageTouch, enableMessageGroupingByUser, FileAttachment, FileAttachmentGroup, FileAttachmentIcon, FlatList, forceAlignMessages, formatDate, Gallery, Giphy, giphyVersion, handleBlock, handleCopy, handleDelete, handleEdit, handleFlag, handleMute, handlePinMessage, handleQuotedReply, handleReaction, handleRetry, handleThreadReply, initialScrollToFirstUnreadMessage, InlineDateSeparator, InlineUnreadIndicator, legacyImageViewerSwipeBehaviour, markdownRules, Message, messageActions, MessageAvatar, MessageContent, messageContentOrder, MessageDeleted, MessageFooter, MessageHeader, MessageList, MessagePinnedHeader, MessageReplies, MessageRepliesAvatars, MessageSimple, MessageStatus, MessageSystem, MessageText, myMessageTheme, onLongPressMessage, onPressInMessage, onPressMessage, OverlayReactionList, ReactionList, removeMessage, Reply, retrySendMessage, ScrollToBottomButton, selectReaction, setEditingState, setQuotedMessageState, supportedReactions, targetedMessage, TypingIndicator, TypingIndicatorContainer, updateMessage, UrlPreview, }: MessagesContextValue<StreamChatGenerics> & {
|
|
3
|
+
export declare const useCreateMessagesContext: <StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics>({ additionalTouchableProps, Attachment, AttachmentActions, Card, CardCover, CardFooter, CardHeader, channelId, DateHeader, deletedMessagesVisibilityType, disableTypingIndicator, dismissKeyboardOnMessageTouch, enableMessageGroupingByUser, FileAttachment, FileAttachmentGroup, FileAttachmentIcon, FlatList, forceAlignMessages, formatDate, Gallery, Giphy, giphyVersion, handleBlock, handleCopy, handleDelete, handleEdit, handleFlag, handleMute, handlePinMessage, handleQuotedReply, handleReaction, handleRetry, handleThreadReply, initialScrollToFirstUnreadMessage, InlineDateSeparator, InlineUnreadIndicator, isAttachmentEqual, legacyImageViewerSwipeBehaviour, markdownRules, Message, messageActions, MessageAvatar, MessageContent, messageContentOrder, MessageDeleted, MessageFooter, MessageHeader, MessageList, MessagePinnedHeader, MessageReplies, MessageRepliesAvatars, MessageSimple, MessageStatus, MessageSystem, MessageText, myMessageTheme, onLongPressMessage, onPressInMessage, onPressMessage, OverlayReactionList, ReactionList, removeMessage, Reply, retrySendMessage, ScrollToBottomButton, selectReaction, setEditingState, setQuotedMessageState, supportedReactions, targetedMessage, TypingIndicator, TypingIndicatorContainer, updateMessage, UrlPreview, }: MessagesContextValue<StreamChatGenerics> & {
|
|
4
4
|
/**
|
|
5
5
|
* To ensure we allow re-render, when channel is changed
|
|
6
6
|
*/
|
|
@@ -56,13 +56,7 @@ export declare type ImageGalleryCustomComponents<StreamChatGenerics extends Defa
|
|
|
56
56
|
};
|
|
57
57
|
declare type Props<StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics> = ImageGalleryCustomComponents<StreamChatGenerics> & {
|
|
58
58
|
overlayOpacity: Animated.SharedValue<number>;
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* This should be
|
|
62
|
-
*/
|
|
63
|
-
imageGalleryGridSnapPoints?: [string | number, string | number];
|
|
64
|
-
numberOfImageGalleryGridColumns?: number;
|
|
65
|
-
} & Pick<OverlayProviderProps<StreamChatGenerics>, 'giphyVersion'>;
|
|
59
|
+
} & Pick<OverlayProviderProps<StreamChatGenerics>, 'giphyVersion' | 'imageGalleryGridSnapPoints' | 'imageGalleryGridHandleHeight' | 'numberOfImageGalleryGridColumns'>;
|
|
66
60
|
export declare const ImageGallery: {
|
|
67
61
|
<StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics>(props: Props<StreamChatGenerics>): JSX.Element;
|
|
68
62
|
displayName: string;
|
|
@@ -30,7 +30,7 @@ export declare type MessageActionHandlers = {
|
|
|
30
30
|
toggleMuteUser: () => Promise<void>;
|
|
31
31
|
toggleReaction: (reactionType: string) => Promise<void>;
|
|
32
32
|
};
|
|
33
|
-
export declare type MessagePropsWithContext<StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics> = Pick<ChannelContextValue<StreamChatGenerics>, 'channel' | 'disabled' | 'enforceUniqueReaction' | 'members'> & Pick<ChatContextValue<StreamChatGenerics>, 'client' | 'mutedUsers'> & Pick<KeyboardContextValue, 'dismissKeyboard'> & Partial<Omit<MessageContextValue<StreamChatGenerics>, 'groupStyles' | 'message'>> & Pick<MessageContextValue<StreamChatGenerics>, 'groupStyles' | 'message'> & Pick<MessagesContextValue<StreamChatGenerics>, 'dismissKeyboardOnMessageTouch' | 'forceAlignMessages' | 'handleBlock' | 'handleCopy' | 'handleDelete' | 'handleEdit' | 'handleFlag' | 'handleMute' | 'handlePinMessage' | 'handleQuotedReply' | 'handleReaction' | 'handleRetry' | 'handleThreadReply' | 'messageActions' | 'messageContentOrder' | 'MessageSimple' | 'onLongPressMessage' | 'onPressInMessage' | 'onPressMessage' | 'OverlayReactionList' | 'removeMessage' | 'retrySendMessage' | 'selectReaction' | 'setEditingState' | 'setQuotedMessageState' | 'supportedReactions' | 'updateMessage'> & Pick<MessageOverlayContextValue<StreamChatGenerics>, 'setData'> & Pick<OverlayContextValue, 'setOverlay'> & Pick<ThreadContextValue<StreamChatGenerics>, 'openThread'> & Pick<TranslationContextValue, 't'> & {
|
|
33
|
+
export declare type MessagePropsWithContext<StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics> = Pick<ChannelContextValue<StreamChatGenerics>, 'channel' | 'disabled' | 'enforceUniqueReaction' | 'members'> & Pick<ChatContextValue<StreamChatGenerics>, 'client' | 'mutedUsers'> & Pick<KeyboardContextValue, 'dismissKeyboard'> & Partial<Omit<MessageContextValue<StreamChatGenerics>, 'groupStyles' | 'message'>> & Pick<MessageContextValue<StreamChatGenerics>, 'groupStyles' | 'message'> & Pick<MessagesContextValue<StreamChatGenerics>, 'dismissKeyboardOnMessageTouch' | 'forceAlignMessages' | 'handleBlock' | 'handleCopy' | 'handleDelete' | 'handleEdit' | 'handleFlag' | 'handleMute' | 'handlePinMessage' | 'handleQuotedReply' | 'handleReaction' | 'handleRetry' | 'handleThreadReply' | 'isAttachmentEqual' | 'messageActions' | 'messageContentOrder' | 'MessageSimple' | 'onLongPressMessage' | 'onPressInMessage' | 'onPressMessage' | 'OverlayReactionList' | 'removeMessage' | 'retrySendMessage' | 'selectReaction' | 'setEditingState' | 'setQuotedMessageState' | 'supportedReactions' | 'updateMessage'> & Pick<MessageOverlayContextValue<StreamChatGenerics>, 'setData'> & Pick<OverlayContextValue, 'setOverlay'> & Pick<ThreadContextValue<StreamChatGenerics>, 'openThread'> & Pick<TranslationContextValue, 't'> & {
|
|
34
34
|
messagesContext: MessagesContextValue<StreamChatGenerics>;
|
|
35
35
|
/**
|
|
36
36
|
* Whether or not users are able to long press messages.
|
|
@@ -3,7 +3,7 @@ import { MessageContextValue } from '../../../contexts/messageContext/MessageCon
|
|
|
3
3
|
import { MessagesContextValue } from '../../../contexts/messagesContext/MessagesContext';
|
|
4
4
|
import { TranslationContextValue } from '../../../contexts/translationContext/TranslationContext';
|
|
5
5
|
import type { DefaultStreamChatGenerics } from '../../../types/types';
|
|
6
|
-
export declare type MessageContentPropsWithContext<StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics> = Pick<MessageContextValue<StreamChatGenerics>, 'alignment' | 'disabled' | 'goToMessage' | 'groupStyles' | 'hasReactions' | 'isMyMessage' | 'lastGroupMessage' | 'members' | 'message' | 'messageContentOrder' | 'onLongPress' | 'onlyEmojis' | 'onPress' | 'onPressIn' | 'otherAttachments' | 'preventPress' | 'showMessageStatus' | 'threadList'> & Pick<MessagesContextValue<StreamChatGenerics>, 'additionalTouchableProps' | 'Attachment' | 'FileAttachmentGroup' | 'formatDate' | 'Gallery' | 'MessageFooter' | 'MessageHeader' | 'MessageDeleted' | 'MessageReplies' | 'MessageStatus' | 'onPressInMessage' | 'Reply'> & Pick<TranslationContextValue, 't' | 'tDateTimeParser'> & {
|
|
6
|
+
export declare type MessageContentPropsWithContext<StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics> = Pick<MessageContextValue<StreamChatGenerics>, 'alignment' | 'disabled' | 'goToMessage' | 'groupStyles' | 'hasReactions' | 'isMyMessage' | 'lastGroupMessage' | 'members' | 'message' | 'messageContentOrder' | 'onLongPress' | 'onlyEmojis' | 'onPress' | 'onPressIn' | 'otherAttachments' | 'preventPress' | 'showMessageStatus' | 'threadList'> & Pick<MessagesContextValue<StreamChatGenerics>, 'additionalTouchableProps' | 'Attachment' | 'FileAttachmentGroup' | 'formatDate' | 'Gallery' | 'isAttachmentEqual' | 'MessageFooter' | 'MessageHeader' | 'MessageDeleted' | 'MessageReplies' | 'MessageStatus' | 'onPressInMessage' | 'Reply'> & Pick<TranslationContextValue, 't' | 'tDateTimeParser'> & {
|
|
7
7
|
setMessageContentWidth: React.Dispatch<React.SetStateAction<number>>;
|
|
8
8
|
};
|
|
9
9
|
export declare type MessageContentProps<StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics> = Partial<Omit<MessageContentPropsWithContext<StreamChatGenerics>, 'setMessageContentWidth'>> & Pick<MessageContentPropsWithContext<StreamChatGenerics>, 'setMessageContentWidth'>;
|
|
@@ -272,6 +272,8 @@ export declare type MessagesContextValue<StreamChatGenerics extends DefaultStrea
|
|
|
272
272
|
handleRetry?: (message: MessageType<StreamChatGenerics>) => Promise<void>;
|
|
273
273
|
/** Handler to access when a thread reply action is invoked */
|
|
274
274
|
handleThreadReply?: (message: MessageType<StreamChatGenerics>) => Promise<void>;
|
|
275
|
+
/** Handler to deal with custom memoization logic of Attachment */
|
|
276
|
+
isAttachmentEqual?: (prevAttachment: Attachment<StreamChatGenerics>, nextAttachment: Attachment<StreamChatGenerics>) => boolean;
|
|
275
277
|
legacyImageViewerSwipeBehaviour?: boolean;
|
|
276
278
|
/** Object specifying rules defined within simple-markdown https://github.com/Khan/simple-markdown#adding-a-simple-extension */
|
|
277
279
|
markdownRules?: MarkdownRules;
|
|
@@ -22,9 +22,9 @@ export declare type OverlayProviderProps<StreamChatGenerics extends DefaultStrea
|
|
|
22
22
|
/**
|
|
23
23
|
* The giphy version to render - check the keys of the [Image Object](https://developers.giphy.com/docs/api/schema#image-object) for possible values. Uses 'fixed_height' by default
|
|
24
24
|
* */
|
|
25
|
-
giphyVersion: keyof NonNullable<Attachment['giphy']>;
|
|
26
25
|
closePicker?: (ref: React.RefObject<BottomSheetMethods>) => void;
|
|
27
26
|
error?: boolean | Error;
|
|
27
|
+
giphyVersion?: keyof NonNullable<Attachment['giphy']>;
|
|
28
28
|
/** https://github.com/GetStream/stream-chat-react-native/wiki/Internationalization-(i18n) */
|
|
29
29
|
i18nInstance?: Streami18n;
|
|
30
30
|
imageGalleryGridHandleHeight?: number;
|
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": "4.3.
|
|
4
|
+
"version": "4.3.1-beta.1",
|
|
5
5
|
"author": {
|
|
6
6
|
"company": "Stream.io Inc",
|
|
7
7
|
"name": "Stream.io Inc"
|
|
@@ -26,6 +26,7 @@ export type AttachmentPropsWithContext<
|
|
|
26
26
|
| 'Gallery'
|
|
27
27
|
| 'giphyVersion'
|
|
28
28
|
| 'Giphy'
|
|
29
|
+
| 'isAttachmentEqual'
|
|
29
30
|
| 'UrlPreview'
|
|
30
31
|
> & {
|
|
31
32
|
/**
|
|
@@ -101,15 +102,20 @@ const areEqual = <StreamChatGenerics extends DefaultStreamChatGenerics = Default
|
|
|
101
102
|
prevProps: AttachmentPropsWithContext<StreamChatGenerics>,
|
|
102
103
|
nextProps: AttachmentPropsWithContext<StreamChatGenerics>,
|
|
103
104
|
) => {
|
|
104
|
-
const { attachment: prevAttachment } = prevProps;
|
|
105
|
+
const { attachment: prevAttachment, isAttachmentEqual } = prevProps;
|
|
105
106
|
const { attachment: nextAttachment } = nextProps;
|
|
106
107
|
|
|
107
108
|
const attachmentEqual =
|
|
108
109
|
prevAttachment.actions?.length === nextAttachment.actions?.length &&
|
|
109
110
|
prevAttachment.image_url === nextAttachment.image_url &&
|
|
110
111
|
prevAttachment.thumb_url === nextAttachment.thumb_url;
|
|
112
|
+
if (!attachmentEqual) return false;
|
|
111
113
|
|
|
112
|
-
|
|
114
|
+
if (isAttachmentEqual) {
|
|
115
|
+
return isAttachmentEqual(prevAttachment, nextAttachment);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
return true;
|
|
113
119
|
};
|
|
114
120
|
|
|
115
121
|
const MemoizedAttachment = React.memo(
|
|
@@ -129,6 +135,7 @@ export type AttachmentProps<
|
|
|
129
135
|
| 'Giphy'
|
|
130
136
|
| 'giphyVersion'
|
|
131
137
|
| 'UrlPreview'
|
|
138
|
+
| 'isAttachmentEqual'
|
|
132
139
|
>
|
|
133
140
|
> &
|
|
134
141
|
Pick<AttachmentPropsWithContext<StreamChatGenerics>, 'attachment'>;
|
|
@@ -159,6 +166,7 @@ export const Attachment = <
|
|
|
159
166
|
Gallery: ContextGallery,
|
|
160
167
|
Giphy: ContextGiphy,
|
|
161
168
|
giphyVersion: ContextGiphyVersion,
|
|
169
|
+
isAttachmentEqual,
|
|
162
170
|
UrlPreview: ContextUrlPreview,
|
|
163
171
|
} = useMessagesContext<StreamChatGenerics>();
|
|
164
172
|
|
|
@@ -185,6 +193,7 @@ export const Attachment = <
|
|
|
185
193
|
Gallery,
|
|
186
194
|
Giphy,
|
|
187
195
|
giphyVersion,
|
|
196
|
+
isAttachmentEqual,
|
|
188
197
|
UrlPreview,
|
|
189
198
|
}}
|
|
190
199
|
/>
|
|
@@ -255,6 +255,7 @@ export type ChannelPropsWithContext<
|
|
|
255
255
|
| 'handleThreadReply'
|
|
256
256
|
| 'InlineDateSeparator'
|
|
257
257
|
| 'InlineUnreadIndicator'
|
|
258
|
+
| 'isAttachmentEqual'
|
|
258
259
|
| 'legacyImageViewerSwipeBehaviour'
|
|
259
260
|
| 'markdownRules'
|
|
260
261
|
| 'Message'
|
|
@@ -458,6 +459,7 @@ const ChannelWithContext = <
|
|
|
458
459
|
InputEditingStateHeader = InputEditingStateHeaderDefault,
|
|
459
460
|
InputGiphySearch = InputGiphyCommandInputDefault,
|
|
460
461
|
InputReplyStateHeader = InputReplyStateHeaderDefault,
|
|
462
|
+
isAttachmentEqual,
|
|
461
463
|
keyboardBehavior,
|
|
462
464
|
KeyboardCompatibleView = KeyboardCompatibleViewDefault,
|
|
463
465
|
keyboardVerticalOffset,
|
|
@@ -1698,6 +1700,7 @@ const ChannelWithContext = <
|
|
|
1698
1700
|
initialScrollToFirstUnreadMessage,
|
|
1699
1701
|
InlineDateSeparator,
|
|
1700
1702
|
InlineUnreadIndicator,
|
|
1703
|
+
isAttachmentEqual,
|
|
1701
1704
|
legacyImageViewerSwipeBehaviour,
|
|
1702
1705
|
markdownRules,
|
|
1703
1706
|
Message,
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import { Text } from 'react-native';
|
|
4
|
+
|
|
5
|
+
import { act, cleanup, render, waitFor } from '@testing-library/react-native';
|
|
6
|
+
|
|
7
|
+
import { OverlayProvider } from '../../../contexts/overlayContext/OverlayProvider';
|
|
8
|
+
import { getOrCreateChannelApi } from '../../../mock-builders/api/getOrCreateChannel';
|
|
9
|
+
|
|
10
|
+
import { useMockedApis } from '../../../mock-builders/api/useMockedApis';
|
|
11
|
+
import dispatchMessageUpdateEvent from '../../../mock-builders/event/messageUpdated';
|
|
12
|
+
import { generateChannelResponse } from '../../../mock-builders/generator/channel';
|
|
13
|
+
import { generateMember } from '../../../mock-builders/generator/member';
|
|
14
|
+
import { generateMessage } from '../../../mock-builders/generator/message';
|
|
15
|
+
import { generateUser } from '../../../mock-builders/generator/user';
|
|
16
|
+
import { getTestClientWithUser } from '../../../mock-builders/mock';
|
|
17
|
+
import { Channel } from '../../Channel/Channel';
|
|
18
|
+
import { Chat } from '../../Chat/Chat';
|
|
19
|
+
import { MessageList } from '../../MessageList/MessageList';
|
|
20
|
+
|
|
21
|
+
describe('Message', () => {
|
|
22
|
+
let channel;
|
|
23
|
+
let chatClient;
|
|
24
|
+
|
|
25
|
+
const user = generateUser({ id: 'id', name: 'name' });
|
|
26
|
+
const messages = [
|
|
27
|
+
generateMessage({
|
|
28
|
+
attachments: [{ customField: 'custom-field', type: 'test' }],
|
|
29
|
+
user,
|
|
30
|
+
}),
|
|
31
|
+
];
|
|
32
|
+
|
|
33
|
+
beforeEach(async () => {
|
|
34
|
+
const members = [generateMember({ user })];
|
|
35
|
+
const mockedChannel = generateChannelResponse({
|
|
36
|
+
members,
|
|
37
|
+
messages,
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
chatClient = await getTestClientWithUser(user);
|
|
41
|
+
useMockedApis(chatClient, [getOrCreateChannelApi(mockedChannel)]);
|
|
42
|
+
channel = chatClient.channel('messaging', mockedChannel.id);
|
|
43
|
+
await channel.watch();
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
afterEach(() => {
|
|
47
|
+
jest.clearAllMocks();
|
|
48
|
+
cleanup();
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
const getMessageWithCustomFields = () => {
|
|
52
|
+
const isAttachmentEqualHandler = (prevProps, nextProps) => {
|
|
53
|
+
const propsEqual = prevProps.customField === nextProps.customField;
|
|
54
|
+
if (!propsEqual) return false;
|
|
55
|
+
return true;
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
return (
|
|
59
|
+
<OverlayProvider>
|
|
60
|
+
<Chat client={chatClient}>
|
|
61
|
+
<Channel
|
|
62
|
+
Card={({ customField, type }) => {
|
|
63
|
+
if (type === 'test') {
|
|
64
|
+
return <Text testID='attachment-custom-field'>{customField}</Text>;
|
|
65
|
+
}
|
|
66
|
+
}}
|
|
67
|
+
channel={channel}
|
|
68
|
+
isAttachmentEqual={isAttachmentEqualHandler}
|
|
69
|
+
>
|
|
70
|
+
<MessageList />
|
|
71
|
+
</Channel>
|
|
72
|
+
</Chat>
|
|
73
|
+
</OverlayProvider>
|
|
74
|
+
);
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
it('should render attachment with custom field', async () => {
|
|
78
|
+
const { getByText } = render(getMessageWithCustomFields());
|
|
79
|
+
|
|
80
|
+
await waitFor(() => {
|
|
81
|
+
expect(getByText('custom-field')).toBeTruthy();
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
act(() => {
|
|
85
|
+
dispatchMessageUpdateEvent(
|
|
86
|
+
chatClient,
|
|
87
|
+
{
|
|
88
|
+
...messages[0],
|
|
89
|
+
attachments: [{ customField: 'custom-field-2', type: 'test' }],
|
|
90
|
+
updated_at: new Date(),
|
|
91
|
+
},
|
|
92
|
+
channel,
|
|
93
|
+
);
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
await waitFor(() => {
|
|
97
|
+
expect(getByText('custom-field-2')).toBeTruthy();
|
|
98
|
+
});
|
|
99
|
+
});
|
|
100
|
+
});
|
|
@@ -42,6 +42,7 @@ export const useCreateMessagesContext = <
|
|
|
42
42
|
initialScrollToFirstUnreadMessage,
|
|
43
43
|
InlineDateSeparator,
|
|
44
44
|
InlineUnreadIndicator,
|
|
45
|
+
isAttachmentEqual,
|
|
45
46
|
legacyImageViewerSwipeBehaviour,
|
|
46
47
|
markdownRules,
|
|
47
48
|
Message,
|
|
@@ -127,6 +128,7 @@ export const useCreateMessagesContext = <
|
|
|
127
128
|
initialScrollToFirstUnreadMessage,
|
|
128
129
|
InlineDateSeparator,
|
|
129
130
|
InlineUnreadIndicator,
|
|
131
|
+
isAttachmentEqual,
|
|
130
132
|
legacyImageViewerSwipeBehaviour,
|
|
131
133
|
markdownRules,
|
|
132
134
|
Message,
|
|
@@ -127,13 +127,13 @@ export type ImageGalleryCustomComponents<
|
|
|
127
127
|
type Props<StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics> =
|
|
128
128
|
ImageGalleryCustomComponents<StreamChatGenerics> & {
|
|
129
129
|
overlayOpacity: Animated.SharedValue<number>;
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
130
|
+
} & Pick<
|
|
131
|
+
OverlayProviderProps<StreamChatGenerics>,
|
|
132
|
+
| 'giphyVersion'
|
|
133
|
+
| 'imageGalleryGridSnapPoints'
|
|
134
|
+
| 'imageGalleryGridHandleHeight'
|
|
135
|
+
| 'numberOfImageGalleryGridColumns'
|
|
136
|
+
>;
|
|
137
137
|
|
|
138
138
|
export const ImageGallery = <
|
|
139
139
|
StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
|
|
@@ -141,7 +141,7 @@ export const ImageGallery = <
|
|
|
141
141
|
props: Props<StreamChatGenerics>,
|
|
142
142
|
) => {
|
|
143
143
|
const {
|
|
144
|
-
giphyVersion,
|
|
144
|
+
giphyVersion = 'fixed_height',
|
|
145
145
|
imageGalleryCustomComponents,
|
|
146
146
|
imageGalleryGridHandleHeight,
|
|
147
147
|
imageGalleryGridSnapPoints,
|
|
@@ -308,6 +308,7 @@ export const ImageGallery = <
|
|
|
308
308
|
* Photos array created from all currently available
|
|
309
309
|
* photo attachments
|
|
310
310
|
*/
|
|
311
|
+
|
|
311
312
|
const photos = images.reduce((acc: Photo<StreamChatGenerics>[], cur) => {
|
|
312
313
|
const attachmentImages =
|
|
313
314
|
cur.attachments?.filter(
|
|
@@ -112,6 +112,7 @@ export type MessagePropsWithContext<
|
|
|
112
112
|
| 'handleReaction'
|
|
113
113
|
| 'handleRetry'
|
|
114
114
|
| 'handleThreadReply'
|
|
115
|
+
| 'isAttachmentEqual'
|
|
115
116
|
| 'messageActions'
|
|
116
117
|
| 'messageContentOrder'
|
|
117
118
|
| 'MessageSimple'
|
|
@@ -472,6 +473,7 @@ const MessageWithContext = <
|
|
|
472
473
|
t,
|
|
473
474
|
updateMessage,
|
|
474
475
|
});
|
|
476
|
+
|
|
475
477
|
const showMessageOverlay = async (messageReactions = false, error = errorOrFailed) => {
|
|
476
478
|
await dismissKeyboard();
|
|
477
479
|
|
|
@@ -680,6 +682,7 @@ const areEqual = <StreamChatGenerics extends DefaultStreamChatGenerics = Default
|
|
|
680
682
|
) => {
|
|
681
683
|
const {
|
|
682
684
|
goToMessage: prevGoToMessage,
|
|
685
|
+
isAttachmentEqual,
|
|
683
686
|
isTargetedMessage: prevIsTargetedMessage,
|
|
684
687
|
lastReceivedId: prevLastReceivedId,
|
|
685
688
|
members: prevMembers,
|
|
@@ -729,8 +732,8 @@ const areEqual = <StreamChatGenerics extends DefaultStreamChatGenerics = Default
|
|
|
729
732
|
prevMessage.status === nextMessage.status &&
|
|
730
733
|
prevMessage.type === nextMessage.type &&
|
|
731
734
|
prevMessage.text === nextMessage.text &&
|
|
732
|
-
prevMessage.
|
|
733
|
-
prevMessage.
|
|
735
|
+
prevMessage.pinned === nextMessage.pinned &&
|
|
736
|
+
prevMessage.updated_at === nextMessage.updated_at;
|
|
734
737
|
|
|
735
738
|
if (!messageEqual) return false;
|
|
736
739
|
|
|
@@ -752,12 +755,20 @@ const areEqual = <StreamChatGenerics extends DefaultStreamChatGenerics = Default
|
|
|
752
755
|
(Array.isArray(prevMessageAttachments) &&
|
|
753
756
|
Array.isArray(nextMessageAttachments) &&
|
|
754
757
|
prevMessageAttachments.length === nextMessageAttachments.length &&
|
|
755
|
-
prevMessageAttachments.every((attachment, index) =>
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
attachment.
|
|
759
|
-
|
|
760
|
-
|
|
758
|
+
prevMessageAttachments.every((attachment, index) => {
|
|
759
|
+
const attachmentKeysEqual =
|
|
760
|
+
attachment.type === 'image'
|
|
761
|
+
? attachment.image_url === nextMessageAttachments[index].image_url &&
|
|
762
|
+
attachment.thumb_url === nextMessageAttachments[index].thumb_url
|
|
763
|
+
: attachment.type === nextMessageAttachments[index].type;
|
|
764
|
+
|
|
765
|
+
if (isAttachmentEqual)
|
|
766
|
+
return (
|
|
767
|
+
attachmentKeysEqual && !!isAttachmentEqual(attachment, nextMessageAttachments[index])
|
|
768
|
+
);
|
|
769
|
+
|
|
770
|
+
return attachmentKeysEqual;
|
|
771
|
+
})) ||
|
|
761
772
|
prevMessageAttachments === nextMessageAttachments;
|
|
762
773
|
if (!attachmentsEqual) return false;
|
|
763
774
|
|
|
@@ -84,6 +84,7 @@ export type MessageContentPropsWithContext<
|
|
|
84
84
|
| 'FileAttachmentGroup'
|
|
85
85
|
| 'formatDate'
|
|
86
86
|
| 'Gallery'
|
|
87
|
+
| 'isAttachmentEqual'
|
|
87
88
|
| 'MessageFooter'
|
|
88
89
|
| 'MessageHeader'
|
|
89
90
|
| 'MessageDeleted'
|
|
@@ -371,6 +372,7 @@ const areEqual = <StreamChatGenerics extends DefaultStreamChatGenerics = Default
|
|
|
371
372
|
goToMessage: prevGoToMessage,
|
|
372
373
|
groupStyles: prevGroupStyles,
|
|
373
374
|
hasReactions: prevHasReactions,
|
|
375
|
+
isAttachmentEqual,
|
|
374
376
|
lastGroupMessage: prevLastGroupMessage,
|
|
375
377
|
members: prevMembers,
|
|
376
378
|
message: prevMessage,
|
|
@@ -402,7 +404,6 @@ const areEqual = <StreamChatGenerics extends DefaultStreamChatGenerics = Default
|
|
|
402
404
|
|
|
403
405
|
const goToMessageChangedAndMatters =
|
|
404
406
|
nextMessage.quoted_message_id && prevGoToMessage !== nextGoToMessage;
|
|
405
|
-
|
|
406
407
|
if (goToMessageChangedAndMatters) return false;
|
|
407
408
|
|
|
408
409
|
const onlyEmojisEqual = prevOnlyEmojis === nextOnlyEmojis;
|
|
@@ -431,7 +432,6 @@ const areEqual = <StreamChatGenerics extends DefaultStreamChatGenerics = Default
|
|
|
431
432
|
prevMessage.type === nextMessage.type &&
|
|
432
433
|
prevMessage.text === nextMessage.text &&
|
|
433
434
|
prevMessage.pinned === nextMessage.pinned;
|
|
434
|
-
|
|
435
435
|
if (!messageEqual) return false;
|
|
436
436
|
|
|
437
437
|
const isPrevQuotedMessageTypeDeleted = prevMessage.quoted_message?.type === 'deleted';
|
|
@@ -440,21 +440,28 @@ const areEqual = <StreamChatGenerics extends DefaultStreamChatGenerics = Default
|
|
|
440
440
|
const quotedMessageEqual =
|
|
441
441
|
prevMessage.quoted_message?.id === nextMessage.quoted_message?.id &&
|
|
442
442
|
isPrevQuotedMessageTypeDeleted === isNextQuotedMessageTypeDeleted;
|
|
443
|
-
|
|
444
443
|
if (!quotedMessageEqual) return false;
|
|
445
444
|
|
|
446
|
-
const
|
|
447
|
-
const
|
|
445
|
+
const prevMessageAttachments = prevMessage.attachments;
|
|
446
|
+
const nextMessageAttachments = nextMessage.attachments;
|
|
448
447
|
const attachmentsEqual =
|
|
449
|
-
Array.isArray(
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
448
|
+
Array.isArray(prevMessageAttachments) &&
|
|
449
|
+
Array.isArray(nextMessageAttachments) &&
|
|
450
|
+
prevMessageAttachments.length === nextMessageAttachments.length &&
|
|
451
|
+
prevMessageAttachments.every((attachment, index) => {
|
|
452
|
+
const attachmentKeysEqual =
|
|
453
|
+
attachment.type === 'image'
|
|
454
|
+
? attachment.image_url === nextMessageAttachments[index].image_url &&
|
|
455
|
+
attachment.thumb_url === nextMessageAttachments[index].thumb_url
|
|
456
|
+
: attachment.type === nextMessageAttachments[index].type;
|
|
457
|
+
|
|
458
|
+
if (isAttachmentEqual)
|
|
459
|
+
return (
|
|
460
|
+
attachmentKeysEqual && !!isAttachmentEqual(attachment, nextMessageAttachments[index])
|
|
461
|
+
);
|
|
462
|
+
|
|
463
|
+
return attachmentKeysEqual;
|
|
464
|
+
});
|
|
458
465
|
if (!attachmentsEqual) return false;
|
|
459
466
|
|
|
460
467
|
const latestReactionsEqual =
|
|
@@ -527,6 +534,7 @@ export const MessageContent = <
|
|
|
527
534
|
FileAttachmentGroup,
|
|
528
535
|
formatDate,
|
|
529
536
|
Gallery,
|
|
537
|
+
isAttachmentEqual,
|
|
530
538
|
MessageDeleted,
|
|
531
539
|
MessageFooter,
|
|
532
540
|
MessageHeader,
|
|
@@ -549,6 +557,7 @@ export const MessageContent = <
|
|
|
549
557
|
goToMessage,
|
|
550
558
|
groupStyles,
|
|
551
559
|
hasReactions,
|
|
560
|
+
isAttachmentEqual,
|
|
552
561
|
isMyMessage,
|
|
553
562
|
lastGroupMessage,
|
|
554
563
|
lastReceivedId,
|
|
@@ -144,18 +144,21 @@ const areEqual = <StreamChatGenerics extends DefaultStreamChatGenerics = Default
|
|
|
144
144
|
const channelEqual = prevChannel?.state.messages.length === nextChannel?.state.messages.length;
|
|
145
145
|
if (!channelEqual) return false;
|
|
146
146
|
|
|
147
|
-
const
|
|
148
|
-
const
|
|
147
|
+
const prevMessageAttachments = prevMessage.attachments;
|
|
148
|
+
const nextMessageAttachments = nextMessage.attachments;
|
|
149
149
|
const attachmentsEqual =
|
|
150
|
-
Array.isArray(
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
150
|
+
Array.isArray(prevMessageAttachments) &&
|
|
151
|
+
Array.isArray(nextMessageAttachments) &&
|
|
152
|
+
prevMessageAttachments.length === nextMessageAttachments.length &&
|
|
153
|
+
prevMessageAttachments.every((attachment, index) => {
|
|
154
|
+
const attachmentKeysEqual =
|
|
155
|
+
attachment.type === 'image'
|
|
156
|
+
? attachment.image_url === nextMessageAttachments[index].image_url &&
|
|
157
|
+
attachment.thumb_url === nextMessageAttachments[index].thumb_url
|
|
158
|
+
: attachment.type === nextMessageAttachments[index].type;
|
|
159
|
+
|
|
160
|
+
return attachmentKeysEqual;
|
|
161
|
+
});
|
|
159
162
|
if (!attachmentsEqual) return false;
|
|
160
163
|
|
|
161
164
|
const latestReactionsEqual =
|
|
@@ -296,6 +296,11 @@ export type MessagesContextValue<
|
|
|
296
296
|
handleRetry?: (message: MessageType<StreamChatGenerics>) => Promise<void>;
|
|
297
297
|
/** Handler to access when a thread reply action is invoked */
|
|
298
298
|
handleThreadReply?: (message: MessageType<StreamChatGenerics>) => Promise<void>;
|
|
299
|
+
/** Handler to deal with custom memoization logic of Attachment */
|
|
300
|
+
isAttachmentEqual?: (
|
|
301
|
+
prevAttachment: Attachment<StreamChatGenerics>,
|
|
302
|
+
nextAttachment: Attachment<StreamChatGenerics>,
|
|
303
|
+
) => boolean;
|
|
299
304
|
legacyImageViewerSwipeBehaviour?: boolean;
|
|
300
305
|
/** Object specifying rules defined within simple-markdown https://github.com/Khan/simple-markdown#adding-a-simple-extension */
|
|
301
306
|
markdownRules?: MarkdownRules;
|
|
@@ -56,9 +56,9 @@ export type OverlayProviderProps<
|
|
|
56
56
|
/**
|
|
57
57
|
* The giphy version to render - check the keys of the [Image Object](https://developers.giphy.com/docs/api/schema#image-object) for possible values. Uses 'fixed_height' by default
|
|
58
58
|
* */
|
|
59
|
-
giphyVersion: keyof NonNullable<Attachment['giphy']>;
|
|
60
59
|
closePicker?: (ref: React.RefObject<BottomSheetMethods>) => void;
|
|
61
60
|
error?: boolean | Error;
|
|
61
|
+
giphyVersion?: keyof NonNullable<Attachment['giphy']>;
|
|
62
62
|
/** https://github.com/GetStream/stream-chat-react-native/wiki/Internationalization-(i18n) */
|
|
63
63
|
i18nInstance?: Streami18n;
|
|
64
64
|
imageGalleryGridHandleHeight?: number;
|
package/src/version.json
CHANGED