stream-chat-react-native-core 4.3.0-beta.2 → 4.3.0-beta.5
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/Channel/hooks/useCreateOwnCapabilitiesContext.js +6 -3
- package/lib/commonjs/components/Channel/hooks/useCreateOwnCapabilitiesContext.js.map +1 -1
- package/lib/commonjs/components/Channel/hooks/useCreatePaginatedMessageListContext.js +1 -1
- package/lib/commonjs/components/Channel/hooks/useCreatePaginatedMessageListContext.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/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/Channel/hooks/useCreateOwnCapabilitiesContext.js +6 -3
- package/lib/module/components/Channel/hooks/useCreateOwnCapabilitiesContext.js.map +1 -1
- package/lib/module/components/Channel/hooks/useCreatePaginatedMessageListContext.js +1 -1
- package/lib/module/components/Channel/hooks/useCreatePaginatedMessageListContext.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/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/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/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/Channel/hooks/useCreateOwnCapabilitiesContext.ts +6 -1
- package/src/components/Channel/hooks/useCreatePaginatedMessageListContext.ts +1 -1
- 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/components/Thread/__tests__/__snapshots__/Thread.test.js.snap +411 -12
- package/src/contexts/messagesContext/MessagesContext.tsx +5 -0
- package/src/version.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["MessagesContext.tsx"],"names":["MessagesContext","React","createContext","MessagesProvider","children","value","useMessagesContext","withMessagesContext","Component","WithMessagesContextComponent","props","messagesContext","displayName"],"mappings":";;;;;;;;;;;AAAA;;AAkDA;;;;;;;;;AAuZO,IAAMA,eAAe,GAAGC,kBAAMC,aAAN,CAAoB,EAApB,CAAxB;;;;AAEA,IAAMC,gBAAgB,GAAG,SAAnBA,gBAAmB;AAAA,MAG9BC,QAH8B,QAG9BA,QAH8B;AAAA,MAI9BC,KAJ8B,QAI9BA,KAJ8B;AAAA,SAQ9B,gCAAC,eAAD,CAAiB,QAAjB;AAA0B,IAAA,KAAK,EAAEA,KAAjC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,KACGD,QADH,CAR8B;AAAA,CAAzB;;;;AAaA,IAAME,kBAAkB,GAAG,SAArBA,kBAAqB;AAAA,SAE3B,uBAAWN,eAAX,CAF2B;AAAA,CAA3B;;;;AASA,IAAMO,mBAAmB,GAAG,SAAtBA,mBAAsB,CAIjCC,SAJiC,EAKqC;AACtE,MAAMC,4BAA4B,GAAG,SAA/BA,4BAA+B,CACnCC,KADmC,EAEhC;AACH,QAAMC,eAAe,GAAGL,kBAAkB,EAA1C;AAEA,WAAO,gCAAC,SAAD,gCAAgBI,KAAhB,EAAiCC,eAAjC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,OAAP;AACD,GAND;;AAOAF,EAAAA,4BAA4B,CAACG,WAA7B,2BAAiE,oCAAeJ,SAAf,CAAjE;AACA,SAAOC,4BAAP;AACD,CAfM","sourcesContent":["import React, { PropsWithChildren, useContext } from 'react';\n\nimport type { TouchableOpacityProps } from 'react-native';\n\nimport type { MessagePinnedHeaderProps } from 'src/components/Message/MessageSimple/MessagePinnedHeader';\n\nimport type { Attachment, ChannelState, MessageResponse } from 'stream-chat';\n\nimport type { AttachmentProps } from '../../components/Attachment/Attachment';\nimport type { AttachmentActionsProps } from '../../components/Attachment/AttachmentActions';\nimport type { CardProps } from '../../components/Attachment/Card';\nimport type { FileAttachmentProps } from '../../components/Attachment/FileAttachment';\nimport type { FileAttachmentGroupProps } from '../../components/Attachment/FileAttachmentGroup';\nimport type { FileIconProps } from '../../components/Attachment/FileIcon';\nimport type { GalleryProps } from '../../components/Attachment/Gallery';\nimport type { GiphyProps } from '../../components/Attachment/Giphy';\nimport type {\n MessageProps,\n MessageTouchableHandlerPayload,\n} from '../../components/Message/Message';\nimport type { MessageAvatarProps } from '../../components/Message/MessageSimple/MessageAvatar';\nimport type { MessageContentProps } from '../../components/Message/MessageSimple/MessageContent';\nimport type { MessageDeletedProps } from '../../components/Message/MessageSimple/MessageDeleted';\nimport type { MessageFooterProps } from '../../components/Message/MessageSimple/MessageFooter';\n\nimport type { MessageRepliesProps } from '../../components/Message/MessageSimple/MessageReplies';\nimport type { MessageRepliesAvatarsProps } from '../../components/Message/MessageSimple/MessageRepliesAvatars';\nimport type { MessageSimpleProps } from '../../components/Message/MessageSimple/MessageSimple';\nimport type { MessageStatusProps } from '../../components/Message/MessageSimple/MessageStatus';\nimport type { MessageTextProps } from '../../components/Message/MessageSimple/MessageTextContainer';\nimport type { ReactionListProps } from '../../components/Message/MessageSimple/ReactionList';\nimport type { MarkdownRules } from '../../components/Message/MessageSimple/utils/renderText';\nimport type { MessageActionsParams } from '../../components/Message/utils/messageActions';\nimport type { DateHeaderProps } from '../../components/MessageList/DateHeader';\nimport type { MessageType } from '../../components/MessageList/hooks/useMessageList';\nimport type { InlineDateSeparatorProps } from '../../components/MessageList/InlineDateSeparator';\nimport type { MessageListProps } from '../../components/MessageList/MessageList';\nimport type { MessageSystemProps } from '../../components/MessageList/MessageSystem';\nimport type { ScrollToBottomButtonProps } from '../../components/MessageList/ScrollToBottomButton';\nimport type { MessageActionType } from '../../components/MessageOverlay/MessageActionListItem';\nimport type { OverlayReactionListProps } from '../../components/MessageOverlay/OverlayReactionList';\nimport type { ReplyProps } from '../../components/Reply/Reply';\nimport type { FlatList } from '../../native';\nimport type { DefaultStreamChatGenerics, UnknownType } from '../../types/types';\nimport type { ReactionData } from '../../utils/utils';\nimport type { Alignment } from '../messageContext/MessageContext';\nimport type { SuggestionCommand } from '../suggestionsContext/SuggestionsContext';\nimport type { DeepPartial } from '../themeContext/ThemeContext';\nimport type { Theme } from '../themeContext/utils/theme';\nimport type { TDateTimeParserInput } from '../translationContext/TranslationContext';\nimport { getDisplayName } from '../utils/getDisplayName';\n\nexport type MessageContentType = 'attachments' | 'files' | 'gallery' | 'quoted_reply' | 'text';\n\nexport type MessagesContextValue<\n StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,\n> = {\n /**\n * UI component for Attachment.\n * Defaults to: [Attachment](https://github.com/GetStream/stream-chat-react-native/blob/master/src/components/Attachment/Attachment.tsx)\n */\n Attachment: React.ComponentType<AttachmentProps<StreamChatGenerics>>;\n /**\n * UI component to display AttachmentActions. e.g., send, shuffle, cancel in case of giphy\n * Defaults to: [AttachmentActions](https://github.com/GetStream/stream-chat-react-native/blob/master/src/components/Attachment/AttachmentActions.tsx)\n */\n AttachmentActions: React.ComponentType<AttachmentActionsProps<StreamChatGenerics>>;\n /**\n * UI component to display generic media type e.g. giphy, url preview etc\n * Defaults to: [Card](https://github.com/GetStream/stream-chat-react-native/blob/master/src/components/Attachment/Card.tsx)\n */\n Card: React.ComponentType<CardProps<StreamChatGenerics>>;\n /**\n * UI component for DateHeader\n * Defaults to: [DateHeader](https://github.com/GetStream/stream-chat-react-native/blob/master/src/components/MessageList/DateHeader.tsx)\n **/\n DateHeader: React.ComponentType<DateHeaderProps>;\n\n /** Should keyboard be dismissed when messaged is touched */\n dismissKeyboardOnMessageTouch: boolean;\n\n enableMessageGroupingByUser: boolean;\n\n /**\n * UI component to display File type attachment.\n * Defaults to: [FileAttachment](https://github.com/GetStream/stream-chat-react-native/blob/master/src/components/Attachment/FileAttachment.tsx)\n */\n FileAttachment: React.ComponentType<FileAttachmentProps<StreamChatGenerics>>;\n /**\n * UI component to display group of File type attachments or multiple file attachments (in single message).\n * Defaults to: [FileAttachmentGroup](https://github.com/GetStream/stream-chat-react-native/blob/master/src/components/Attachment/FileAttachmentGroup.tsx)\n */\n FileAttachmentGroup: React.ComponentType<FileAttachmentGroupProps<StreamChatGenerics>>;\n /**\n * UI component for attachment icon for type 'file' attachment.\n * Defaults to: https://github.com/GetStream/stream-chat-react-native/blob/master/src/components/Attachment/FileIcon.tsx\n */\n FileAttachmentIcon: React.ComponentType<FileIconProps>;\n FlatList: typeof FlatList;\n /**\n * UI component to display image attachments\n * Defaults to: [Gallery](https://github.com/GetStream/stream-chat-react-native/blob/master/src/components/Attachment/Gallery.tsx)\n */\n Gallery: React.ComponentType<GalleryProps<StreamChatGenerics>>;\n /**\n * UI component for Giphy\n * Defaults to: [Giphy](https://github.com/GetStream/stream-chat-react-native/blob/master/src/components/Attachment/Giphy.tsx)\n */\n Giphy: React.ComponentType<GiphyProps<StreamChatGenerics>>;\n /**\n * 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\n * */\n giphyVersion: keyof NonNullable<Attachment['giphy']>;\n /**\n * When true, messageList will be scrolled at first unread message, when opened.\n */\n initialScrollToFirstUnreadMessage: boolean;\n /**\n * UI component for Message Date Separator Component\n * Defaults to: [InlineDateSeparator](https://github.com/GetStream/stream-chat-react-native/blob/master/src/components/MessageList/InlineDateSeparator.tsx)\n */\n InlineDateSeparator: React.ComponentType<InlineDateSeparatorProps>;\n /**\n * UI component for InlineUnreadIndicator\n * Defaults to: [InlineUnreadIndicator](https://github.com/GetStream/stream-chat-react-native/blob/master/src/components/Message/MessageSimple/InlineUnreadIndicator.tsx)\n **/\n InlineUnreadIndicator: React.ComponentType;\n Message: React.ComponentType<MessageProps<StreamChatGenerics>>;\n /**\n * UI component for MessageAvatar\n * Defaults to: [MessageAvatar](https://github.com/GetStream/stream-chat-react-native/blob/master/src/components/Message/MessageSimple/MessageAvatar.tsx)\n **/\n MessageAvatar: React.ComponentType<MessageAvatarProps<StreamChatGenerics>>;\n /**\n * UI component for MessageContent\n * Defaults to: [MessageContent](https://github.com/GetStream/stream-chat-react-native/blob/master/src/components/Message/MessageSimple/MessageContent.tsx)\n */\n MessageContent: React.ComponentType<MessageContentProps<StreamChatGenerics>>;\n /** Order to render the message content */\n messageContentOrder: MessageContentType[];\n /**\n * UI component for MessageDeleted\n * Defaults to: [MessageDeleted](https://github.com/GetStream/stream-chat-react-native/blob/master/src/components/MessageSimple/MessageDeleted.tsx)\n */\n MessageDeleted: React.ComponentType<MessageDeletedProps<StreamChatGenerics>>;\n /**\n * Custom message footer component\n */\n MessageFooter: React.ComponentType<MessageFooterProps<StreamChatGenerics>>;\n MessageList: React.ComponentType<MessageListProps<StreamChatGenerics>>;\n /**\n * Custom message pinned component\n */\n MessagePinnedHeader: React.ComponentType<MessagePinnedHeaderProps<StreamChatGenerics>>;\n /**\n * UI component for MessageReplies\n * Defaults to: [MessageReplies](https://github.com/GetStream/stream-chat-react-native/blob/master/src/components/MessageSimple/MessageReplies.tsx)\n */\n\n MessageReplies: React.ComponentType<MessageRepliesProps<StreamChatGenerics>>;\n /**\n * UI Component for MessageRepliesAvatars\n * Defaults to: [MessageRepliesAvatars](https://github.com/GetStream/stream-chat-react-native/blob/master/src/components/MessageSimple/MessageRepliesAvatars.tsx)\n */\n MessageRepliesAvatars: React.ComponentType<MessageRepliesAvatarsProps<StreamChatGenerics>>;\n /**\n * UI component for MessageSimple\n * Defaults to: [MessageSimple](https://github.com/GetStream/stream-chat-react-native/blob/master/src/components/Message/MessageSimple/MessageSimple.tsx)\n */\n MessageSimple: React.ComponentType<MessageSimpleProps<StreamChatGenerics>>;\n /**\n * UI component for MessageStatus (delivered/read)\n * Defaults to: [MessageStatus](https://github.com/GetStream/stream-chat-react-native/blob/master/src/components/Message/MessageSimple/MessageStatus.tsx)\n */\n MessageStatus: React.ComponentType<MessageStatusProps<StreamChatGenerics>>;\n /**\n * UI component for MessageSystem\n * Defaults to: [MessageSystem](https://getstream.github.io/stream-chat-react-native/v3/#messagesystem)\n */\n MessageSystem: React.ComponentType<MessageSystemProps<StreamChatGenerics>>;\n /**\n * UI component for OverlayReactionList\n */\n OverlayReactionList: React.ComponentType<OverlayReactionListProps<StreamChatGenerics>>;\n /**\n * UI component for ReactionList\n * Defaults to: [ReactionList](https://github.com/GetStream/stream-chat-react-native/blob/master/src/components/Reaction/ReactionList.tsx)\n */\n ReactionList: React.ComponentType<ReactionListProps<StreamChatGenerics>>;\n removeMessage: (message: { id: string; parent_id?: string }) => void;\n /**\n * UI component for Reply\n * Defaults to: [Reply](https://getstream.github.io/stream-chat-react-native/v3/#reply)\n */\n Reply: React.ComponentType<ReplyProps<StreamChatGenerics>>;\n /**\n * Override the api request for retry message functionality.\n */\n retrySendMessage: (message: MessageResponse<StreamChatGenerics>) => Promise<void>;\n /**\n * UI component for ScrollToBottomButton\n * Defaults to: [ScrollToBottomButton](https://getstream.github.io/stream-chat-react-native/v3/#ScrollToBottomButton)\n */\n ScrollToBottomButton: React.ComponentType<ScrollToBottomButtonProps>;\n setEditingState: (message: MessageType<StreamChatGenerics>) => void;\n setQuotedMessageState: (message: MessageType<StreamChatGenerics>) => void;\n supportedReactions: ReactionData[];\n /**\n * UI component for TypingIndicator\n * Defaults to: [TypingIndicator](https://getstream.github.io/stream-chat-react-native/v3/#typingindicator)\n */\n TypingIndicator: React.ComponentType;\n /**\n * UI component for TypingIndicatorContainer\n * Defaults to: [TypingIndicatorContainer](https://getstream.github.io/stream-chat-react-native/v3/#typingindicatorcontainer)\n */\n TypingIndicatorContainer: React.ComponentType;\n updateMessage: (\n updatedMessage: MessageResponse<StreamChatGenerics>,\n extraState?: {\n commands?: SuggestionCommand<StreamChatGenerics>[];\n messageInput?: string;\n threadMessages?: ChannelState<StreamChatGenerics>['threads'][string];\n },\n ) => void;\n /**\n * Custom UI component to display enriched url preview.\n * Defaults to https://github.com/GetStream/stream-chat-react-native/blob/master/src/components/Attachment/Card.tsx\n */\n UrlPreview: React.ComponentType<CardProps<StreamChatGenerics>>;\n /**\n * Provide any additional props for `TouchableOpacity` which wraps inner MessageContent component here.\n * Please check docs for TouchableOpacity for supported props - https://reactnative.dev/docs/touchableopacity#props\n *\n * @overrideType Object\n */\n additionalTouchableProps?: Omit<TouchableOpacityProps, 'style'>;\n /**\n * Custom UI component to override default cover (between Header and Footer) of Card component.\n * Accepts the same props as Card component.\n */\n CardCover?: React.ComponentType<CardProps<StreamChatGenerics>>;\n /**\n * Custom UI component to override default Footer of Card component.\n * Accepts the same props as Card component.\n */\n CardFooter?: React.ComponentType<CardProps<StreamChatGenerics>>;\n /**\n * Custom UI component to override default header of Card component.\n * Accepts the same props as Card component.\n */\n CardHeader?: React.ComponentType<CardProps<StreamChatGenerics>>;\n\n /**\n * Full override of the delete message button in the Message Actions\n *\n * Please check [cookbook](https://github.com/GetStream/stream-chat-react-native/wiki/Cookbook-v3.0#override-or-intercept-message-actions-edit-delete-reaction-reply-etc) for details.\n */\n\n /** Control if the deleted message is visible to both the send and reciever, either of them or none */\n deletedMessagesVisibilityType?: 'always' | 'never' | 'receiver' | 'sender';\n\n disableTypingIndicator?: boolean;\n\n /**\n * Whether messages should be aligned to right or left part of screen.\n * By default, messages will be received messages will be aligned to left and\n * sent messages will be aligned to right.\n */\n forceAlignMessages?: Alignment | boolean;\n /**\n * Optional function to custom format the message date\n */\n formatDate?: (date: TDateTimeParserInput) => string;\n handleBlock?: (message: MessageType<StreamChatGenerics>) => Promise<void>;\n /** Handler to access when a copy message action is invoked */\n handleCopy?: (message: MessageType<StreamChatGenerics>) => Promise<void>;\n /** Handler to access when a delete message action is invoked */\n handleDelete?: (message: MessageType<StreamChatGenerics>) => Promise<void>;\n /** Handler to access when an edit message action is invoked */\n handleEdit?: (message: MessageType<StreamChatGenerics>) => void;\n /** Handler to access when a flag message action is invoked */\n handleFlag?: (message: MessageType<StreamChatGenerics>) => Promise<void>;\n /** Handler to access when a mute user action is invoked */\n handleMute?: (message: MessageType<StreamChatGenerics>) => Promise<void>;\n /** Handler to access when a pin/unpin user action is invoked*/\n handlePinMessage?: ((message: MessageType<StreamChatGenerics>) => MessageActionType) | null;\n /** Handler to access when a quoted reply action is invoked */\n handleQuotedReply?: (message: MessageType<StreamChatGenerics>) => Promise<void>;\n /** Handler to process a reaction */\n handleReaction?: (\n message: MessageType<StreamChatGenerics>,\n reactionType: string,\n ) => Promise<void>;\n /** Handler to access when a retry action is invoked */\n handleRetry?: (message: MessageType<StreamChatGenerics>) => Promise<void>;\n /** Handler to access when a thread reply action is invoked */\n handleThreadReply?: (message: MessageType<StreamChatGenerics>) => Promise<void>;\n legacyImageViewerSwipeBehaviour?: boolean;\n /** Object specifying rules defined within simple-markdown https://github.com/Khan/simple-markdown#adding-a-simple-extension */\n markdownRules?: MarkdownRules;\n /**\n * Use this prop to override message actions (which pop-up in message overlay).\n *\n * You can either completely override the default messageActions object.\n *\n * ```\n * <Channel\n * messageActions=[\n * {\n * action: () => { someAction() };\n * title: \"Pin Message\";\n * icon: PinIcon;\n * titleStyle: {};\n * },\n * {\n * action: () => { someAction() };\n * title: \"Delete Message\";\n * icon: PinIcon;\n * titleStyle: {};\n * }\n * ]\n * >\n * </Channel>\n * ```\n *\n * Or you can selectly keep certain action and remove some:\n *\n * e.g. Lets say you only want to keep threadReply and copyMessage actions\n *\n * ```\n * <Channel\n * messageActions={({\n * blockUser,\n * copyMessage,\n * deleteMessage,\n * editMessage,\n * flagMessage,\n * muteUser,\n * quotedReply,\n * retry,\n * threadReply,\n * }) => ([\n * threadReply, copyMessage\n * ])}\n * >\n * </Channel>\n * ```\n *\n * @overrideType Function | Array<Objects>\n */\n messageActions?: (param: MessageActionsParams<StreamChatGenerics>) => MessageActionType[];\n /**\n * Custom message header component\n */\n MessageHeader?: React.ComponentType<MessageFooterProps<StreamChatGenerics>>;\n /** Custom UI component for message text */\n MessageText?: React.ComponentType<MessageTextProps<StreamChatGenerics>>;\n\n /**\n * Theme provided only to messages that are the current users\n */\n myMessageTheme?: DeepPartial<Theme>;\n /**\n * Override default handler for onLongPress on message. You have access to payload of that handler as param:\n *\n * ```\n * <Channel\n * onLongPressMessage={({\n * actionHandlers: {\n * deleteMessage, // () => Promise<void>;\n * editMessage, // () => void;\n * quotedReply, // () => void;\n * resendMessage, // () => Promise<void>;\n * showMessageOverlay, // () => void;\n * toggleBanUser, // () => Promise<void>;\n * toggleMuteUser, // () => Promise<void>;\n * toggleReaction, // (reactionType: string) => Promise<void>;\n * },\n * defaultHandler, // () => void\n * event, // any event object corresponding to touchable feedback\n * emitter, // which component trigged this touchable feedback e.g. card, fileAttachment, gallery, message ... etc\n * message // message object on which longPress occured\n * }) => {\n * // Your custom action\n * }}\n * />\n * ```\n */\n onLongPressMessage?: (payload: MessageTouchableHandlerPayload<StreamChatGenerics>) => void;\n /**\n * Add onPressIn handler for attachments. You have access to payload of that handler as param:\n *\n * ```\n * <Channel\n * onPressInMessage={({\n * actionHandlers: {\n * deleteMessage, // () => Promise<void>;\n * editMessage, // () => void;\n * quotedReply, // () => void;\n * resendMessage, // () => Promise<void>;\n * showMessageOverlay, // () => void;\n * toggleBanUser, // () => Promise<void>;\n * toggleMuteUser, // () => Promise<void>;\n * toggleReaction, // (reactionType: string) => Promise<void>;\n * },\n * defaultHandler, // () => void\n * event, // any event object corresponding to touchable feedback\n * emitter, // which component trigged this touchable feedback e.g. card, fileAttachment, gallery, message ... etc\n * message // message object on which longPress occured\n * }) => {\n * // Your custom action\n * }}\n * />\n * ```\n */\n onPressInMessage?: (payload: MessageTouchableHandlerPayload<StreamChatGenerics>) => void;\n /**\n * Override onPress handler for message. You have access to payload of that handler as param:\n *\n * ```\n * <Channel\n * onPressMessage={({\n * actionHandlers: {\n * deleteMessage, // () => Promise<void>;\n * editMessage, // () => void;\n * quotedReply, // () => void;\n * resendMessage, // () => Promise<void>;\n * showMessageOverlay, // () => void;\n * toggleBanUser, // () => Promise<void>;\n * toggleMuteUser, // () => Promise<void>;\n * toggleReaction, // (reactionType: string) => Promise<void>;\n * },\n * defaultHandler, // () => void\n * event, // any event object corresponding to touchable feedback\n * emitter, // which component trigged this touchable feedback e.g. card, fileAttachment, gallery, message ... etc\n * message // message object on which longPress occurred\n * }) => {\n * // Your custom action\n * }}\n * />\n * ```\n */\n onPressMessage?: (payload: MessageTouchableHandlerPayload<StreamChatGenerics>) => void;\n\n /**\n * Full override of the reaction function on Message and Message Overlay\n *\n * Please check [cookbook](https://github.com/GetStream/stream-chat-react-native/wiki/Cookbook-v3.0#override-or-intercept-message-actions-edit-delete-reaction-reply-etc) for details.\n * */\n selectReaction?: (\n message: MessageType<StreamChatGenerics>,\n ) => (reactionType: string) => Promise<void>;\n\n targetedMessage?: string;\n};\n\nexport const MessagesContext = React.createContext({} as MessagesContextValue);\n\nexport const MessagesProvider = <\n StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,\n>({\n children,\n value,\n}: PropsWithChildren<{\n value?: MessagesContextValue<StreamChatGenerics>;\n}>) => (\n <MessagesContext.Provider value={value as unknown as MessagesContextValue}>\n {children}\n </MessagesContext.Provider>\n);\n\nexport const useMessagesContext = <\n StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,\n>() => useContext(MessagesContext) as unknown as MessagesContextValue<StreamChatGenerics>;\n\n/**\n * Typescript currently does not support partial inference so if MessagesContext\n * typing is desired while using the HOC withMessagesContext the Props for the\n * wrapped component must be provided as the first generic.\n */\nexport const withMessagesContext = <\n P extends UnknownType,\n StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,\n>(\n Component: React.ComponentType<P>,\n): React.FC<Omit<P, keyof MessagesContextValue<StreamChatGenerics>>> => {\n const WithMessagesContextComponent = (\n props: Omit<P, keyof MessagesContextValue<StreamChatGenerics>>,\n ) => {\n const messagesContext = useMessagesContext<StreamChatGenerics>();\n\n return <Component {...(props as P)} {...messagesContext} />;\n };\n WithMessagesContextComponent.displayName = `WithMessagesContext${getDisplayName(Component)}`;\n return WithMessagesContextComponent;\n};\n"]}
|
|
1
|
+
{"version":3,"sources":["MessagesContext.tsx"],"names":["MessagesContext","React","createContext","MessagesProvider","children","value","useMessagesContext","withMessagesContext","Component","WithMessagesContextComponent","props","messagesContext","displayName"],"mappings":";;;;;;;;;;;AAAA;;AAkDA;;;;;;;;;AA4ZO,IAAMA,eAAe,GAAGC,kBAAMC,aAAN,CAAoB,EAApB,CAAxB;;;;AAEA,IAAMC,gBAAgB,GAAG,SAAnBA,gBAAmB;AAAA,MAG9BC,QAH8B,QAG9BA,QAH8B;AAAA,MAI9BC,KAJ8B,QAI9BA,KAJ8B;AAAA,SAQ9B,gCAAC,eAAD,CAAiB,QAAjB;AAA0B,IAAA,KAAK,EAAEA,KAAjC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,KACGD,QADH,CAR8B;AAAA,CAAzB;;;;AAaA,IAAME,kBAAkB,GAAG,SAArBA,kBAAqB;AAAA,SAE3B,uBAAWN,eAAX,CAF2B;AAAA,CAA3B;;;;AASA,IAAMO,mBAAmB,GAAG,SAAtBA,mBAAsB,CAIjCC,SAJiC,EAKqC;AACtE,MAAMC,4BAA4B,GAAG,SAA/BA,4BAA+B,CACnCC,KADmC,EAEhC;AACH,QAAMC,eAAe,GAAGL,kBAAkB,EAA1C;AAEA,WAAO,gCAAC,SAAD,gCAAgBI,KAAhB,EAAiCC,eAAjC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,OAAP;AACD,GAND;;AAOAF,EAAAA,4BAA4B,CAACG,WAA7B,2BAAiE,oCAAeJ,SAAf,CAAjE;AACA,SAAOC,4BAAP;AACD,CAfM","sourcesContent":["import React, { PropsWithChildren, useContext } from 'react';\n\nimport type { TouchableOpacityProps } from 'react-native';\n\nimport type { MessagePinnedHeaderProps } from 'src/components/Message/MessageSimple/MessagePinnedHeader';\n\nimport type { Attachment, ChannelState, MessageResponse } from 'stream-chat';\n\nimport type { AttachmentProps } from '../../components/Attachment/Attachment';\nimport type { AttachmentActionsProps } from '../../components/Attachment/AttachmentActions';\nimport type { CardProps } from '../../components/Attachment/Card';\nimport type { FileAttachmentProps } from '../../components/Attachment/FileAttachment';\nimport type { FileAttachmentGroupProps } from '../../components/Attachment/FileAttachmentGroup';\nimport type { FileIconProps } from '../../components/Attachment/FileIcon';\nimport type { GalleryProps } from '../../components/Attachment/Gallery';\nimport type { GiphyProps } from '../../components/Attachment/Giphy';\nimport type {\n MessageProps,\n MessageTouchableHandlerPayload,\n} from '../../components/Message/Message';\nimport type { MessageAvatarProps } from '../../components/Message/MessageSimple/MessageAvatar';\nimport type { MessageContentProps } from '../../components/Message/MessageSimple/MessageContent';\nimport type { MessageDeletedProps } from '../../components/Message/MessageSimple/MessageDeleted';\nimport type { MessageFooterProps } from '../../components/Message/MessageSimple/MessageFooter';\n\nimport type { MessageRepliesProps } from '../../components/Message/MessageSimple/MessageReplies';\nimport type { MessageRepliesAvatarsProps } from '../../components/Message/MessageSimple/MessageRepliesAvatars';\nimport type { MessageSimpleProps } from '../../components/Message/MessageSimple/MessageSimple';\nimport type { MessageStatusProps } from '../../components/Message/MessageSimple/MessageStatus';\nimport type { MessageTextProps } from '../../components/Message/MessageSimple/MessageTextContainer';\nimport type { ReactionListProps } from '../../components/Message/MessageSimple/ReactionList';\nimport type { MarkdownRules } from '../../components/Message/MessageSimple/utils/renderText';\nimport type { MessageActionsParams } from '../../components/Message/utils/messageActions';\nimport type { DateHeaderProps } from '../../components/MessageList/DateHeader';\nimport type { MessageType } from '../../components/MessageList/hooks/useMessageList';\nimport type { InlineDateSeparatorProps } from '../../components/MessageList/InlineDateSeparator';\nimport type { MessageListProps } from '../../components/MessageList/MessageList';\nimport type { MessageSystemProps } from '../../components/MessageList/MessageSystem';\nimport type { ScrollToBottomButtonProps } from '../../components/MessageList/ScrollToBottomButton';\nimport type { MessageActionType } from '../../components/MessageOverlay/MessageActionListItem';\nimport type { OverlayReactionListProps } from '../../components/MessageOverlay/OverlayReactionList';\nimport type { ReplyProps } from '../../components/Reply/Reply';\nimport type { FlatList } from '../../native';\nimport type { DefaultStreamChatGenerics, UnknownType } from '../../types/types';\nimport type { ReactionData } from '../../utils/utils';\nimport type { Alignment } from '../messageContext/MessageContext';\nimport type { SuggestionCommand } from '../suggestionsContext/SuggestionsContext';\nimport type { DeepPartial } from '../themeContext/ThemeContext';\nimport type { Theme } from '../themeContext/utils/theme';\nimport type { TDateTimeParserInput } from '../translationContext/TranslationContext';\nimport { getDisplayName } from '../utils/getDisplayName';\n\nexport type MessageContentType = 'attachments' | 'files' | 'gallery' | 'quoted_reply' | 'text';\n\nexport type MessagesContextValue<\n StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,\n> = {\n /**\n * UI component for Attachment.\n * Defaults to: [Attachment](https://github.com/GetStream/stream-chat-react-native/blob/master/src/components/Attachment/Attachment.tsx)\n */\n Attachment: React.ComponentType<AttachmentProps<StreamChatGenerics>>;\n /**\n * UI component to display AttachmentActions. e.g., send, shuffle, cancel in case of giphy\n * Defaults to: [AttachmentActions](https://github.com/GetStream/stream-chat-react-native/blob/master/src/components/Attachment/AttachmentActions.tsx)\n */\n AttachmentActions: React.ComponentType<AttachmentActionsProps<StreamChatGenerics>>;\n /**\n * UI component to display generic media type e.g. giphy, url preview etc\n * Defaults to: [Card](https://github.com/GetStream/stream-chat-react-native/blob/master/src/components/Attachment/Card.tsx)\n */\n Card: React.ComponentType<CardProps<StreamChatGenerics>>;\n /**\n * UI component for DateHeader\n * Defaults to: [DateHeader](https://github.com/GetStream/stream-chat-react-native/blob/master/src/components/MessageList/DateHeader.tsx)\n **/\n DateHeader: React.ComponentType<DateHeaderProps>;\n\n /** Should keyboard be dismissed when messaged is touched */\n dismissKeyboardOnMessageTouch: boolean;\n\n enableMessageGroupingByUser: boolean;\n\n /**\n * UI component to display File type attachment.\n * Defaults to: [FileAttachment](https://github.com/GetStream/stream-chat-react-native/blob/master/src/components/Attachment/FileAttachment.tsx)\n */\n FileAttachment: React.ComponentType<FileAttachmentProps<StreamChatGenerics>>;\n /**\n * UI component to display group of File type attachments or multiple file attachments (in single message).\n * Defaults to: [FileAttachmentGroup](https://github.com/GetStream/stream-chat-react-native/blob/master/src/components/Attachment/FileAttachmentGroup.tsx)\n */\n FileAttachmentGroup: React.ComponentType<FileAttachmentGroupProps<StreamChatGenerics>>;\n /**\n * UI component for attachment icon for type 'file' attachment.\n * Defaults to: https://github.com/GetStream/stream-chat-react-native/blob/master/src/components/Attachment/FileIcon.tsx\n */\n FileAttachmentIcon: React.ComponentType<FileIconProps>;\n FlatList: typeof FlatList;\n /**\n * UI component to display image attachments\n * Defaults to: [Gallery](https://github.com/GetStream/stream-chat-react-native/blob/master/src/components/Attachment/Gallery.tsx)\n */\n Gallery: React.ComponentType<GalleryProps<StreamChatGenerics>>;\n /**\n * UI component for Giphy\n * Defaults to: [Giphy](https://github.com/GetStream/stream-chat-react-native/blob/master/src/components/Attachment/Giphy.tsx)\n */\n Giphy: React.ComponentType<GiphyProps<StreamChatGenerics>>;\n /**\n * 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\n * */\n giphyVersion: keyof NonNullable<Attachment['giphy']>;\n /**\n * When true, messageList will be scrolled at first unread message, when opened.\n */\n initialScrollToFirstUnreadMessage: boolean;\n /**\n * UI component for Message Date Separator Component\n * Defaults to: [InlineDateSeparator](https://github.com/GetStream/stream-chat-react-native/blob/master/src/components/MessageList/InlineDateSeparator.tsx)\n */\n InlineDateSeparator: React.ComponentType<InlineDateSeparatorProps>;\n /**\n * UI component for InlineUnreadIndicator\n * Defaults to: [InlineUnreadIndicator](https://github.com/GetStream/stream-chat-react-native/blob/master/src/components/Message/MessageSimple/InlineUnreadIndicator.tsx)\n **/\n InlineUnreadIndicator: React.ComponentType;\n Message: React.ComponentType<MessageProps<StreamChatGenerics>>;\n /**\n * UI component for MessageAvatar\n * Defaults to: [MessageAvatar](https://github.com/GetStream/stream-chat-react-native/blob/master/src/components/Message/MessageSimple/MessageAvatar.tsx)\n **/\n MessageAvatar: React.ComponentType<MessageAvatarProps<StreamChatGenerics>>;\n /**\n * UI component for MessageContent\n * Defaults to: [MessageContent](https://github.com/GetStream/stream-chat-react-native/blob/master/src/components/Message/MessageSimple/MessageContent.tsx)\n */\n MessageContent: React.ComponentType<MessageContentProps<StreamChatGenerics>>;\n /** Order to render the message content */\n messageContentOrder: MessageContentType[];\n /**\n * UI component for MessageDeleted\n * Defaults to: [MessageDeleted](https://github.com/GetStream/stream-chat-react-native/blob/master/src/components/MessageSimple/MessageDeleted.tsx)\n */\n MessageDeleted: React.ComponentType<MessageDeletedProps<StreamChatGenerics>>;\n /**\n * Custom message footer component\n */\n MessageFooter: React.ComponentType<MessageFooterProps<StreamChatGenerics>>;\n MessageList: React.ComponentType<MessageListProps<StreamChatGenerics>>;\n /**\n * Custom message pinned component\n */\n MessagePinnedHeader: React.ComponentType<MessagePinnedHeaderProps<StreamChatGenerics>>;\n /**\n * UI component for MessageReplies\n * Defaults to: [MessageReplies](https://github.com/GetStream/stream-chat-react-native/blob/master/src/components/MessageSimple/MessageReplies.tsx)\n */\n\n MessageReplies: React.ComponentType<MessageRepliesProps<StreamChatGenerics>>;\n /**\n * UI Component for MessageRepliesAvatars\n * Defaults to: [MessageRepliesAvatars](https://github.com/GetStream/stream-chat-react-native/blob/master/src/components/MessageSimple/MessageRepliesAvatars.tsx)\n */\n MessageRepliesAvatars: React.ComponentType<MessageRepliesAvatarsProps<StreamChatGenerics>>;\n /**\n * UI component for MessageSimple\n * Defaults to: [MessageSimple](https://github.com/GetStream/stream-chat-react-native/blob/master/src/components/Message/MessageSimple/MessageSimple.tsx)\n */\n MessageSimple: React.ComponentType<MessageSimpleProps<StreamChatGenerics>>;\n /**\n * UI component for MessageStatus (delivered/read)\n * Defaults to: [MessageStatus](https://github.com/GetStream/stream-chat-react-native/blob/master/src/components/Message/MessageSimple/MessageStatus.tsx)\n */\n MessageStatus: React.ComponentType<MessageStatusProps<StreamChatGenerics>>;\n /**\n * UI component for MessageSystem\n * Defaults to: [MessageSystem](https://getstream.github.io/stream-chat-react-native/v3/#messagesystem)\n */\n MessageSystem: React.ComponentType<MessageSystemProps<StreamChatGenerics>>;\n /**\n * UI component for OverlayReactionList\n */\n OverlayReactionList: React.ComponentType<OverlayReactionListProps<StreamChatGenerics>>;\n /**\n * UI component for ReactionList\n * Defaults to: [ReactionList](https://github.com/GetStream/stream-chat-react-native/blob/master/src/components/Reaction/ReactionList.tsx)\n */\n ReactionList: React.ComponentType<ReactionListProps<StreamChatGenerics>>;\n removeMessage: (message: { id: string; parent_id?: string }) => void;\n /**\n * UI component for Reply\n * Defaults to: [Reply](https://getstream.github.io/stream-chat-react-native/v3/#reply)\n */\n Reply: React.ComponentType<ReplyProps<StreamChatGenerics>>;\n /**\n * Override the api request for retry message functionality.\n */\n retrySendMessage: (message: MessageResponse<StreamChatGenerics>) => Promise<void>;\n /**\n * UI component for ScrollToBottomButton\n * Defaults to: [ScrollToBottomButton](https://getstream.github.io/stream-chat-react-native/v3/#ScrollToBottomButton)\n */\n ScrollToBottomButton: React.ComponentType<ScrollToBottomButtonProps>;\n setEditingState: (message: MessageType<StreamChatGenerics>) => void;\n setQuotedMessageState: (message: MessageType<StreamChatGenerics>) => void;\n supportedReactions: ReactionData[];\n /**\n * UI component for TypingIndicator\n * Defaults to: [TypingIndicator](https://getstream.github.io/stream-chat-react-native/v3/#typingindicator)\n */\n TypingIndicator: React.ComponentType;\n /**\n * UI component for TypingIndicatorContainer\n * Defaults to: [TypingIndicatorContainer](https://getstream.github.io/stream-chat-react-native/v3/#typingindicatorcontainer)\n */\n TypingIndicatorContainer: React.ComponentType;\n updateMessage: (\n updatedMessage: MessageResponse<StreamChatGenerics>,\n extraState?: {\n commands?: SuggestionCommand<StreamChatGenerics>[];\n messageInput?: string;\n threadMessages?: ChannelState<StreamChatGenerics>['threads'][string];\n },\n ) => void;\n /**\n * Custom UI component to display enriched url preview.\n * Defaults to https://github.com/GetStream/stream-chat-react-native/blob/master/src/components/Attachment/Card.tsx\n */\n UrlPreview: React.ComponentType<CardProps<StreamChatGenerics>>;\n /**\n * Provide any additional props for `TouchableOpacity` which wraps inner MessageContent component here.\n * Please check docs for TouchableOpacity for supported props - https://reactnative.dev/docs/touchableopacity#props\n *\n * @overrideType Object\n */\n additionalTouchableProps?: Omit<TouchableOpacityProps, 'style'>;\n /**\n * Custom UI component to override default cover (between Header and Footer) of Card component.\n * Accepts the same props as Card component.\n */\n CardCover?: React.ComponentType<CardProps<StreamChatGenerics>>;\n /**\n * Custom UI component to override default Footer of Card component.\n * Accepts the same props as Card component.\n */\n CardFooter?: React.ComponentType<CardProps<StreamChatGenerics>>;\n /**\n * Custom UI component to override default header of Card component.\n * Accepts the same props as Card component.\n */\n CardHeader?: React.ComponentType<CardProps<StreamChatGenerics>>;\n\n /**\n * Full override of the delete message button in the Message Actions\n *\n * Please check [cookbook](https://github.com/GetStream/stream-chat-react-native/wiki/Cookbook-v3.0#override-or-intercept-message-actions-edit-delete-reaction-reply-etc) for details.\n */\n\n /** Control if the deleted message is visible to both the send and reciever, either of them or none */\n deletedMessagesVisibilityType?: 'always' | 'never' | 'receiver' | 'sender';\n\n disableTypingIndicator?: boolean;\n\n /**\n * Whether messages should be aligned to right or left part of screen.\n * By default, messages will be received messages will be aligned to left and\n * sent messages will be aligned to right.\n */\n forceAlignMessages?: Alignment | boolean;\n /**\n * Optional function to custom format the message date\n */\n formatDate?: (date: TDateTimeParserInput) => string;\n handleBlock?: (message: MessageType<StreamChatGenerics>) => Promise<void>;\n /** Handler to access when a copy message action is invoked */\n handleCopy?: (message: MessageType<StreamChatGenerics>) => Promise<void>;\n /** Handler to access when a delete message action is invoked */\n handleDelete?: (message: MessageType<StreamChatGenerics>) => Promise<void>;\n /** Handler to access when an edit message action is invoked */\n handleEdit?: (message: MessageType<StreamChatGenerics>) => void;\n /** Handler to access when a flag message action is invoked */\n handleFlag?: (message: MessageType<StreamChatGenerics>) => Promise<void>;\n /** Handler to access when a mute user action is invoked */\n handleMute?: (message: MessageType<StreamChatGenerics>) => Promise<void>;\n /** Handler to access when a pin/unpin user action is invoked*/\n handlePinMessage?: ((message: MessageType<StreamChatGenerics>) => MessageActionType) | null;\n /** Handler to access when a quoted reply action is invoked */\n handleQuotedReply?: (message: MessageType<StreamChatGenerics>) => Promise<void>;\n /** Handler to process a reaction */\n handleReaction?: (\n message: MessageType<StreamChatGenerics>,\n reactionType: string,\n ) => Promise<void>;\n /** Handler to access when a retry action is invoked */\n handleRetry?: (message: MessageType<StreamChatGenerics>) => Promise<void>;\n /** Handler to access when a thread reply action is invoked */\n handleThreadReply?: (message: MessageType<StreamChatGenerics>) => Promise<void>;\n /** Handler to deal with custom memoization logic of Attachment */\n isAttachmentEqual?: (\n prevAttachment: Attachment<StreamChatGenerics>,\n nextAttachment: Attachment<StreamChatGenerics>,\n ) => boolean;\n legacyImageViewerSwipeBehaviour?: boolean;\n /** Object specifying rules defined within simple-markdown https://github.com/Khan/simple-markdown#adding-a-simple-extension */\n markdownRules?: MarkdownRules;\n /**\n * Use this prop to override message actions (which pop-up in message overlay).\n *\n * You can either completely override the default messageActions object.\n *\n * ```\n * <Channel\n * messageActions=[\n * {\n * action: () => { someAction() };\n * title: \"Pin Message\";\n * icon: PinIcon;\n * titleStyle: {};\n * },\n * {\n * action: () => { someAction() };\n * title: \"Delete Message\";\n * icon: PinIcon;\n * titleStyle: {};\n * }\n * ]\n * >\n * </Channel>\n * ```\n *\n * Or you can selectly keep certain action and remove some:\n *\n * e.g. Lets say you only want to keep threadReply and copyMessage actions\n *\n * ```\n * <Channel\n * messageActions={({\n * blockUser,\n * copyMessage,\n * deleteMessage,\n * editMessage,\n * flagMessage,\n * muteUser,\n * quotedReply,\n * retry,\n * threadReply,\n * }) => ([\n * threadReply, copyMessage\n * ])}\n * >\n * </Channel>\n * ```\n *\n * @overrideType Function | Array<Objects>\n */\n messageActions?: (param: MessageActionsParams<StreamChatGenerics>) => MessageActionType[];\n /**\n * Custom message header component\n */\n MessageHeader?: React.ComponentType<MessageFooterProps<StreamChatGenerics>>;\n /** Custom UI component for message text */\n MessageText?: React.ComponentType<MessageTextProps<StreamChatGenerics>>;\n\n /**\n * Theme provided only to messages that are the current users\n */\n myMessageTheme?: DeepPartial<Theme>;\n /**\n * Override default handler for onLongPress on message. You have access to payload of that handler as param:\n *\n * ```\n * <Channel\n * onLongPressMessage={({\n * actionHandlers: {\n * deleteMessage, // () => Promise<void>;\n * editMessage, // () => void;\n * quotedReply, // () => void;\n * resendMessage, // () => Promise<void>;\n * showMessageOverlay, // () => void;\n * toggleBanUser, // () => Promise<void>;\n * toggleMuteUser, // () => Promise<void>;\n * toggleReaction, // (reactionType: string) => Promise<void>;\n * },\n * defaultHandler, // () => void\n * event, // any event object corresponding to touchable feedback\n * emitter, // which component trigged this touchable feedback e.g. card, fileAttachment, gallery, message ... etc\n * message // message object on which longPress occured\n * }) => {\n * // Your custom action\n * }}\n * />\n * ```\n */\n onLongPressMessage?: (payload: MessageTouchableHandlerPayload<StreamChatGenerics>) => void;\n /**\n * Add onPressIn handler for attachments. You have access to payload of that handler as param:\n *\n * ```\n * <Channel\n * onPressInMessage={({\n * actionHandlers: {\n * deleteMessage, // () => Promise<void>;\n * editMessage, // () => void;\n * quotedReply, // () => void;\n * resendMessage, // () => Promise<void>;\n * showMessageOverlay, // () => void;\n * toggleBanUser, // () => Promise<void>;\n * toggleMuteUser, // () => Promise<void>;\n * toggleReaction, // (reactionType: string) => Promise<void>;\n * },\n * defaultHandler, // () => void\n * event, // any event object corresponding to touchable feedback\n * emitter, // which component trigged this touchable feedback e.g. card, fileAttachment, gallery, message ... etc\n * message // message object on which longPress occured\n * }) => {\n * // Your custom action\n * }}\n * />\n * ```\n */\n onPressInMessage?: (payload: MessageTouchableHandlerPayload<StreamChatGenerics>) => void;\n /**\n * Override onPress handler for message. You have access to payload of that handler as param:\n *\n * ```\n * <Channel\n * onPressMessage={({\n * actionHandlers: {\n * deleteMessage, // () => Promise<void>;\n * editMessage, // () => void;\n * quotedReply, // () => void;\n * resendMessage, // () => Promise<void>;\n * showMessageOverlay, // () => void;\n * toggleBanUser, // () => Promise<void>;\n * toggleMuteUser, // () => Promise<void>;\n * toggleReaction, // (reactionType: string) => Promise<void>;\n * },\n * defaultHandler, // () => void\n * event, // any event object corresponding to touchable feedback\n * emitter, // which component trigged this touchable feedback e.g. card, fileAttachment, gallery, message ... etc\n * message // message object on which longPress occurred\n * }) => {\n * // Your custom action\n * }}\n * />\n * ```\n */\n onPressMessage?: (payload: MessageTouchableHandlerPayload<StreamChatGenerics>) => void;\n\n /**\n * Full override of the reaction function on Message and Message Overlay\n *\n * Please check [cookbook](https://github.com/GetStream/stream-chat-react-native/wiki/Cookbook-v3.0#override-or-intercept-message-actions-edit-delete-reaction-reply-etc) for details.\n * */\n selectReaction?: (\n message: MessageType<StreamChatGenerics>,\n ) => (reactionType: string) => Promise<void>;\n\n targetedMessage?: string;\n};\n\nexport const MessagesContext = React.createContext({} as MessagesContextValue);\n\nexport const MessagesProvider = <\n StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,\n>({\n children,\n value,\n}: PropsWithChildren<{\n value?: MessagesContextValue<StreamChatGenerics>;\n}>) => (\n <MessagesContext.Provider value={value as unknown as MessagesContextValue}>\n {children}\n </MessagesContext.Provider>\n);\n\nexport const useMessagesContext = <\n StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,\n>() => useContext(MessagesContext) as unknown as MessagesContextValue<StreamChatGenerics>;\n\n/**\n * Typescript currently does not support partial inference so if MessagesContext\n * typing is desired while using the HOC withMessagesContext the Props for the\n * wrapped component must be provided as the first generic.\n */\nexport const withMessagesContext = <\n P extends UnknownType,\n StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,\n>(\n Component: React.ComponentType<P>,\n): React.FC<Omit<P, keyof MessagesContextValue<StreamChatGenerics>>> => {\n const WithMessagesContextComponent = (\n props: Omit<P, keyof MessagesContextValue<StreamChatGenerics>>,\n ) => {\n const messagesContext = useMessagesContext<StreamChatGenerics>();\n\n return <Component {...(props as P)} {...messagesContext} />;\n };\n WithMessagesContextComponent.displayName = `WithMessagesContext${getDisplayName(Component)}`;\n return WithMessagesContextComponent;\n};\n"]}
|
package/lib/module/version.json
CHANGED
|
@@ -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
|
*/
|
|
@@ -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;
|
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.0-beta.
|
|
4
|
+
"version": "4.3.0-beta.5",
|
|
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,
|
|
@@ -21,6 +21,10 @@ export const useCreateOwnCapabilitiesContext = <
|
|
|
21
21
|
const overrideCapabilitiesStr = overrideCapabilities
|
|
22
22
|
? JSON.stringify(Object.values(overrideCapabilities))
|
|
23
23
|
: null;
|
|
24
|
+
const ownCapabilitiesStr = channel?.data?.own_capabilities
|
|
25
|
+
? JSON.stringify(Object.values(channel?.data?.own_capabilities as Array<string>))
|
|
26
|
+
: null;
|
|
27
|
+
|
|
24
28
|
const ownCapabilitiesContext: OwnCapabilitiesContextValue = useMemo(() => {
|
|
25
29
|
const capabilities = (channel?.data?.own_capabilities || []) as Array<string>;
|
|
26
30
|
const ownCapabilitiesContext = Object.keys(allOwnCapabilities).reduce(
|
|
@@ -34,6 +38,7 @@ export const useCreateOwnCapabilitiesContext = <
|
|
|
34
38
|
);
|
|
35
39
|
|
|
36
40
|
return ownCapabilitiesContext;
|
|
37
|
-
}, [channel.id, overrideCapabilitiesStr]);
|
|
41
|
+
}, [channel.id, overrideCapabilitiesStr, ownCapabilitiesStr]);
|
|
42
|
+
|
|
38
43
|
return ownCapabilitiesContext;
|
|
39
44
|
};
|
|
@@ -23,7 +23,7 @@ export const useCreatePaginatedMessageListContext = <
|
|
|
23
23
|
({ deleted_at, latest_reactions, reply_count, status, updated_at }) =>
|
|
24
24
|
`${deleted_at}${
|
|
25
25
|
latest_reactions ? latest_reactions.map(({ type }) => type).join() : ''
|
|
26
|
-
}${reply_count}${status}${updated_at
|
|
26
|
+
}${reply_count}${status}${updated_at?.toISOString?.() || updated_at}`,
|
|
27
27
|
)
|
|
28
28
|
.join();
|
|
29
29
|
|
|
@@ -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,
|