stream-chat-react-native-core 4.7.0 → 4.7.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/Card.js +61 -21
- package/lib/commonjs/components/Attachment/Card.js.map +1 -1
- package/lib/commonjs/components/AutoCompleteInput/AutoCompleteSuggestionList.js +1 -1
- package/lib/commonjs/components/AutoCompleteInput/AutoCompleteSuggestionList.js.map +1 -1
- package/lib/commonjs/components/MessageInput/SendMessageDisallowedIndicator.js +2 -2
- package/lib/commonjs/components/MessageInput/SendMessageDisallowedIndicator.js.map +1 -1
- package/lib/commonjs/components/Reply/Reply.js +12 -12
- package/lib/commonjs/components/Reply/Reply.js.map +1 -1
- package/lib/commonjs/contexts/activeChannelsRefContext/ActiveChannelsRefContext.js +2 -2
- package/lib/commonjs/contexts/activeChannelsRefContext/ActiveChannelsRefContext.js.map +1 -1
- package/lib/commonjs/contexts/attachmentPickerContext/AttachmentPickerContext.js +14 -4
- package/lib/commonjs/contexts/attachmentPickerContext/AttachmentPickerContext.js.map +1 -1
- package/lib/commonjs/contexts/channelContext/ChannelContext.js +14 -4
- package/lib/commonjs/contexts/channelContext/ChannelContext.js.map +1 -1
- package/lib/commonjs/contexts/channelsContext/ChannelsContext.js +14 -4
- package/lib/commonjs/contexts/channelsContext/ChannelsContext.js.map +1 -1
- package/lib/commonjs/contexts/channelsStateContext/ChannelsStateContext.js +15 -9
- package/lib/commonjs/contexts/channelsStateContext/ChannelsStateContext.js.map +1 -1
- package/lib/commonjs/contexts/chatContext/ChatContext.js +14 -4
- package/lib/commonjs/contexts/chatContext/ChatContext.js.map +1 -1
- package/lib/commonjs/contexts/imageGalleryContext/ImageGalleryContext.js +14 -4
- package/lib/commonjs/contexts/imageGalleryContext/ImageGalleryContext.js.map +1 -1
- package/lib/commonjs/contexts/keyboardContext/KeyboardContext.js +2 -2
- package/lib/commonjs/contexts/keyboardContext/KeyboardContext.js.map +1 -1
- package/lib/commonjs/contexts/messageContext/MessageContext.js +14 -4
- package/lib/commonjs/contexts/messageContext/MessageContext.js.map +1 -1
- package/lib/commonjs/contexts/messageInputContext/MessageInputContext.js +14 -4
- package/lib/commonjs/contexts/messageInputContext/MessageInputContext.js.map +1 -1
- package/lib/commonjs/contexts/messageOverlayContext/MessageOverlayContext.js +14 -4
- package/lib/commonjs/contexts/messageOverlayContext/MessageOverlayContext.js.map +1 -1
- package/lib/commonjs/contexts/messageOverlayContext/hooks/useResettableState.test.js +4 -4
- package/lib/commonjs/contexts/messageOverlayContext/hooks/useResettableState.test.js.map +1 -1
- package/lib/commonjs/contexts/messagesContext/MessagesContext.js +14 -4
- package/lib/commonjs/contexts/messagesContext/MessagesContext.js.map +1 -1
- package/lib/commonjs/contexts/overlayContext/OverlayContext.js +13 -3
- package/lib/commonjs/contexts/overlayContext/OverlayContext.js.map +1 -1
- package/lib/commonjs/contexts/overlayContext/OverlayProvider.js +12 -12
- package/lib/commonjs/contexts/overlayContext/OverlayProvider.js.map +1 -1
- package/lib/commonjs/contexts/ownCapabilitiesContext/OwnCapabilitiesContext.js +13 -3
- package/lib/commonjs/contexts/ownCapabilitiesContext/OwnCapabilitiesContext.js.map +1 -1
- package/lib/commonjs/contexts/paginatedMessageListContext/PaginatedMessageListContext.js +14 -4
- package/lib/commonjs/contexts/paginatedMessageListContext/PaginatedMessageListContext.js.map +1 -1
- package/lib/commonjs/contexts/suggestionsContext/SuggestionsContext.js +14 -4
- package/lib/commonjs/contexts/suggestionsContext/SuggestionsContext.js.map +1 -1
- package/lib/commonjs/contexts/themeContext/ThemeContext.js +13 -7
- package/lib/commonjs/contexts/themeContext/ThemeContext.js.map +1 -1
- package/lib/commonjs/contexts/themeContext/utils/theme.js +9 -0
- package/lib/commonjs/contexts/themeContext/utils/theme.js.map +1 -1
- package/lib/commonjs/contexts/threadContext/ThreadContext.js +14 -4
- package/lib/commonjs/contexts/threadContext/ThreadContext.js.map +1 -1
- package/lib/commonjs/contexts/translationContext/TranslationContext.js +15 -6
- package/lib/commonjs/contexts/translationContext/TranslationContext.js.map +1 -1
- package/lib/commonjs/contexts/typingContext/TypingContext.js +14 -4
- package/lib/commonjs/contexts/typingContext/TypingContext.js.map +1 -1
- package/lib/commonjs/contexts/utils/defaultBaseContextValue.js +7 -0
- package/lib/commonjs/contexts/utils/defaultBaseContextValue.js.map +1 -0
- package/lib/commonjs/contexts/utils/isTestEnvironment.js +11 -0
- package/lib/commonjs/contexts/utils/isTestEnvironment.js.map +1 -0
- package/lib/commonjs/mock-builders/mock.js +30 -5
- package/lib/commonjs/mock-builders/mock.js.map +1 -1
- package/lib/commonjs/version.json +1 -1
- package/lib/module/components/Attachment/Card.js +61 -21
- package/lib/module/components/Attachment/Card.js.map +1 -1
- package/lib/module/components/AutoCompleteInput/AutoCompleteSuggestionList.js +1 -1
- package/lib/module/components/AutoCompleteInput/AutoCompleteSuggestionList.js.map +1 -1
- package/lib/module/components/MessageInput/SendMessageDisallowedIndicator.js +2 -2
- package/lib/module/components/MessageInput/SendMessageDisallowedIndicator.js.map +1 -1
- package/lib/module/components/Reply/Reply.js +12 -12
- package/lib/module/components/Reply/Reply.js.map +1 -1
- package/lib/module/contexts/activeChannelsRefContext/ActiveChannelsRefContext.js +2 -2
- package/lib/module/contexts/activeChannelsRefContext/ActiveChannelsRefContext.js.map +1 -1
- package/lib/module/contexts/attachmentPickerContext/AttachmentPickerContext.js +14 -4
- package/lib/module/contexts/attachmentPickerContext/AttachmentPickerContext.js.map +1 -1
- package/lib/module/contexts/channelContext/ChannelContext.js +14 -4
- package/lib/module/contexts/channelContext/ChannelContext.js.map +1 -1
- package/lib/module/contexts/channelsContext/ChannelsContext.js +14 -4
- package/lib/module/contexts/channelsContext/ChannelsContext.js.map +1 -1
- package/lib/module/contexts/channelsStateContext/ChannelsStateContext.js +15 -9
- package/lib/module/contexts/channelsStateContext/ChannelsStateContext.js.map +1 -1
- package/lib/module/contexts/chatContext/ChatContext.js +14 -4
- package/lib/module/contexts/chatContext/ChatContext.js.map +1 -1
- package/lib/module/contexts/imageGalleryContext/ImageGalleryContext.js +14 -4
- package/lib/module/contexts/imageGalleryContext/ImageGalleryContext.js.map +1 -1
- package/lib/module/contexts/keyboardContext/KeyboardContext.js +2 -2
- package/lib/module/contexts/keyboardContext/KeyboardContext.js.map +1 -1
- package/lib/module/contexts/messageContext/MessageContext.js +14 -4
- package/lib/module/contexts/messageContext/MessageContext.js.map +1 -1
- package/lib/module/contexts/messageInputContext/MessageInputContext.js +14 -4
- package/lib/module/contexts/messageInputContext/MessageInputContext.js.map +1 -1
- package/lib/module/contexts/messageOverlayContext/MessageOverlayContext.js +14 -4
- package/lib/module/contexts/messageOverlayContext/MessageOverlayContext.js.map +1 -1
- package/lib/module/contexts/messageOverlayContext/hooks/useResettableState.test.js +4 -4
- package/lib/module/contexts/messageOverlayContext/hooks/useResettableState.test.js.map +1 -1
- package/lib/module/contexts/messagesContext/MessagesContext.js +14 -4
- package/lib/module/contexts/messagesContext/MessagesContext.js.map +1 -1
- package/lib/module/contexts/overlayContext/OverlayContext.js +13 -3
- package/lib/module/contexts/overlayContext/OverlayContext.js.map +1 -1
- package/lib/module/contexts/overlayContext/OverlayProvider.js +12 -12
- package/lib/module/contexts/overlayContext/OverlayProvider.js.map +1 -1
- package/lib/module/contexts/ownCapabilitiesContext/OwnCapabilitiesContext.js +13 -3
- package/lib/module/contexts/ownCapabilitiesContext/OwnCapabilitiesContext.js.map +1 -1
- package/lib/module/contexts/paginatedMessageListContext/PaginatedMessageListContext.js +14 -4
- package/lib/module/contexts/paginatedMessageListContext/PaginatedMessageListContext.js.map +1 -1
- package/lib/module/contexts/suggestionsContext/SuggestionsContext.js +14 -4
- package/lib/module/contexts/suggestionsContext/SuggestionsContext.js.map +1 -1
- package/lib/module/contexts/themeContext/ThemeContext.js +13 -7
- package/lib/module/contexts/themeContext/ThemeContext.js.map +1 -1
- package/lib/module/contexts/themeContext/utils/theme.js +9 -0
- package/lib/module/contexts/themeContext/utils/theme.js.map +1 -1
- package/lib/module/contexts/threadContext/ThreadContext.js +14 -4
- package/lib/module/contexts/threadContext/ThreadContext.js.map +1 -1
- package/lib/module/contexts/translationContext/TranslationContext.js +15 -6
- package/lib/module/contexts/translationContext/TranslationContext.js.map +1 -1
- package/lib/module/contexts/typingContext/TypingContext.js +14 -4
- package/lib/module/contexts/typingContext/TypingContext.js.map +1 -1
- package/lib/module/contexts/utils/defaultBaseContextValue.js +7 -0
- package/lib/module/contexts/utils/defaultBaseContextValue.js.map +1 -0
- package/lib/module/contexts/utils/isTestEnvironment.js +11 -0
- package/lib/module/contexts/utils/isTestEnvironment.js.map +1 -0
- package/lib/module/mock-builders/mock.js +30 -5
- package/lib/module/mock-builders/mock.js.map +1 -1
- package/lib/module/version.json +1 -1
- package/lib/typescript/contexts/__tests__/index.test.d.ts +1 -0
- package/lib/typescript/contexts/keyboardContext/KeyboardContext.d.ts +6 -2
- package/lib/typescript/contexts/themeContext/ThemeContext.d.ts +5 -2
- package/lib/typescript/contexts/themeContext/utils/theme.d.ts +6 -0
- package/lib/typescript/contexts/utils/defaultBaseContextValue.d.ts +1 -0
- package/lib/typescript/contexts/utils/isTestEnvironment.d.ts +1 -0
- package/lib/typescript/mock-builders/mock.d.ts +2 -2
- package/package.json +1 -1
- package/src/components/Attachment/Card.tsx +29 -6
- package/src/components/Attachment/__tests__/Attachment.test.js +0 -14
- package/src/components/Attachment/__tests__/Giphy.test.js +9 -5
- package/src/components/AutoCompleteInput/AutoCompleteSuggestionList.tsx +1 -0
- package/src/components/ImageGallery/components/__tests__/ImageGalleryHeader.test.tsx +5 -3
- package/src/components/MessageInput/SendMessageDisallowedIndicator.tsx +1 -0
- package/src/components/MessageInput/__tests__/FileUploadPreview.test.js +1 -1
- package/src/components/Reply/Reply.tsx +6 -3
- package/src/contexts/__tests__/index.test.tsx +103 -0
- package/src/contexts/activeChannelsRefContext/ActiveChannelsRefContext.tsx +1 -0
- package/src/contexts/attachmentPickerContext/AttachmentPickerContext.tsx +18 -4
- package/src/contexts/channelContext/ChannelContext.tsx +18 -2
- package/src/contexts/channelsContext/ChannelsContext.tsx +18 -2
- package/src/contexts/channelsStateContext/ChannelsStateContext.tsx +19 -10
- package/src/contexts/chatContext/ChatContext.tsx +15 -2
- package/src/contexts/imageGalleryContext/ImageGalleryContext.tsx +18 -3
- package/src/contexts/keyboardContext/KeyboardContext.tsx +2 -1
- package/src/contexts/messageContext/MessageContext.tsx +19 -2
- package/src/contexts/messageInputContext/MessageInputContext.tsx +20 -2
- package/src/contexts/messageOverlayContext/MessageOverlayContext.tsx +19 -3
- package/src/contexts/messageOverlayContext/hooks/useResettableState.test.tsx +1 -0
- package/src/contexts/messagesContext/MessagesContext.tsx +19 -2
- package/src/contexts/overlayContext/OverlayContext.tsx +17 -2
- package/src/contexts/overlayContext/OverlayProvider.tsx +1 -0
- package/src/contexts/ownCapabilitiesContext/OwnCapabilitiesContext.tsx +18 -3
- package/src/contexts/paginatedMessageListContext/PaginatedMessageListContext.tsx +15 -3
- package/src/contexts/suggestionsContext/SuggestionsContext.tsx +19 -2
- package/src/contexts/suggestionsContext/__tests__/Suggestions.test.js +1 -0
- package/src/contexts/themeContext/ThemeContext.tsx +19 -5
- package/src/contexts/themeContext/utils/theme.ts +15 -0
- package/src/contexts/threadContext/ThreadContext.tsx +16 -2
- package/src/contexts/translationContext/TranslationContext.tsx +18 -4
- package/src/contexts/typingContext/TypingContext.tsx +17 -2
- package/src/contexts/utils/defaultBaseContextValue.ts +1 -0
- package/src/contexts/utils/isTestEnvironment.ts +1 -0
- package/src/mock-builders/mock.js +16 -3
- package/src/version.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["ChannelsContext.tsx"],"names":["ChannelsContext","React","createContext","ChannelsProvider","children","value","useChannelsContext","withChannelsContext","Component","WithChannelsContextComponent","props","channelsContext","displayName"],"mappings":";;;;;;;;;;;AAAA;;AAqBA;;;;;;;;;AA4LO,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 { FlatListProps } from 'react-native';\nimport type { FlatList } from 'react-native-gesture-handler';\n\nimport type { ChannelPreviewMutedStatusProps } from 'src/components/ChannelPreview/ChannelPreviewMutedStatus';\n\nimport type { Channel } from 'stream-chat';\n\nimport type { HeaderErrorProps } from '../../components/ChannelList/ChannelListHeaderErrorIndicator';\nimport type { QueryChannels } from '../../components/ChannelList/hooks/usePaginatedChannels';\nimport type { ChannelAvatarProps } from '../../components/ChannelPreview/ChannelAvatar';\nimport type { ChannelPreviewMessageProps } from '../../components/ChannelPreview/ChannelPreviewMessage';\nimport type { ChannelPreviewMessengerProps } from '../../components/ChannelPreview/ChannelPreviewMessenger';\nimport type { ChannelPreviewStatusProps } from '../../components/ChannelPreview/ChannelPreviewStatus';\nimport type { ChannelPreviewTitleProps } from '../../components/ChannelPreview/ChannelPreviewTitle';\nimport type { ChannelPreviewUnreadCountProps } from '../../components/ChannelPreview/ChannelPreviewUnreadCount';\nimport type { EmptyStateProps } from '../../components/Indicators/EmptyStateIndicator';\nimport type { LoadingErrorProps } from '../../components/Indicators/LoadingErrorIndicator';\nimport type { LoadingProps } from '../../components/Indicators/LoadingIndicator';\nimport type { DefaultStreamChatGenerics, UnknownType } from '../../types/types';\nimport { getDisplayName } from '../utils/getDisplayName';\n\nexport type ChannelsContextValue<\n StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,\n> = {\n /**\n * Besides the existing default behavior of the ChannelListMessenger component, you can attach\n * additional props to the underlying React Native FlatList.\n *\n * You can find list of all the available FlatList props here - https://facebook.github.io/react-native/docs/flatlist#props\n *\n * **EXAMPLE:**\n *\n * ```\n * <ChannelListMessenger\n * channels={channels}\n * additionalFlatListProps={{ bounces: true }}\n * />\n * ```\n *\n * **Note:** Don't use `additionalFlatListProps` to access the FlatList ref, use `setFlatListRef`\n */\n additionalFlatListProps: Partial<FlatListProps<Channel<StreamChatGenerics>>>;\n /**\n * Channels can be either an array of channels or a promise which resolves to an array of channels\n */\n channels: Channel<StreamChatGenerics>[];\n /**\n * Custom indicator to use when channel list is empty\n *\n * Default: [EmptyStateIndicator](https://getstream.github.io/stream-chat-react-native/v3/#emptystateindicator)\n * */\n EmptyStateIndicator: React.ComponentType<EmptyStateProps>;\n /**\n * Custom loading indicator to display at bottom of the list, while loading further pages\n *\n * Default: [ChannelListFooterLoadingIndicator](https://getstream.github.io/stream-chat-react-native/v3/#ChannelListFooterLoadingIndicator)\n */\n FooterLoadingIndicator: React.ComponentType;\n /**\n * Incremental number change to force update the FlatList\n */\n forceUpdate: number;\n /**\n * Whether or not the FlatList has another page to render\n */\n hasNextPage: boolean;\n /**\n * Custom indicator to display error at top of list, if loading/pagination error occurs\n *\n * Default: [ChannelListHeaderErrorIndicator](https://getstream.github.io/stream-chat-react-native/v3/#ChannelListHeaderErrorIndicator)\n */\n HeaderErrorIndicator: React.ComponentType<HeaderErrorProps>;\n /**\n * Custom indicator to display network-down error at top of list, if there is connectivity issue\n *\n * Default: [ChannelListHeaderNetworkDownIndicator](https://getstream.github.io/stream-chat-react-native/v3/#ChannelListHeaderNetworkDownIndicator)\n */\n HeaderNetworkDownIndicator: React.ComponentType;\n /**\n * Initial channels query loading state, triggers the LoadingIndicator\n */\n loadingChannels: boolean;\n /**\n * Custom indicator to use when there is error in fetching channels\n *\n * Default: [LoadingErrorIndicator](https://getstream.github.io/stream-chat-react-native/v3/#loadingerrorindicator)\n * */\n LoadingErrorIndicator: React.ComponentType<LoadingErrorProps>;\n /**\n * Custom loading indicator to use on Channel List\n *\n * */\n LoadingIndicator: React.ComponentType<Pick<LoadingProps, 'listType'>>;\n /**\n * Whether or not additional channels are being loaded, triggers the FooterLoadingIndicator\n */\n loadingNextPage: boolean;\n /**\n * The React Native FlatList threshold to fetch more data\n * @see See loadMoreThreshold [doc](https://facebook.github.io/react-native/docs/flatlist#onendreachedthreshold)\n * */\n loadMoreThreshold: number;\n /**\n * Loads the next page of `channels`, which is present as a required prop\n */\n loadNextPage: QueryChannels | undefined;\n /**\n * Max number to display within notification badge. Default: 255 and it cannot be higher than that for now due to backend limitations\n */\n maxUnreadCount: number;\n /**\n * Number of skeletons that should show when loading. Default: 6\n */\n numberOfSkeletons: number;\n /**\n * Custom UI component to display individual channel list items\n *\n * Default: [ChannelPreviewMessenger](https://getstream.github.io/stream-chat-react-native/v3/#channelpreviewmessenger)\n */\n Preview: React.ComponentType<ChannelPreviewMessengerProps<StreamChatGenerics>>;\n /**\n * Triggered when the channel list is refreshing, displays a loading spinner at the top of the list\n */\n refreshing: boolean;\n /**\n * Function to refresh the channel list that is similar to `reloadList`, but it doesn't wipe out existing channels\n * from UI before loading the new ones\n */\n refreshList: () => void | Promise<void>;\n /**\n * Removes all the existing channels from UI and loads fresh channels\n * */\n reloadList: () => Promise<void>;\n // /**\n // * Function to set the currently active channel, acts as a bridge between ChannelList and Channel components\n // *\n // * @param channel A channel object\n // */\n // setActiveChannel?: (channel: Channel<StreamChatGenerics>) => void;\n /**\n * Function to gain access to the inner FlatList ref\n *\n * **Example:**\n *\n * ```\n * <ChannelListMessenger\n * setFlatListRef={(ref) => {\n * // Use ref for your own good\n * }}\n * ```\n */\n setFlatListRef: (ref: FlatList<Channel<StreamChatGenerics>> | null) => void;\n /**\n * Custom UI component to display loading channel skeletons\n *\n * Default: [Skeleton](https://getstream.github.io/stream-chat-react-native/v3/#skeleton)\n */\n Skeleton: React.ComponentType;\n /**\n * Error in channels query, if any\n */\n error?: Error;\n ListHeaderComponent?: React.ComponentType;\n /**\n * Function to set the currently active channel, acts as a bridge between ChannelList and Channel components\n *\n * @param channel A channel object\n */\n onSelect?: (channel: Channel<StreamChatGenerics>) => void;\n /**\n * Custom UI component to render preview avatar.\n *\n * **Default** [ChannelAvatar](https://github.com/GetStream/stream-chat-react-native/blob/main/package/src/components/ChannelPreview/ChannelAvatar.tsx)\n */\n PreviewAvatar?: React.ComponentType<ChannelAvatarProps<StreamChatGenerics>>;\n /**\n * Custom UI component to render preview of latest message on channel.\n *\n * **Default** [ChannelPreviewMessage](https://github.com/GetStream/stream-chat-react-native/blob/main/package/src/components/ChannelPreview/ChannelPreviewMessage.tsx)\n */\n PreviewMessage?: React.ComponentType<ChannelPreviewMessageProps<StreamChatGenerics>>;\n /**\n * Custom UI component to render muted status.\n *\n * **Default** [ChannelMutedStatus](https://github.com/GetStream/stream-chat-react-native/blob/main/package/src/components/ChannelPreview/ChannelPreviewMutedStatus.tsx)\n */\n PreviewMutedStatus?: React.ComponentType<ChannelPreviewMutedStatusProps<StreamChatGenerics>>;\n /**\n * Custom UI component to render preview avatar.\n *\n * **Default** [ChannelPreviewStatus](https://github.com/GetStream/stream-chat-react-native/blob/main/package/src/components/ChannelPreview/ChannelPreviewStatus.tsx)\n */\n PreviewStatus?: React.ComponentType<ChannelPreviewStatusProps<StreamChatGenerics>>;\n /**\n * Custom UI component to render preview avatar.\n *\n * **Default** [ChannelPreviewTitle](https://github.com/GetStream/stream-chat-react-native/blob/main/package/src/components/ChannelPreview/ChannelPreviewTitle.tsx)\n */\n PreviewTitle?: React.ComponentType<ChannelPreviewTitleProps<StreamChatGenerics>>;\n /**\n * Custom UI component to render preview avatar.\n *\n * **Default** [ChannelPreviewUnreadCount](https://github.com/GetStream/stream-chat-react-native/blob/main/package/src/components/ChannelPreview/ChannelPreviewUnreadCount.tsx)\n */\n PreviewUnreadCount?: React.ComponentType<ChannelPreviewUnreadCountProps<StreamChatGenerics>>;\n};\n\nexport const ChannelsContext = React.createContext({} as ChannelsContextValue);\n\nexport const ChannelsProvider = <\n StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,\n>({\n children,\n value,\n}: PropsWithChildren<{\n value: ChannelsContextValue<StreamChatGenerics>;\n}>) => (\n <ChannelsContext.Provider value={value as unknown as ChannelsContextValue}>\n {children}\n </ChannelsContext.Provider>\n);\n\nexport const useChannelsContext = <\n StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,\n>() => useContext(ChannelsContext) as unknown as ChannelsContextValue<StreamChatGenerics>;\n\n/**\n * Typescript currently does not support partial inference so if ChatContext\n * typing is desired while using the HOC withChannelContext the Props for the\n * wrapped component must be provided as the first generic.\n */\nexport const withChannelsContext = <\n P extends UnknownType,\n StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,\n>(\n Component: React.ComponentType<P>,\n): React.FC<Omit<P, keyof ChannelsContextValue<StreamChatGenerics>>> => {\n const WithChannelsContextComponent = (\n props: Omit<P, keyof ChannelsContextValue<StreamChatGenerics>>,\n ) => {\n const channelsContext = useChannelsContext<StreamChatGenerics>();\n\n return <Component {...(props as P)} {...channelsContext} />;\n };\n WithChannelsContextComponent.displayName = `WithChannelsContext${getDisplayName(Component)}`;\n return WithChannelsContextComponent;\n};\n"]}
|
|
1
|
+
{"version":3,"sources":["ChannelsContext.tsx"],"names":["ChannelsContext","React","createContext","DEFAULT_BASE_CONTEXT_VALUE","ChannelsProvider","children","value","useChannelsContext","contextValue","Error","withChannelsContext","Component","WithChannelsContextComponent","props","channelsContext","displayName"],"mappings":";;;;;;;;;;;AAAA;;AAqBA;;AAEA;;AACA;;;;;;;;;AA4LO,IAAMA,eAAe,GAAGC,kBAAMC,aAAN,CAC7BC,mDAD6B,CAAxB;;;;AAIA,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,GAE3B;AACL,MAAMC,YAAY,GAAG,uBACnBR,eADmB,CAArB;;AAIA,MAAIQ,YAAY,KAAKL,mDAAjB,IAA+C,CAAC,2CAApD,EAAyE;AACvE,UAAM,IAAIM,KAAJ,yOAAN;AAGD;;AAED,SAAOD,YAAP;AACD,CAdM;;;;AAoBA,IAAME,mBAAmB,GAAG,SAAtBA,mBAAsB,CAIjCC,SAJiC,EAKqC;AACtE,MAAMC,4BAA4B,GAAG,SAA/BA,4BAA+B,CACnCC,KADmC,EAEhC;AACH,QAAMC,eAAe,GAAGP,kBAAkB,EAA1C;AAEA,WAAO,gCAAC,SAAD,gCAAgBM,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 { FlatListProps } from 'react-native';\nimport type { FlatList } from 'react-native-gesture-handler';\n\nimport type { ChannelPreviewMutedStatusProps } from 'src/components/ChannelPreview/ChannelPreviewMutedStatus';\n\nimport type { Channel } from 'stream-chat';\n\nimport type { HeaderErrorProps } from '../../components/ChannelList/ChannelListHeaderErrorIndicator';\nimport type { QueryChannels } from '../../components/ChannelList/hooks/usePaginatedChannels';\nimport type { ChannelAvatarProps } from '../../components/ChannelPreview/ChannelAvatar';\nimport type { ChannelPreviewMessageProps } from '../../components/ChannelPreview/ChannelPreviewMessage';\nimport type { ChannelPreviewMessengerProps } from '../../components/ChannelPreview/ChannelPreviewMessenger';\nimport type { ChannelPreviewStatusProps } from '../../components/ChannelPreview/ChannelPreviewStatus';\nimport type { ChannelPreviewTitleProps } from '../../components/ChannelPreview/ChannelPreviewTitle';\nimport type { ChannelPreviewUnreadCountProps } from '../../components/ChannelPreview/ChannelPreviewUnreadCount';\nimport type { EmptyStateProps } from '../../components/Indicators/EmptyStateIndicator';\nimport type { LoadingErrorProps } from '../../components/Indicators/LoadingErrorIndicator';\nimport type { LoadingProps } from '../../components/Indicators/LoadingIndicator';\nimport type { DefaultStreamChatGenerics, UnknownType } from '../../types/types';\nimport { DEFAULT_BASE_CONTEXT_VALUE } from '../utils/defaultBaseContextValue';\n\nimport { getDisplayName } from '../utils/getDisplayName';\nimport { isTestEnvironment } from '../utils/isTestEnvironment';\n\nexport type ChannelsContextValue<\n StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,\n> = {\n /**\n * Besides the existing default behavior of the ChannelListMessenger component, you can attach\n * additional props to the underlying React Native FlatList.\n *\n * You can find list of all the available FlatList props here - https://facebook.github.io/react-native/docs/flatlist#props\n *\n * **EXAMPLE:**\n *\n * ```\n * <ChannelListMessenger\n * channels={channels}\n * additionalFlatListProps={{ bounces: true }}\n * />\n * ```\n *\n * **Note:** Don't use `additionalFlatListProps` to access the FlatList ref, use `setFlatListRef`\n */\n additionalFlatListProps: Partial<FlatListProps<Channel<StreamChatGenerics>>>;\n /**\n * Channels can be either an array of channels or a promise which resolves to an array of channels\n */\n channels: Channel<StreamChatGenerics>[];\n /**\n * Custom indicator to use when channel list is empty\n *\n * Default: [EmptyStateIndicator](https://getstream.github.io/stream-chat-react-native/v3/#emptystateindicator)\n * */\n EmptyStateIndicator: React.ComponentType<EmptyStateProps>;\n /**\n * Custom loading indicator to display at bottom of the list, while loading further pages\n *\n * Default: [ChannelListFooterLoadingIndicator](https://getstream.github.io/stream-chat-react-native/v3/#ChannelListFooterLoadingIndicator)\n */\n FooterLoadingIndicator: React.ComponentType;\n /**\n * Incremental number change to force update the FlatList\n */\n forceUpdate: number;\n /**\n * Whether or not the FlatList has another page to render\n */\n hasNextPage: boolean;\n /**\n * Custom indicator to display error at top of list, if loading/pagination error occurs\n *\n * Default: [ChannelListHeaderErrorIndicator](https://getstream.github.io/stream-chat-react-native/v3/#ChannelListHeaderErrorIndicator)\n */\n HeaderErrorIndicator: React.ComponentType<HeaderErrorProps>;\n /**\n * Custom indicator to display network-down error at top of list, if there is connectivity issue\n *\n * Default: [ChannelListHeaderNetworkDownIndicator](https://getstream.github.io/stream-chat-react-native/v3/#ChannelListHeaderNetworkDownIndicator)\n */\n HeaderNetworkDownIndicator: React.ComponentType;\n /**\n * Initial channels query loading state, triggers the LoadingIndicator\n */\n loadingChannels: boolean;\n /**\n * Custom indicator to use when there is error in fetching channels\n *\n * Default: [LoadingErrorIndicator](https://getstream.github.io/stream-chat-react-native/v3/#loadingerrorindicator)\n * */\n LoadingErrorIndicator: React.ComponentType<LoadingErrorProps>;\n /**\n * Custom loading indicator to use on Channel List\n *\n * */\n LoadingIndicator: React.ComponentType<Pick<LoadingProps, 'listType'>>;\n /**\n * Whether or not additional channels are being loaded, triggers the FooterLoadingIndicator\n */\n loadingNextPage: boolean;\n /**\n * The React Native FlatList threshold to fetch more data\n * @see See loadMoreThreshold [doc](https://facebook.github.io/react-native/docs/flatlist#onendreachedthreshold)\n * */\n loadMoreThreshold: number;\n /**\n * Loads the next page of `channels`, which is present as a required prop\n */\n loadNextPage: QueryChannels | undefined;\n /**\n * Max number to display within notification badge. Default: 255 and it cannot be higher than that for now due to backend limitations\n */\n maxUnreadCount: number;\n /**\n * Number of skeletons that should show when loading. Default: 6\n */\n numberOfSkeletons: number;\n /**\n * Custom UI component to display individual channel list items\n *\n * Default: [ChannelPreviewMessenger](https://getstream.github.io/stream-chat-react-native/v3/#channelpreviewmessenger)\n */\n Preview: React.ComponentType<ChannelPreviewMessengerProps<StreamChatGenerics>>;\n /**\n * Triggered when the channel list is refreshing, displays a loading spinner at the top of the list\n */\n refreshing: boolean;\n /**\n * Function to refresh the channel list that is similar to `reloadList`, but it doesn't wipe out existing channels\n * from UI before loading the new ones\n */\n refreshList: () => void | Promise<void>;\n /**\n * Removes all the existing channels from UI and loads fresh channels\n * */\n reloadList: () => Promise<void>;\n // /**\n // * Function to set the currently active channel, acts as a bridge between ChannelList and Channel components\n // *\n // * @param channel A channel object\n // */\n // setActiveChannel?: (channel: Channel<StreamChatGenerics>) => void;\n /**\n * Function to gain access to the inner FlatList ref\n *\n * **Example:**\n *\n * ```\n * <ChannelListMessenger\n * setFlatListRef={(ref) => {\n * // Use ref for your own good\n * }}\n * ```\n */\n setFlatListRef: (ref: FlatList<Channel<StreamChatGenerics>> | null) => void;\n /**\n * Custom UI component to display loading channel skeletons\n *\n * Default: [Skeleton](https://getstream.github.io/stream-chat-react-native/v3/#skeleton)\n */\n Skeleton: React.ComponentType;\n /**\n * Error in channels query, if any\n */\n error?: Error;\n ListHeaderComponent?: React.ComponentType;\n /**\n * Function to set the currently active channel, acts as a bridge between ChannelList and Channel components\n *\n * @param channel A channel object\n */\n onSelect?: (channel: Channel<StreamChatGenerics>) => void;\n /**\n * Custom UI component to render preview avatar.\n *\n * **Default** [ChannelAvatar](https://github.com/GetStream/stream-chat-react-native/blob/main/package/src/components/ChannelPreview/ChannelAvatar.tsx)\n */\n PreviewAvatar?: React.ComponentType<ChannelAvatarProps<StreamChatGenerics>>;\n /**\n * Custom UI component to render preview of latest message on channel.\n *\n * **Default** [ChannelPreviewMessage](https://github.com/GetStream/stream-chat-react-native/blob/main/package/src/components/ChannelPreview/ChannelPreviewMessage.tsx)\n */\n PreviewMessage?: React.ComponentType<ChannelPreviewMessageProps<StreamChatGenerics>>;\n /**\n * Custom UI component to render muted status.\n *\n * **Default** [ChannelMutedStatus](https://github.com/GetStream/stream-chat-react-native/blob/main/package/src/components/ChannelPreview/ChannelPreviewMutedStatus.tsx)\n */\n PreviewMutedStatus?: React.ComponentType<ChannelPreviewMutedStatusProps<StreamChatGenerics>>;\n /**\n * Custom UI component to render preview avatar.\n *\n * **Default** [ChannelPreviewStatus](https://github.com/GetStream/stream-chat-react-native/blob/main/package/src/components/ChannelPreview/ChannelPreviewStatus.tsx)\n */\n PreviewStatus?: React.ComponentType<ChannelPreviewStatusProps<StreamChatGenerics>>;\n /**\n * Custom UI component to render preview avatar.\n *\n * **Default** [ChannelPreviewTitle](https://github.com/GetStream/stream-chat-react-native/blob/main/package/src/components/ChannelPreview/ChannelPreviewTitle.tsx)\n */\n PreviewTitle?: React.ComponentType<ChannelPreviewTitleProps<StreamChatGenerics>>;\n /**\n * Custom UI component to render preview avatar.\n *\n * **Default** [ChannelPreviewUnreadCount](https://github.com/GetStream/stream-chat-react-native/blob/main/package/src/components/ChannelPreview/ChannelPreviewUnreadCount.tsx)\n */\n PreviewUnreadCount?: React.ComponentType<ChannelPreviewUnreadCountProps<StreamChatGenerics>>;\n};\n\nexport const ChannelsContext = React.createContext(\n DEFAULT_BASE_CONTEXT_VALUE as ChannelsContextValue,\n);\n\nexport const ChannelsProvider = <\n StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,\n>({\n children,\n value,\n}: PropsWithChildren<{\n value: ChannelsContextValue<StreamChatGenerics>;\n}>) => (\n <ChannelsContext.Provider value={value as unknown as ChannelsContextValue}>\n {children}\n </ChannelsContext.Provider>\n);\n\nexport const useChannelsContext = <\n StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,\n>() => {\n const contextValue = useContext(\n ChannelsContext,\n ) as unknown as ChannelsContextValue<StreamChatGenerics>;\n\n if (contextValue === DEFAULT_BASE_CONTEXT_VALUE && !isTestEnvironment()) {\n throw new Error(\n `The useChannelsContext hook was called outside of the ChannelsContext provider. Make sure you have configured ChannelList component correctly - https://getstream.io/chat/docs/sdk/reactnative/basics/hello_stream_chat/#channel-list`,\n );\n }\n\n return contextValue;\n};\n/**\n * Typescript currently does not support partial inference so if ChatContext\n * typing is desired while using the HOC withChannelContext the Props for the\n * wrapped component must be provided as the first generic.\n */\nexport const withChannelsContext = <\n P extends UnknownType,\n StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,\n>(\n Component: React.ComponentType<P>,\n): React.FC<Omit<P, keyof ChannelsContextValue<StreamChatGenerics>>> => {\n const WithChannelsContextComponent = (\n props: Omit<P, keyof ChannelsContextValue<StreamChatGenerics>>,\n ) => {\n const channelsContext = useChannelsContext<StreamChatGenerics>();\n\n return <Component {...(props as P)} {...channelsContext} />;\n };\n WithChannelsContextComponent.displayName = `WithChannelsContext${getDisplayName(Component)}`;\n return WithChannelsContextComponent;\n};\n"]}
|
|
@@ -17,8 +17,12 @@ var _react = _interopRequireWildcard(require("react"));
|
|
|
17
17
|
|
|
18
18
|
var _ActiveChannelsRefContext = require("../activeChannelsRefContext/ActiveChannelsRefContext");
|
|
19
19
|
|
|
20
|
+
var _defaultBaseContextValue = require("../utils/defaultBaseContextValue");
|
|
21
|
+
|
|
20
22
|
var _getDisplayName = require("../utils/getDisplayName");
|
|
21
23
|
|
|
24
|
+
var _isTestEnvironment = require("../utils/isTestEnvironment");
|
|
25
|
+
|
|
22
26
|
var _this = this,
|
|
23
27
|
_jsxFileName = "/home/runner/work/stream-chat-react-native/stream-chat-react-native/package/src/contexts/channelsStateContext/ChannelsStateContext.tsx";
|
|
24
28
|
|
|
@@ -63,11 +67,7 @@ function reducer(state, action) {
|
|
|
63
67
|
}
|
|
64
68
|
}
|
|
65
69
|
|
|
66
|
-
var ChannelsStateContext = _react["default"].createContext(
|
|
67
|
-
removeChannelState: function removeChannelState() {},
|
|
68
|
-
setState: function setState() {},
|
|
69
|
-
state: {}
|
|
70
|
-
});
|
|
70
|
+
var ChannelsStateContext = _react["default"].createContext(_defaultBaseContextValue.DEFAULT_BASE_CONTEXT_VALUE);
|
|
71
71
|
|
|
72
72
|
var ChannelsStateProvider = function ChannelsStateProvider(_ref) {
|
|
73
73
|
var children = _ref.children;
|
|
@@ -112,7 +112,7 @@ var ChannelsStateProvider = function ChannelsStateProvider(_ref) {
|
|
|
112
112
|
__self: _this,
|
|
113
113
|
__source: {
|
|
114
114
|
fileName: _jsxFileName,
|
|
115
|
-
lineNumber:
|
|
115
|
+
lineNumber: 179,
|
|
116
116
|
columnNumber: 5
|
|
117
117
|
}
|
|
118
118
|
}, _react["default"].createElement(_ActiveChannelsRefContext.ActiveChannelsProvider, {
|
|
@@ -120,7 +120,7 @@ var ChannelsStateProvider = function ChannelsStateProvider(_ref) {
|
|
|
120
120
|
__self: _this,
|
|
121
121
|
__source: {
|
|
122
122
|
fileName: _jsxFileName,
|
|
123
|
-
lineNumber:
|
|
123
|
+
lineNumber: 180,
|
|
124
124
|
columnNumber: 7
|
|
125
125
|
}
|
|
126
126
|
}, children));
|
|
@@ -129,7 +129,13 @@ var ChannelsStateProvider = function ChannelsStateProvider(_ref) {
|
|
|
129
129
|
exports.ChannelsStateProvider = ChannelsStateProvider;
|
|
130
130
|
|
|
131
131
|
var useChannelsStateContext = function useChannelsStateContext() {
|
|
132
|
-
|
|
132
|
+
var contextValue = (0, _react.useContext)(ChannelsStateContext);
|
|
133
|
+
|
|
134
|
+
if (contextValue === _defaultBaseContextValue.DEFAULT_BASE_CONTEXT_VALUE && !(0, _isTestEnvironment.isTestEnvironment)()) {
|
|
135
|
+
throw new Error("The useChannelStateContext hook was called outside the ChannelStateContext Provider. Make sure you have configured OverlayProvider component correctly - https://getstream.io/chat/docs/sdk/reactnative/basics/hello_stream_chat/#overlay-provider");
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
return contextValue;
|
|
133
139
|
};
|
|
134
140
|
|
|
135
141
|
exports.useChannelsStateContext = useChannelsStateContext;
|
|
@@ -141,7 +147,7 @@ var withChannelsStateContext = function withChannelsStateContext(Component) {
|
|
|
141
147
|
__self: _this,
|
|
142
148
|
__source: {
|
|
143
149
|
fileName: _jsxFileName,
|
|
144
|
-
lineNumber:
|
|
150
|
+
lineNumber: 212,
|
|
145
151
|
columnNumber: 12
|
|
146
152
|
}
|
|
147
153
|
}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["ChannelsStateContext.tsx"],"names":["reducer","state","action","type","payload","cid","key","value","currentCount","subscriberCount","stateShallowCopy","Error","ChannelsStateContext","React","createContext","removeChannelState","setState","ChannelsStateProvider","children","dispatch","increaseSubscriberCount","decreaseSubscriberCount","activeChannelsRef","Object","keys","current","useChannelsStateContext","withChannelsStateContext","Component","WithChannelsStateContextComponent","props","channelsStateContext","displayName"],"mappings":"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","sourcesContent":["import React, {\n ReactNode,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useReducer,\n useRef,\n} from 'react';\n\nimport type { DefaultStreamChatGenerics, UnknownType } from '../../types/types';\nimport { ActiveChannelsProvider } from '../activeChannelsRefContext/ActiveChannelsRefContext';\n\nimport type { ChannelContextValue } from '../channelContext/ChannelContext';\nimport type { PaginatedMessageListContextValue } from '../paginatedMessageListContext/PaginatedMessageListContext';\nimport type { ThreadContextValue } from '../threadContext/ThreadContext';\nimport type { TypingContextValue } from '../typingContext/TypingContext';\nimport { getDisplayName } from '../utils/getDisplayName';\n\nexport type ChannelState<\n StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,\n> = {\n members: ChannelContextValue<StreamChatGenerics>['members'];\n messages: PaginatedMessageListContextValue<StreamChatGenerics>['messages'];\n read: ChannelContextValue<StreamChatGenerics>['read'];\n subscriberCount: number;\n threadMessages: ThreadContextValue<StreamChatGenerics>['threadMessages'];\n typing: TypingContextValue<StreamChatGenerics>['typing'];\n watcherCount: ChannelContextValue<StreamChatGenerics>['watcherCount'];\n watchers: ChannelContextValue<StreamChatGenerics>['watchers'];\n};\n\ntype ChannelsState<\n StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,\n> = {\n [cid: string]: ChannelState<StreamChatGenerics>;\n};\n\nexport type Keys = keyof ChannelState;\n\nexport type Payload<\n Key extends Keys = Keys,\n StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,\n> = {\n cid: string;\n key: Key;\n value: ChannelState<StreamChatGenerics>[Key];\n};\n\ntype SetStateAction<\n StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,\n> = {\n payload: Payload<Keys, StreamChatGenerics>;\n type: 'SET_STATE';\n};\n\ntype IncreaseSubscriberCountAction = {\n payload: { cid: string };\n type: 'INCREASE_SUBSCRIBER_COUNT';\n};\ntype DecreaseSubscriberCountAction = {\n payload: { cid: string };\n type: 'DECREASE_SUBSCRIBER_COUNT';\n};\n\ntype Action<StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics> =\n | SetStateAction<StreamChatGenerics>\n | IncreaseSubscriberCountAction\n | DecreaseSubscriberCountAction;\n\nexport type ChannelsStateContextValue<\n StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,\n> = {\n decreaseSubscriberCount: (value: { cid: string }) => void;\n increaseSubscriberCount: (value: { cid: string }) => void;\n setState: (value: Payload<Keys, StreamChatGenerics>) => void;\n state: ChannelsState<StreamChatGenerics>;\n};\n\ntype Reducer<StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics> = (\n state: ChannelsState<StreamChatGenerics>,\n action: Action<StreamChatGenerics>,\n) => ChannelsState<StreamChatGenerics>;\n\nfunction reducer(state: ChannelsState, action: Action) {\n switch (action.type) {\n case 'SET_STATE':\n return {\n ...state,\n [action.payload.cid]: {\n ...(state[action.payload.cid] || {}),\n [action.payload.key]: action.payload.value,\n },\n };\n\n case 'INCREASE_SUBSCRIBER_COUNT': {\n const currentCount = state[action.payload.cid]?.subscriberCount ?? 0;\n return {\n ...state,\n [action.payload.cid]: {\n ...(state[action.payload.cid] || {}),\n subscriberCount: currentCount + 1,\n },\n };\n }\n\n case 'DECREASE_SUBSCRIBER_COUNT': {\n const currentCount = state[action.payload.cid]?.subscriberCount ?? 0;\n\n // If there last subscribed Channel component unsubscribes, we clear the channel state.\n if (currentCount <= 1) {\n const stateShallowCopy = {\n ...state,\n };\n\n delete stateShallowCopy[action.payload.cid];\n\n return stateShallowCopy;\n }\n\n return {\n ...state,\n [action.payload.cid]: {\n ...(state[action.payload.cid] || {}),\n subscriberCount: currentCount - 1,\n },\n };\n }\n default:\n throw new Error();\n }\n}\n\nconst ChannelsStateContext = React.createContext({\n removeChannelState: () => {\n // do nothing.\n },\n setState: () => {\n // do nothing.\n },\n state: {},\n} as unknown as ChannelsStateContextValue);\n\nexport const ChannelsStateProvider = <\n StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,\n>({\n children,\n}: {\n children: ReactNode;\n}) => {\n const [state, dispatch] = useReducer(reducer as unknown as Reducer<StreamChatGenerics>, {});\n\n const setState = useCallback((payload: Payload<Keys, StreamChatGenerics>) => {\n dispatch({ payload, type: 'SET_STATE' });\n }, []);\n\n const increaseSubscriberCount = useCallback((payload: { cid: string }) => {\n dispatch({ payload, type: 'INCREASE_SUBSCRIBER_COUNT' });\n }, []);\n\n const decreaseSubscriberCount = useCallback((payload: { cid: string }) => {\n dispatch({ payload, type: 'DECREASE_SUBSCRIBER_COUNT' });\n }, []);\n\n const value = useMemo(\n () => ({\n decreaseSubscriberCount,\n increaseSubscriberCount,\n setState,\n state,\n }),\n [state],\n );\n\n const activeChannelsRef = useRef(Object.keys(state));\n\n useEffect(() => {\n activeChannelsRef.current = Object.keys(state);\n }, [state]);\n\n return (\n <ChannelsStateContext.Provider value={value as unknown as ChannelsStateContextValue}>\n <ActiveChannelsProvider value={activeChannelsRef}>{children}</ActiveChannelsProvider>\n </ChannelsStateContext.Provider>\n );\n};\n\nexport const useChannelsStateContext = <\n StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,\n>() => useContext(ChannelsStateContext) as unknown as ChannelsStateContextValue<StreamChatGenerics>;\n\nexport const withChannelsStateContext = <\n P extends UnknownType,\n StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,\n>(\n Component: React.ComponentType<P>,\n): React.FC<Omit<P, keyof ChannelsStateContextValue<StreamChatGenerics>>> => {\n const WithChannelsStateContextComponent = (\n props: Omit<P, keyof ChannelsStateContextValue<StreamChatGenerics>>,\n ) => {\n const channelsStateContext = useChannelsStateContext<StreamChatGenerics>();\n\n return <Component {...(props as P)} {...channelsStateContext} />;\n };\n WithChannelsStateContextComponent.displayName = `WithChannelsStateContext${getDisplayName(\n Component,\n )}`;\n return WithChannelsStateContextComponent;\n};\n"]}
|
|
1
|
+
{"version":3,"sources":["ChannelsStateContext.tsx"],"names":["reducer","state","action","type","payload","cid","key","value","currentCount","subscriberCount","stateShallowCopy","Error","ChannelsStateContext","React","createContext","DEFAULT_BASE_CONTEXT_VALUE","ChannelsStateProvider","children","dispatch","setState","increaseSubscriberCount","decreaseSubscriberCount","activeChannelsRef","Object","keys","current","useChannelsStateContext","contextValue","withChannelsStateContext","Component","WithChannelsStateContextComponent","props","channelsStateContext","displayName"],"mappings":"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","sourcesContent":["import React, {\n ReactNode,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useReducer,\n useRef,\n} from 'react';\n\nimport type { DefaultStreamChatGenerics, UnknownType } from '../../types/types';\nimport { ActiveChannelsProvider } from '../activeChannelsRefContext/ActiveChannelsRefContext';\n\nimport type { ChannelContextValue } from '../channelContext/ChannelContext';\nimport type { PaginatedMessageListContextValue } from '../paginatedMessageListContext/PaginatedMessageListContext';\nimport type { ThreadContextValue } from '../threadContext/ThreadContext';\nimport type { TypingContextValue } from '../typingContext/TypingContext';\nimport { DEFAULT_BASE_CONTEXT_VALUE } from '../utils/defaultBaseContextValue';\n\nimport { getDisplayName } from '../utils/getDisplayName';\nimport { isTestEnvironment } from '../utils/isTestEnvironment';\n\nexport type ChannelState<\n StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,\n> = {\n members: ChannelContextValue<StreamChatGenerics>['members'];\n messages: PaginatedMessageListContextValue<StreamChatGenerics>['messages'];\n read: ChannelContextValue<StreamChatGenerics>['read'];\n subscriberCount: number;\n threadMessages: ThreadContextValue<StreamChatGenerics>['threadMessages'];\n typing: TypingContextValue<StreamChatGenerics>['typing'];\n watcherCount: ChannelContextValue<StreamChatGenerics>['watcherCount'];\n watchers: ChannelContextValue<StreamChatGenerics>['watchers'];\n};\n\ntype ChannelsState<\n StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,\n> = {\n [cid: string]: ChannelState<StreamChatGenerics>;\n};\n\nexport type Keys = keyof ChannelState;\n\nexport type Payload<\n Key extends Keys = Keys,\n StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,\n> = {\n cid: string;\n key: Key;\n value: ChannelState<StreamChatGenerics>[Key];\n};\n\ntype SetStateAction<\n StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,\n> = {\n payload: Payload<Keys, StreamChatGenerics>;\n type: 'SET_STATE';\n};\n\ntype IncreaseSubscriberCountAction = {\n payload: { cid: string };\n type: 'INCREASE_SUBSCRIBER_COUNT';\n};\ntype DecreaseSubscriberCountAction = {\n payload: { cid: string };\n type: 'DECREASE_SUBSCRIBER_COUNT';\n};\n\ntype Action<StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics> =\n | SetStateAction<StreamChatGenerics>\n | IncreaseSubscriberCountAction\n | DecreaseSubscriberCountAction;\n\nexport type ChannelsStateContextValue<\n StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,\n> = {\n decreaseSubscriberCount: (value: { cid: string }) => void;\n increaseSubscriberCount: (value: { cid: string }) => void;\n setState: (value: Payload<Keys, StreamChatGenerics>) => void;\n state: ChannelsState<StreamChatGenerics>;\n};\n\ntype Reducer<StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics> = (\n state: ChannelsState<StreamChatGenerics>,\n action: Action<StreamChatGenerics>,\n) => ChannelsState<StreamChatGenerics>;\n\nfunction reducer(state: ChannelsState, action: Action) {\n switch (action.type) {\n case 'SET_STATE':\n return {\n ...state,\n [action.payload.cid]: {\n ...(state[action.payload.cid] || {}),\n [action.payload.key]: action.payload.value,\n },\n };\n\n case 'INCREASE_SUBSCRIBER_COUNT': {\n const currentCount = state[action.payload.cid]?.subscriberCount ?? 0;\n return {\n ...state,\n [action.payload.cid]: {\n ...(state[action.payload.cid] || {}),\n subscriberCount: currentCount + 1,\n },\n };\n }\n\n case 'DECREASE_SUBSCRIBER_COUNT': {\n const currentCount = state[action.payload.cid]?.subscriberCount ?? 0;\n\n // If there last subscribed Channel component unsubscribes, we clear the channel state.\n if (currentCount <= 1) {\n const stateShallowCopy = {\n ...state,\n };\n\n delete stateShallowCopy[action.payload.cid];\n\n return stateShallowCopy;\n }\n\n return {\n ...state,\n [action.payload.cid]: {\n ...(state[action.payload.cid] || {}),\n subscriberCount: currentCount - 1,\n },\n };\n }\n default:\n throw new Error();\n }\n}\n\nconst ChannelsStateContext = React.createContext(\n DEFAULT_BASE_CONTEXT_VALUE as ChannelsStateContextValue,\n);\n\nexport const ChannelsStateProvider = <\n StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,\n>({\n children,\n}: {\n children: ReactNode;\n}) => {\n const [state, dispatch] = useReducer(reducer as unknown as Reducer<StreamChatGenerics>, {});\n\n const setState = useCallback((payload: Payload<Keys, StreamChatGenerics>) => {\n dispatch({ payload, type: 'SET_STATE' });\n }, []);\n\n const increaseSubscriberCount = useCallback((payload: { cid: string }) => {\n dispatch({ payload, type: 'INCREASE_SUBSCRIBER_COUNT' });\n }, []);\n\n const decreaseSubscriberCount = useCallback((payload: { cid: string }) => {\n dispatch({ payload, type: 'DECREASE_SUBSCRIBER_COUNT' });\n }, []);\n\n const value = useMemo(\n () => ({\n decreaseSubscriberCount,\n increaseSubscriberCount,\n setState,\n state,\n }),\n [state],\n );\n\n const activeChannelsRef = useRef(Object.keys(state));\n\n useEffect(() => {\n activeChannelsRef.current = Object.keys(state);\n }, [state]);\n\n return (\n <ChannelsStateContext.Provider value={value as unknown as ChannelsStateContextValue}>\n <ActiveChannelsProvider value={activeChannelsRef}>{children}</ActiveChannelsProvider>\n </ChannelsStateContext.Provider>\n );\n};\n\nexport const useChannelsStateContext = <\n StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,\n>() => {\n const contextValue = useContext(\n ChannelsStateContext,\n ) as unknown as ChannelsStateContextValue<StreamChatGenerics>;\n\n if (contextValue === DEFAULT_BASE_CONTEXT_VALUE && !isTestEnvironment()) {\n throw new Error(\n `The useChannelStateContext hook was called outside the ChannelStateContext Provider. Make sure you have configured OverlayProvider component correctly - https://getstream.io/chat/docs/sdk/reactnative/basics/hello_stream_chat/#overlay-provider`,\n );\n }\n\n return contextValue;\n};\n\nexport const withChannelsStateContext = <\n P extends UnknownType,\n StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,\n>(\n Component: React.ComponentType<P>,\n): React.FC<Omit<P, keyof ChannelsStateContextValue<StreamChatGenerics>>> => {\n const WithChannelsStateContextComponent = (\n props: Omit<P, keyof ChannelsStateContextValue<StreamChatGenerics>>,\n ) => {\n const channelsStateContext = useChannelsStateContext<StreamChatGenerics>();\n\n return <Component {...(props as P)} {...channelsStateContext} />;\n };\n WithChannelsStateContextComponent.displayName = `WithChannelsStateContext${getDisplayName(\n Component,\n )}`;\n return WithChannelsStateContextComponent;\n};\n"]}
|
|
@@ -11,8 +11,12 @@ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")
|
|
|
11
11
|
|
|
12
12
|
var _react = _interopRequireWildcard(require("react"));
|
|
13
13
|
|
|
14
|
+
var _defaultBaseContextValue = require("../utils/defaultBaseContextValue");
|
|
15
|
+
|
|
14
16
|
var _getDisplayName = require("../utils/getDisplayName");
|
|
15
17
|
|
|
18
|
+
var _isTestEnvironment = require("../utils/isTestEnvironment");
|
|
19
|
+
|
|
16
20
|
var _this = this,
|
|
17
21
|
_jsxFileName = "/home/runner/work/stream-chat-react-native/stream-chat-react-native/package/src/contexts/chatContext/ChatContext.tsx";
|
|
18
22
|
|
|
@@ -20,7 +24,7 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
|
|
|
20
24
|
|
|
21
25
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
22
26
|
|
|
23
|
-
var ChatContext = _react["default"].createContext(
|
|
27
|
+
var ChatContext = _react["default"].createContext(_defaultBaseContextValue.DEFAULT_BASE_CONTEXT_VALUE);
|
|
24
28
|
|
|
25
29
|
exports.ChatContext = ChatContext;
|
|
26
30
|
|
|
@@ -32,7 +36,7 @@ var ChatProvider = function ChatProvider(_ref) {
|
|
|
32
36
|
__self: _this,
|
|
33
37
|
__source: {
|
|
34
38
|
fileName: _jsxFileName,
|
|
35
|
-
lineNumber:
|
|
39
|
+
lineNumber: 74,
|
|
36
40
|
columnNumber: 3
|
|
37
41
|
}
|
|
38
42
|
}, children);
|
|
@@ -41,7 +45,13 @@ var ChatProvider = function ChatProvider(_ref) {
|
|
|
41
45
|
exports.ChatProvider = ChatProvider;
|
|
42
46
|
|
|
43
47
|
var useChatContext = function useChatContext() {
|
|
44
|
-
|
|
48
|
+
var contextValue = (0, _react.useContext)(ChatContext);
|
|
49
|
+
|
|
50
|
+
if (contextValue === _defaultBaseContextValue.DEFAULT_BASE_CONTEXT_VALUE && !(0, _isTestEnvironment.isTestEnvironment)()) {
|
|
51
|
+
throw new Error("The useChatContext hook was called outside the ChatContext Provider. Make sure you have configured Chat component correctly - https://getstream.io/chat/docs/sdk/reactnative/basics/hello_stream_chat/#chat");
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return contextValue;
|
|
45
55
|
};
|
|
46
56
|
|
|
47
57
|
exports.useChatContext = useChatContext;
|
|
@@ -53,7 +63,7 @@ var withChatContext = function withChatContext(Component) {
|
|
|
53
63
|
__self: _this,
|
|
54
64
|
__source: {
|
|
55
65
|
fileName: _jsxFileName,
|
|
56
|
-
lineNumber:
|
|
66
|
+
lineNumber: 107,
|
|
57
67
|
columnNumber: 12
|
|
58
68
|
}
|
|
59
69
|
}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["ChatContext.tsx"],"names":["ChatContext","React","createContext","ChatProvider","children","value","useChatContext","withChatContext","Component","WithChatContextComponent","props","chatContext","displayName"],"mappings":";;;;;;;;;;;AAAA;;AAKA;;;;;;;;;AAuDO,IAAMA,WAAW,GAAGC,kBAAMC,aAAN,
|
|
1
|
+
{"version":3,"sources":["ChatContext.tsx"],"names":["ChatContext","React","createContext","DEFAULT_BASE_CONTEXT_VALUE","ChatProvider","children","value","useChatContext","contextValue","Error","withChatContext","Component","WithChatContextComponent","props","chatContext","displayName"],"mappings":";;;;;;;;;;;AAAA;;AAKA;;AAEA;;AACA;;;;;;;;;AAuDO,IAAMA,WAAW,GAAGC,kBAAMC,aAAN,CAAoBC,mDAApB,CAApB;;;;AAEA,IAAMC,YAAY,GAAG,SAAfA,YAAe;AAAA,MAG1BC,QAH0B,QAG1BA,QAH0B;AAAA,MAI1BC,KAJ0B,QAI1BA,KAJ0B;AAAA,SAQ1B,gCAAC,WAAD,CAAa,QAAb;AAAsB,IAAA,KAAK,EAAEA,KAA7B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,KACGD,QADH,CAR0B;AAAA,CAArB;;;;AAaA,IAAME,cAAc,GAAG,SAAjBA,cAAiB,GAEvB;AACL,MAAMC,YAAY,GAAG,uBAAWR,WAAX,CAArB;;AAEA,MAAIQ,YAAY,KAAKL,mDAAjB,IAA+C,CAAC,2CAApD,EAAyE;AACvE,UAAM,IAAIM,KAAJ,+MAAN;AAGD;;AAED,SAAOD,YAAP;AACD,CAZM;;;;AAmBA,IAAME,eAAe,GAAG,SAAlBA,eAAkB,CAI7BC,SAJ6B,EAKqC;AAClE,MAAMC,wBAAwB,GAAG,SAA3BA,wBAA2B,CAACC,KAAD,EAAgE;AAC/F,QAAMC,WAAW,GAAGP,cAAc,EAAlC;AAEA,WAAO,gCAAC,SAAD,gCAAgBM,KAAhB,EAAiCC,WAAjC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,OAAP;AACD,GAJD;;AAKAF,EAAAA,wBAAwB,CAACG,WAAzB,uBAAyD,oCAAeJ,SAAf,CAAzD;AACA,SAAOC,wBAAP;AACD,CAbM","sourcesContent":["import React, { PropsWithChildren, useContext } from 'react';\n\nimport type { AppSettingsAPIResponse, Channel, Mute, StreamChat } from 'stream-chat';\n\nimport type { DefaultStreamChatGenerics, UnknownType } from '../../types/types';\nimport { DEFAULT_BASE_CONTEXT_VALUE } from '../utils/defaultBaseContextValue';\n\nimport { getDisplayName } from '../utils/getDisplayName';\nimport { isTestEnvironment } from '../utils/isTestEnvironment';\n\nexport type ChatContextValue<\n StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,\n> = {\n /**\n * Object of application settings returned from Stream.\n * */\n appSettings: AppSettingsAPIResponse<StreamChatGenerics> | null;\n /**\n * The StreamChat client object\n *\n * ```\n * import { StreamChat } from 'stream-chat';\n * import { Chat } from 'stream-chat-react-native';\n *\n * const client = StreamChat.getInstance('api_key);\n * await client.connectUser('user_id', 'userToken');\n *\n * <Chat client={client}>\n * </Chat>\n * ```\n *\n * @overrideType StreamChat\n * */\n client: StreamChat<StreamChatGenerics>;\n connectionRecovering: boolean;\n isOnline: boolean;\n mutedUsers: Mute<StreamChatGenerics>[];\n /**\n * @param newChannel Channel to set as active.\n *\n * @overrideType Function\n */\n setActiveChannel: (newChannel?: Channel<StreamChatGenerics>) => void;\n /**\n * Instance of channel object from stream-chat package.\n *\n * Please check the docs around how to create or query channel - https://getstream.io/chat/docs/javascript/creating_channels/?language=javascript\n *\n * ```\n * import { StreamChat, Channel } from 'stream-chat';\n * import { Chat, Channel} from 'stream-chat-react-native';\n *\n * const client = StreamChat.getInstance('api_key');\n * await client.connectUser('user_id', 'user_token');\n * const channel = client.channel('messaging', 'channel_id');\n * await channel.watch();\n * ```\n *\n * @overrideType Channel\n */\n channel?: Channel<StreamChatGenerics>;\n};\n\nexport const ChatContext = React.createContext(DEFAULT_BASE_CONTEXT_VALUE as ChatContextValue);\n\nexport const ChatProvider = <\n StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,\n>({\n children,\n value,\n}: PropsWithChildren<{\n value: ChatContextValue<StreamChatGenerics>;\n}>) => (\n <ChatContext.Provider value={value as unknown as ChatContextValue}>\n {children}\n </ChatContext.Provider>\n);\n\nexport const useChatContext = <\n StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,\n>() => {\n const contextValue = useContext(ChatContext) as unknown as ChatContextValue<StreamChatGenerics>;\n\n if (contextValue === DEFAULT_BASE_CONTEXT_VALUE && !isTestEnvironment()) {\n throw new Error(\n `The useChatContext hook was called outside the ChatContext Provider. Make sure you have configured Chat component correctly - https://getstream.io/chat/docs/sdk/reactnative/basics/hello_stream_chat/#chat`,\n );\n }\n\n return contextValue;\n};\n\n/**\n * Typescript currently does not support partial inference so if ChatContext\n * typing is desired while using the HOC withChatContext the Props for the\n * wrapped component must be provided as the first generic.\n */\nexport const withChatContext = <\n P extends UnknownType,\n StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,\n>(\n Component: React.ComponentType<P>,\n): React.FC<Omit<P, keyof ChatContextValue<StreamChatGenerics>>> => {\n const WithChatContextComponent = (props: Omit<P, keyof ChatContextValue<StreamChatGenerics>>) => {\n const chatContext = useChatContext<StreamChatGenerics>();\n\n return <Component {...(props as P)} {...chatContext} />;\n };\n WithChatContextComponent.displayName = `WithChatContext${getDisplayName(Component)}`;\n return WithChatContextComponent;\n};\n"]}
|
|
@@ -13,8 +13,12 @@ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/sli
|
|
|
13
13
|
|
|
14
14
|
var _react = _interopRequireWildcard(require("react"));
|
|
15
15
|
|
|
16
|
+
var _defaultBaseContextValue = require("../utils/defaultBaseContextValue");
|
|
17
|
+
|
|
16
18
|
var _getDisplayName = require("../utils/getDisplayName");
|
|
17
19
|
|
|
20
|
+
var _isTestEnvironment = require("../utils/isTestEnvironment");
|
|
21
|
+
|
|
18
22
|
var _this = this,
|
|
19
23
|
_jsxFileName = "/home/runner/work/stream-chat-react-native/stream-chat-react-native/package/src/contexts/imageGalleryContext/ImageGalleryContext.tsx";
|
|
20
24
|
|
|
@@ -22,7 +26,7 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
|
|
|
22
26
|
|
|
23
27
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
24
28
|
|
|
25
|
-
var ImageGalleryContext = _react["default"].createContext(
|
|
29
|
+
var ImageGalleryContext = _react["default"].createContext(_defaultBaseContextValue.DEFAULT_BASE_CONTEXT_VALUE);
|
|
26
30
|
|
|
27
31
|
exports.ImageGalleryContext = ImageGalleryContext;
|
|
28
32
|
|
|
@@ -50,7 +54,7 @@ var ImageGalleryProvider = function ImageGalleryProvider(_ref) {
|
|
|
50
54
|
__self: _this,
|
|
51
55
|
__source: {
|
|
52
56
|
fileName: _jsxFileName,
|
|
53
|
-
lineNumber:
|
|
57
|
+
lineNumber: 39,
|
|
54
58
|
columnNumber: 5
|
|
55
59
|
}
|
|
56
60
|
}, children);
|
|
@@ -59,7 +63,13 @@ var ImageGalleryProvider = function ImageGalleryProvider(_ref) {
|
|
|
59
63
|
exports.ImageGalleryProvider = ImageGalleryProvider;
|
|
60
64
|
|
|
61
65
|
var useImageGalleryContext = function useImageGalleryContext() {
|
|
62
|
-
|
|
66
|
+
var contextValue = (0, _react.useContext)(ImageGalleryContext);
|
|
67
|
+
|
|
68
|
+
if (contextValue === _defaultBaseContextValue.DEFAULT_BASE_CONTEXT_VALUE && !(0, _isTestEnvironment.isTestEnvironment)()) {
|
|
69
|
+
throw new Error("The useImageGalleryContext hook was called outside the ImageGalleryContext Provider. Make sure you have configured OverlayProvider component correctly - https://getstream.io/chat/docs/sdk/reactnative/basics/hello_stream_chat/#overlay-provider");
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
return contextValue;
|
|
63
73
|
};
|
|
64
74
|
|
|
65
75
|
exports.useImageGalleryContext = useImageGalleryContext;
|
|
@@ -71,7 +81,7 @@ var withImageGalleryContext = function withImageGalleryContext(Component) {
|
|
|
71
81
|
__self: _this,
|
|
72
82
|
__source: {
|
|
73
83
|
fileName: _jsxFileName,
|
|
74
|
-
lineNumber:
|
|
84
|
+
lineNumber: 74,
|
|
75
85
|
columnNumber: 12
|
|
76
86
|
}
|
|
77
87
|
}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["ImageGalleryContext.tsx"],"names":["ImageGalleryContext","React","createContext","ImageGalleryProvider","children","images","setImages","image","setImage","imageGalleryContext","useImageGalleryContext","withImageGalleryContext","Component","WithImageGalleryContextComponent","props","displayName"],"mappings":";;;;;;;;;;;;;AAAA;;AAIA;;;;;;;;;AAWO,IAAMA,mBAAmB,GAAGC,kBAAMC,aAAN,
|
|
1
|
+
{"version":3,"sources":["ImageGalleryContext.tsx"],"names":["ImageGalleryContext","React","createContext","DEFAULT_BASE_CONTEXT_VALUE","ImageGalleryProvider","children","images","setImages","image","setImage","imageGalleryContext","useImageGalleryContext","contextValue","Error","withImageGalleryContext","Component","WithImageGalleryContextComponent","props","displayName"],"mappings":";;;;;;;;;;;;;AAAA;;AAIA;;AAEA;;AACA;;;;;;;;;AAWO,IAAMA,mBAAmB,GAAGC,kBAAMC,aAAN,CACjCC,mDADiC,CAA5B;;;;AAIA,IAAMC,oBAAoB,GAAG,SAAvBA,oBAAuB,OAIE;AAAA,MADpCC,QACoC,QADpCA,QACoC;;AACpC,kBAA4B,qBAA4C,EAA5C,CAA5B;AAAA;AAAA,MAAOC,MAAP;AAAA,MAAeC,SAAf;;AACA,mBAA0B,sBAA1B;AAAA;AAAA,MAAOC,KAAP;AAAA,MAAcC,QAAd;;AAEA,MAAMC,mBAAmB,GAAG;AAC1BF,IAAAA,KAAK,EAALA,KAD0B;AAE1BF,IAAAA,MAAM,EAANA,MAF0B;AAG1BG,IAAAA,QAAQ,EAARA,QAH0B;AAI1BF,IAAAA,SAAS,EAATA;AAJ0B,GAA5B;AAOA,SACE,gCAAC,mBAAD,CAAqB,QAArB;AACE,IAAA,KAAK,EAAEG,mBADT;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,KAGGL,QAHH,CADF;AAOD,CAtBM;;;;AAwBA,IAAMM,sBAAsB,GAAG,SAAzBA,sBAAyB,GAE/B;AACL,MAAMC,YAAY,GAAG,uBACnBZ,mBADmB,CAArB;;AAIA,MAAIY,YAAY,KAAKT,mDAAjB,IAA+C,CAAC,2CAApD,EAAyE;AACvE,UAAM,IAAIU,KAAJ,sPAAN;AAGD;;AAED,SAAOD,YAAP;AACD,CAdM;;;;AAgBA,IAAME,uBAAuB,GAAG,SAA1BA,uBAA0B,CAIrCC,SAJqC,EAKqC;AAC1E,MAAMC,gCAAgC,GAAG,SAAnCA,gCAAmC,CACvCC,KADuC,EAEpC;AACH,QAAMP,mBAAmB,GAAGC,sBAAsB,EAAlD;AAEA,WAAO,gCAAC,SAAD,gCAAgBM,KAAhB,EAAiCP,mBAAjC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,OAAP;AACD,GAND;;AAOAM,EAAAA,gCAAgC,CAACE,WAAjC,+BAAyE,oCACvEH,SADuE,CAAzE;AAGA,SAAOC,gCAAP;AACD,CAjBM","sourcesContent":["import React, { PropsWithChildren, useContext, useState } from 'react';\n\nimport type { MessageType } from '../../components/MessageList/hooks/useMessageList';\nimport type { DefaultStreamChatGenerics, UnknownType } from '../../types/types';\nimport { DEFAULT_BASE_CONTEXT_VALUE } from '../utils/defaultBaseContextValue';\n\nimport { getDisplayName } from '../utils/getDisplayName';\nimport { isTestEnvironment } from '../utils/isTestEnvironment';\n\nexport type ImageGalleryContextValue<\n StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,\n> = {\n images: MessageType<StreamChatGenerics>[];\n setImage: React.Dispatch<React.SetStateAction<{ messageId?: string; url?: string } | undefined>>;\n setImages: React.Dispatch<React.SetStateAction<MessageType<StreamChatGenerics>[]>>;\n image?: { messageId?: string; url?: string };\n};\n\nexport const ImageGalleryContext = React.createContext(\n DEFAULT_BASE_CONTEXT_VALUE as ImageGalleryContextValue,\n);\n\nexport const ImageGalleryProvider = <\n StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,\n>({\n children,\n}: PropsWithChildren<UnknownType>) => {\n const [images, setImages] = useState<MessageType<StreamChatGenerics>[]>([]);\n const [image, setImage] = useState<{ messageId?: string; url?: string }>();\n\n const imageGalleryContext = {\n image,\n images,\n setImage,\n setImages,\n };\n\n return (\n <ImageGalleryContext.Provider\n value={imageGalleryContext as unknown as ImageGalleryContextValue}\n >\n {children}\n </ImageGalleryContext.Provider>\n );\n};\n\nexport const useImageGalleryContext = <\n StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,\n>() => {\n const contextValue = useContext(\n ImageGalleryContext,\n ) as unknown as ImageGalleryContextValue<StreamChatGenerics>;\n\n if (contextValue === DEFAULT_BASE_CONTEXT_VALUE && !isTestEnvironment()) {\n throw new Error(\n `The useImageGalleryContext hook was called outside the ImageGalleryContext Provider. Make sure you have configured OverlayProvider component correctly - https://getstream.io/chat/docs/sdk/reactnative/basics/hello_stream_chat/#overlay-provider`,\n );\n }\n\n return contextValue as ImageGalleryContextValue<StreamChatGenerics>;\n};\n\nexport const withImageGalleryContext = <\n P extends UnknownType,\n StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,\n>(\n Component: React.ComponentType<P>,\n): React.FC<Omit<P, keyof ImageGalleryContextValue<StreamChatGenerics>>> => {\n const WithImageGalleryContextComponent = (\n props: Omit<P, keyof ImageGalleryContextValue<StreamChatGenerics>>,\n ) => {\n const imageGalleryContext = useImageGalleryContext<StreamChatGenerics>();\n\n return <Component {...(props as P)} {...imageGalleryContext} />;\n };\n WithImageGalleryContextComponent.displayName = `WithImageGalleryContext${getDisplayName(\n Component,\n )}`;\n return WithImageGalleryContextComponent;\n};\n"]}
|
|
@@ -36,7 +36,7 @@ var KeyboardProvider = function KeyboardProvider(_ref) {
|
|
|
36
36
|
__self: _this,
|
|
37
37
|
__source: {
|
|
38
38
|
fileName: _jsxFileName,
|
|
39
|
-
lineNumber:
|
|
39
|
+
lineNumber: 19,
|
|
40
40
|
columnNumber: 3
|
|
41
41
|
}
|
|
42
42
|
}, children);
|
|
@@ -57,7 +57,7 @@ var withKeyboardContext = function withKeyboardContext(Component) {
|
|
|
57
57
|
__self: _this,
|
|
58
58
|
__source: {
|
|
59
59
|
fileName: _jsxFileName,
|
|
60
|
-
lineNumber:
|
|
60
|
+
lineNumber: 34,
|
|
61
61
|
columnNumber: 12
|
|
62
62
|
}
|
|
63
63
|
}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["KeyboardContext.tsx"],"names":["KeyboardContext","React","createContext","dismissKeyboard","Keyboard","dismiss","KeyboardProvider","children","value","useKeyboardContext","withKeyboardContext","Component","WithKeyboardContextComponent","props","keyboardContext","displayName"],"mappings":";;;;;;;;;;;AAAA;;
|
|
1
|
+
{"version":3,"sources":["KeyboardContext.tsx"],"names":["KeyboardContext","React","createContext","dismissKeyboard","Keyboard","dismiss","KeyboardProvider","children","value","useKeyboardContext","withKeyboardContext","Component","WithKeyboardContextComponent","props","keyboardContext","displayName"],"mappings":";;;;;;;;;;;AAAA;;AAEA;;AAGA;;;;;;;;;AAMO,IAAMA,eAAe,GAAGC,kBAAMC,aAAN,CAAoB;AACjDC,EAAAA,eAAe,EAAEC,sBAASC;AADuB,CAApB,CAAxB;;;;AAIA,IAAMC,gBAEX,GAAG,SAFQA,gBAER;AAAA,MAAGC,QAAH,QAAGA,QAAH;AAAA,MAAaC,KAAb,QAAaA,KAAb;AAAA,SACH,gCAAC,eAAD,CAAiB,QAAjB;AAA0B,IAAA,KAAK,EAAEA,KAAjC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,KAAyCD,QAAzC,CADG;AAAA,CAFE;;;;AAMA,IAAME,kBAAkB,GAAG,SAArBA,kBAAqB;AAAA,SAAM,uBAAWT,eAAX,CAAN;AAAA,CAA3B;;;;AAEA,IAAMU,mBAAmB,GAAG,SAAtBA,mBAAsB,CAGjCC,SAHiC,EAIkC;AACnE,MAAMC,4BAA4B,GAAG,SAA/BA,4BAA+B,CACnCC,KADmC,EAEhC;AACH,QAAMC,eAAe,GAAGL,kBAAkB,EAA1C;AAEA,WAAO,gCAAC,SAAD,gCAAgBI,KAAhB,EAAkDC,eAAlD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,OAAP;AACD,GAND;;AAOAF,EAAAA,4BAA4B,CAACG,WAA7B,2BAAiE,oCAC/DJ,SAD+D,CAAjE;AAGA,SAAOC,4BAAP;AACD,CAhBM","sourcesContent":["import React, { useContext } from 'react';\n\nimport { Keyboard } from 'react-native';\n\nimport type { DefaultStreamChatGenerics } from '../../types/types';\nimport { getDisplayName } from '../utils/getDisplayName';\n\nexport type KeyboardContextValue = {\n dismissKeyboard: () => void;\n};\n\nexport const KeyboardContext = React.createContext({\n dismissKeyboard: Keyboard.dismiss,\n});\n\nexport const KeyboardProvider: React.FC<{\n value: KeyboardContextValue;\n}> = ({ children, value }) => (\n <KeyboardContext.Provider value={value}>{children}</KeyboardContext.Provider>\n);\n\nexport const useKeyboardContext = () => useContext(KeyboardContext);\n\nexport const withKeyboardContext = <\n StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,\n>(\n Component: React.ComponentType<StreamChatGenerics>,\n): React.FC<Omit<StreamChatGenerics, keyof KeyboardContextValue>> => {\n const WithKeyboardContextComponent = (\n props: Omit<StreamChatGenerics, keyof KeyboardContextValue>,\n ) => {\n const keyboardContext = useKeyboardContext();\n\n return <Component {...(props as StreamChatGenerics)} {...keyboardContext} />;\n };\n WithKeyboardContextComponent.displayName = `WithKeyboardContext${getDisplayName(\n Component as React.ComponentType,\n )}`;\n return WithKeyboardContextComponent;\n};\n"]}
|
|
@@ -11,8 +11,12 @@ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")
|
|
|
11
11
|
|
|
12
12
|
var _react = _interopRequireWildcard(require("react"));
|
|
13
13
|
|
|
14
|
+
var _defaultBaseContextValue = require("../utils/defaultBaseContextValue");
|
|
15
|
+
|
|
14
16
|
var _getDisplayName = require("../utils/getDisplayName");
|
|
15
17
|
|
|
18
|
+
var _isTestEnvironment = require("../utils/isTestEnvironment");
|
|
19
|
+
|
|
16
20
|
var _this = this,
|
|
17
21
|
_jsxFileName = "/home/runner/work/stream-chat-react-native/stream-chat-react-native/package/src/contexts/messageContext/MessageContext.tsx";
|
|
18
22
|
|
|
@@ -20,7 +24,7 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
|
|
|
20
24
|
|
|
21
25
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
22
26
|
|
|
23
|
-
var MessageContext = _react["default"].createContext(
|
|
27
|
+
var MessageContext = _react["default"].createContext(_defaultBaseContextValue.DEFAULT_BASE_CONTEXT_VALUE);
|
|
24
28
|
|
|
25
29
|
exports.MessageContext = MessageContext;
|
|
26
30
|
|
|
@@ -32,7 +36,7 @@ var MessageProvider = function MessageProvider(_ref) {
|
|
|
32
36
|
__self: _this,
|
|
33
37
|
__source: {
|
|
34
38
|
fileName: _jsxFileName,
|
|
35
|
-
lineNumber:
|
|
39
|
+
lineNumber: 120,
|
|
36
40
|
columnNumber: 3
|
|
37
41
|
}
|
|
38
42
|
}, children);
|
|
@@ -41,7 +45,13 @@ var MessageProvider = function MessageProvider(_ref) {
|
|
|
41
45
|
exports.MessageProvider = MessageProvider;
|
|
42
46
|
|
|
43
47
|
var useMessageContext = function useMessageContext() {
|
|
44
|
-
|
|
48
|
+
var contextValue = (0, _react.useContext)(MessageContext);
|
|
49
|
+
|
|
50
|
+
if (contextValue === _defaultBaseContextValue.DEFAULT_BASE_CONTEXT_VALUE && !(0, _isTestEnvironment.isTestEnvironment)()) {
|
|
51
|
+
throw new Error("The useMessageContext hook was called outside of the MessageContext provider. Make sure you have configured MessageList component correctly - https://getstream.io/chat/docs/sdk/reactnative/basics/hello_stream_chat/#message-list");
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return contextValue;
|
|
45
55
|
};
|
|
46
56
|
|
|
47
57
|
exports.useMessageContext = useMessageContext;
|
|
@@ -53,7 +63,7 @@ var withMessageContext = function withMessageContext(Component) {
|
|
|
53
63
|
__self: _this,
|
|
54
64
|
__source: {
|
|
55
65
|
fileName: _jsxFileName,
|
|
56
|
-
lineNumber:
|
|
66
|
+
lineNumber: 157,
|
|
57
67
|
columnNumber: 12
|
|
58
68
|
}
|
|
59
69
|
}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["MessageContext.tsx"],"names":["MessageContext","React","createContext","MessageProvider","children","value","useMessageContext","withMessageContext","Component","WithMessageContextComponent","props","messageContext","displayName"],"mappings":";;;;;;;;;;;AAAA;;AAaA;;;;;;;;;AA2FO,IAAMA,cAAc,GAAGC,kBAAMC,aAAN,
|
|
1
|
+
{"version":3,"sources":["MessageContext.tsx"],"names":["MessageContext","React","createContext","DEFAULT_BASE_CONTEXT_VALUE","MessageProvider","children","value","useMessageContext","contextValue","Error","withMessageContext","Component","WithMessageContextComponent","props","messageContext","displayName"],"mappings":";;;;;;;;;;;AAAA;;AAaA;;AAEA;;AACA;;;;;;;;;AA2FO,IAAMA,cAAc,GAAGC,kBAAMC,aAAN,CAC5BC,mDAD4B,CAAvB;;;;AAIA,IAAMC,eAAe,GAAG,SAAlBA,eAAkB;AAAA,MAG7BC,QAH6B,QAG7BA,QAH6B;AAAA,MAI7BC,KAJ6B,QAI7BA,KAJ6B;AAAA,SAQ7B,gCAAC,cAAD,CAAgB,QAAhB;AAAyB,IAAA,KAAK,EAAEA,KAAhC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,KACGD,QADH,CAR6B;AAAA,CAAxB;;;;AAaA,IAAME,iBAAiB,GAAG,SAApBA,iBAAoB,GAE1B;AACL,MAAMC,YAAY,GAAG,uBACnBR,cADmB,CAArB;;AAIA,MAAIQ,YAAY,KAAKL,mDAAjB,IAA+C,CAAC,2CAApD,EAAyE;AACvE,UAAM,IAAIM,KAAJ,uOAAN;AAGD;;AAED,SAAOD,YAAP;AACD,CAdM;;;;AAqBA,IAAME,kBAAkB,GAAG,SAArBA,kBAAqB,CAIhCC,SAJgC,EAKqC;AACrE,MAAMC,2BAA2B,GAAG,SAA9BA,2BAA8B,CAClCC,KADkC,EAE/B;AACH,QAAMC,cAAc,GAAGP,iBAAiB,EAAxC;AAEA,WAAO,gCAAC,SAAD,gCAAgBM,KAAhB,EAAiCC,cAAjC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,OAAP;AACD,GAND;;AAOAF,EAAAA,2BAA2B,CAACG,WAA5B,0BAA+D,oCAAeJ,SAAf,CAA/D;AACA,SAAOC,2BAAP;AACD,CAfM","sourcesContent":["import React, { PropsWithChildren, useContext } from 'react';\n\nimport type { Attachment } from 'stream-chat';\n\nimport type { ActionHandler } from '../../components/Attachment/Attachment';\nimport type {\n MessageTouchableHandlerPayload,\n TouchableHandlerPayload,\n} from '../../components/Message/Message';\nimport type { GroupType, MessageType } from '../../components/MessageList/hooks/useMessageList';\nimport type { ChannelContextValue } from '../../contexts/channelContext/ChannelContext';\nimport type { MessageContentType } from '../../contexts/messagesContext/MessagesContext';\nimport type { DefaultStreamChatGenerics, UnknownType } from '../../types/types';\nimport { DEFAULT_BASE_CONTEXT_VALUE } from '../utils/defaultBaseContextValue';\n\nimport { getDisplayName } from '../utils/getDisplayName';\nimport { isTestEnvironment } from '../utils/isTestEnvironment';\n\nexport type Alignment = 'right' | 'left';\n\nexport type Reactions = {\n own: boolean;\n type: string;\n}[];\n\nexport type MessageContextValue<\n StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,\n> = {\n /** Whether or not actions can be performed on message */\n actionsEnabled: boolean;\n /** Position of the message, either 'right' or 'left' */\n alignment: Alignment;\n /** The files attached to a message */\n files: Attachment<StreamChatGenerics>[];\n /**\n * Position of message in group - top, bottom, middle, single.\n *\n * Message group is a group of consecutive messages from same user. groupStyles can be used to style message as per their position in message group\n * e.g., user avatar (to which message belongs to) is only showed for last (bottom) message in group.\n */\n groupStyles: GroupType[];\n /** Handler for actions. Actions in combination with attachments can be used to build [commands](https://getstream.io/chat/docs/#channel_commands). */\n handleAction: ActionHandler;\n handleDeleteMessage: () => Promise<void>;\n handleEditMessage: () => void;\n handleQuotedReplyMessage: () => void;\n handleResendMessage: () => Promise<void>;\n handleToggleBanUser: () => Promise<void>;\n handleToggleMuteUser: () => Promise<void>;\n handleToggleReaction: (reactionType: string) => Promise<void>;\n /** Whether or not message has reactions */\n hasReactions: boolean;\n /** The images attached to a message */\n images: Attachment<StreamChatGenerics>[];\n /** Whether or not this is the active user's message */\n isMyMessage: boolean;\n /** Whether or not this is the last message in a group of messages */\n lastGroupMessage: boolean;\n /** Current [message object](https://getstream.io/chat/docs/#message_format) */\n message: MessageType<StreamChatGenerics>;\n /** Order to render the message content */\n messageContentOrder: MessageContentType[];\n /**\n * You can call methods available on the Message\n * component such as handleEdit, handleDelete, handleAction etc.\n *\n * Source - [Message](https://github.com/GetStream/stream-chat-react-native/blob/main/package/src/components/Message/Message.tsx)\n *\n * By default, we show the overlay with all the message actions on long press.\n *\n * @param payload Payload object for onLongPress event\n */\n onLongPress: (payload: TouchableHandlerPayload) => void;\n /** Whether the message is only text and the text is only emojis */\n onlyEmojis: boolean;\n /** Handler to open a thread on a message */\n onOpenThread: () => void;\n /**\n * You can call methods available on the Message\n * component such as handleEdit, handleDelete, handleAction etc.\n *\n * Source - [Message](https://github.com/GetStream/stream-chat-react-native/blob/main/package/src/components/Message/Message.tsx)\n *\n * By default, we will dismiss the keyboard on press.\n *\n * @param payload Payload object for onPress event\n */\n onPress: (payload: MessageTouchableHandlerPayload) => void;\n onPressIn: ((payload: TouchableHandlerPayload) => void) | null;\n /** The images attached to a message */\n otherAttachments: Attachment<StreamChatGenerics>[];\n reactions: Reactions;\n showMessageOverlay: (messageReactions?: boolean) => void;\n showMessageStatus: boolean;\n /** Whether or not the Message is part of a Thread */\n threadList: boolean;\n /** The videos attached to a message */\n videos: Attachment<StreamChatGenerics>[];\n goToMessage?: (messageId: string) => void;\n /** Latest message id on current channel */\n lastReceivedId?: string;\n /** Prevent message being pressed for image viewer view */\n preventPress?: boolean;\n /** Whether or not the avatar show show next to Message */\n showAvatar?: boolean;\n} & Pick<ChannelContextValue<StreamChatGenerics>, 'channel' | 'disabled' | 'members'>;\n\nexport const MessageContext = React.createContext(\n DEFAULT_BASE_CONTEXT_VALUE as MessageContextValue,\n);\n\nexport const MessageProvider = <\n StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,\n>({\n children,\n value,\n}: PropsWithChildren<{\n value?: MessageContextValue<StreamChatGenerics>;\n}>) => (\n <MessageContext.Provider value={value as unknown as MessageContextValue}>\n {children}\n </MessageContext.Provider>\n);\n\nexport const useMessageContext = <\n StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,\n>() => {\n const contextValue = useContext(\n MessageContext,\n ) as unknown as MessageContextValue<StreamChatGenerics>;\n\n if (contextValue === DEFAULT_BASE_CONTEXT_VALUE && !isTestEnvironment()) {\n throw new Error(\n `The useMessageContext hook was called outside of the MessageContext provider. Make sure you have configured MessageList component correctly - https://getstream.io/chat/docs/sdk/reactnative/basics/hello_stream_chat/#message-list`,\n );\n }\n\n return contextValue;\n};\n\n/**\n * Typescript currently does not support partial inference so if MessageContext\n * typing is desired while using the HOC withMessageContextContext the Props for the\n * wrapped component must be provided as the first generic.\n */\nexport const withMessageContext = <\n P extends UnknownType,\n StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,\n>(\n Component: React.ComponentType<P>,\n): React.FC<Omit<P, keyof MessageContextValue<StreamChatGenerics>>> => {\n const WithMessageContextComponent = (\n props: Omit<P, keyof MessageContextValue<StreamChatGenerics>>,\n ) => {\n const messageContext = useMessageContext<StreamChatGenerics>();\n\n return <Component {...(props as P)} {...messageContext} />;\n };\n WithMessageContextComponent.displayName = `WithMessageContext${getDisplayName(Component)}`;\n return WithMessageContextComponent;\n};\n"]}
|
|
@@ -51,8 +51,12 @@ var _ThreadContext = require("../threadContext/ThreadContext");
|
|
|
51
51
|
|
|
52
52
|
var _TranslationContext = require("../translationContext/TranslationContext");
|
|
53
53
|
|
|
54
|
+
var _defaultBaseContextValue = require("../utils/defaultBaseContextValue");
|
|
55
|
+
|
|
54
56
|
var _getDisplayName = require("../utils/getDisplayName");
|
|
55
57
|
|
|
58
|
+
var _isTestEnvironment = require("../utils/isTestEnvironment");
|
|
59
|
+
|
|
56
60
|
var _this = this,
|
|
57
61
|
_jsxFileName = "/home/runner/work/stream-chat-react-native/stream-chat-react-native/package/src/contexts/messageInputContext/MessageInputContext.tsx";
|
|
58
62
|
|
|
@@ -66,7 +70,7 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
|
|
|
66
70
|
|
|
67
71
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
68
72
|
|
|
69
|
-
var MessageInputContext = _react["default"].createContext(
|
|
73
|
+
var MessageInputContext = _react["default"].createContext(_defaultBaseContextValue.DEFAULT_BASE_CONTEXT_VALUE);
|
|
70
74
|
|
|
71
75
|
exports.MessageInputContext = MessageInputContext;
|
|
72
76
|
|
|
@@ -1128,7 +1132,7 @@ var MessageInputProvider = function MessageInputProvider(_ref) {
|
|
|
1128
1132
|
__self: _this,
|
|
1129
1133
|
__source: {
|
|
1130
1134
|
fileName: _jsxFileName,
|
|
1131
|
-
lineNumber:
|
|
1135
|
+
lineNumber: 1128,
|
|
1132
1136
|
columnNumber: 5
|
|
1133
1137
|
}
|
|
1134
1138
|
}, children);
|
|
@@ -1137,7 +1141,13 @@ var MessageInputProvider = function MessageInputProvider(_ref) {
|
|
|
1137
1141
|
exports.MessageInputProvider = MessageInputProvider;
|
|
1138
1142
|
|
|
1139
1143
|
var useMessageInputContext = function useMessageInputContext() {
|
|
1140
|
-
|
|
1144
|
+
var contextValue = (0, _react.useContext)(MessageInputContext);
|
|
1145
|
+
|
|
1146
|
+
if (contextValue === _defaultBaseContextValue.DEFAULT_BASE_CONTEXT_VALUE && !(0, _isTestEnvironment.isTestEnvironment)()) {
|
|
1147
|
+
throw new Error("The useMessageInputContext hook was called outside of the MessageInputContext provider. Make sure you have configured Channel component correctly - https://getstream.io/chat/docs/sdk/reactnative/basics/hello_stream_chat/#channel");
|
|
1148
|
+
}
|
|
1149
|
+
|
|
1150
|
+
return contextValue;
|
|
1141
1151
|
};
|
|
1142
1152
|
|
|
1143
1153
|
exports.useMessageInputContext = useMessageInputContext;
|
|
@@ -1149,7 +1159,7 @@ var withMessageInputContext = function withMessageInputContext(Component) {
|
|
|
1149
1159
|
__self: _this,
|
|
1150
1160
|
__source: {
|
|
1151
1161
|
fileName: _jsxFileName,
|
|
1152
|
-
lineNumber:
|
|
1162
|
+
lineNumber: 1168,
|
|
1153
1163
|
columnNumber: 12
|
|
1154
1164
|
}
|
|
1155
1165
|
}));
|