stream-chat-react-native-core 6.0.0-rc.9 → 6.0.0
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/README.md +1 -1
- package/lib/commonjs/components/AITypingIndicatorView/AITypingIndicatorView.js +53 -0
- package/lib/commonjs/components/AITypingIndicatorView/AITypingIndicatorView.js.map +1 -0
- package/lib/commonjs/components/AITypingIndicatorView/hooks/useAIState.js +59 -0
- package/lib/commonjs/components/AITypingIndicatorView/hooks/useAIState.js.map +1 -0
- package/lib/commonjs/components/AITypingIndicatorView/index.js +26 -0
- package/lib/commonjs/components/AITypingIndicatorView/index.js.map +1 -0
- package/lib/commonjs/components/Attachment/AudioAttachment.js +27 -22
- package/lib/commonjs/components/Attachment/AudioAttachment.js.map +1 -1
- package/lib/commonjs/components/Attachment/Gallery.js +3 -1
- package/lib/commonjs/components/Attachment/Gallery.js.map +1 -1
- package/lib/commonjs/components/AttachmentPicker/AttachmentPicker.js +2 -2
- package/lib/commonjs/components/AttachmentPicker/AttachmentPicker.js.map +1 -1
- package/lib/commonjs/components/AttachmentPicker/components/AttachmentPickerItem.js +37 -133
- package/lib/commonjs/components/AttachmentPicker/components/AttachmentPickerItem.js.map +1 -1
- package/lib/commonjs/components/AttachmentPicker/components/AttachmentPickerSelectionBar.js +6 -4
- package/lib/commonjs/components/AttachmentPicker/components/AttachmentPickerSelectionBar.js.map +1 -1
- package/lib/commonjs/components/Channel/Channel.js +478 -1045
- package/lib/commonjs/components/Channel/Channel.js.map +1 -1
- package/lib/commonjs/components/Channel/hooks/useChannelDataState.js +174 -0
- package/lib/commonjs/components/Channel/hooks/useChannelDataState.js.map +1 -0
- package/lib/commonjs/components/Channel/hooks/useCreateInputMessageInputContext.js +2 -0
- package/lib/commonjs/components/Channel/hooks/useCreateInputMessageInputContext.js.map +1 -1
- package/lib/commonjs/components/Channel/hooks/useCreateMessagesContext.js +4 -0
- package/lib/commonjs/components/Channel/hooks/useCreateMessagesContext.js.map +1 -1
- package/lib/commonjs/components/Channel/hooks/useCreatePaginatedMessageListContext.js +3 -3
- package/lib/commonjs/components/Channel/hooks/useCreatePaginatedMessageListContext.js.map +1 -1
- package/lib/commonjs/components/Channel/hooks/useMessageListPagination.js +324 -0
- package/lib/commonjs/components/Channel/hooks/useMessageListPagination.js.map +1 -0
- package/lib/commonjs/components/ChannelList/Skeleton.js +7 -3
- package/lib/commonjs/components/ChannelList/Skeleton.js.map +1 -1
- package/lib/commonjs/components/ChannelList/hooks/usePaginatedChannels.js +85 -45
- package/lib/commonjs/components/ChannelList/hooks/usePaginatedChannels.js.map +1 -1
- package/lib/commonjs/components/ChannelPreview/ChannelPreview.js +17 -91
- package/lib/commonjs/components/ChannelPreview/ChannelPreview.js.map +1 -1
- package/lib/commonjs/components/ChannelPreview/ChannelPreviewMessenger.js +3 -24
- package/lib/commonjs/components/ChannelPreview/ChannelPreviewMessenger.js.map +1 -1
- package/lib/commonjs/components/ChannelPreview/ChannelPreviewMutedStatus.js +2 -2
- package/lib/commonjs/components/ChannelPreview/ChannelPreviewMutedStatus.js.map +1 -1
- package/lib/commonjs/components/ChannelPreview/hooks/useChannelPreviewData.js +121 -0
- package/lib/commonjs/components/ChannelPreview/hooks/useChannelPreviewData.js.map +1 -0
- package/lib/commonjs/components/ChannelPreview/hooks/useIsChannelMuted.js +35 -0
- package/lib/commonjs/components/ChannelPreview/hooks/useIsChannelMuted.js.map +1 -0
- package/lib/commonjs/components/Chat/Chat.js +5 -1
- package/lib/commonjs/components/Chat/Chat.js.map +1 -1
- package/lib/commonjs/components/Chat/hooks/useAppSettings.js +15 -9
- package/lib/commonjs/components/Chat/hooks/useAppSettings.js.map +1 -1
- package/lib/commonjs/components/Chat/hooks/useCreateChatContext.js +2 -0
- package/lib/commonjs/components/Chat/hooks/useCreateChatContext.js.map +1 -1
- package/lib/commonjs/components/Chat/hooks/useIsOnline.js +0 -4
- package/lib/commonjs/components/Chat/hooks/useIsOnline.js.map +1 -1
- package/lib/commonjs/components/ImageGallery/ImageGallery.js.map +1 -1
- package/lib/commonjs/components/ImageGallery/components/ImageGalleryFooter.js +46 -46
- package/lib/commonjs/components/ImageGallery/components/ImageGalleryFooter.js.map +1 -1
- package/lib/commonjs/components/ImageGallery/components/ImageGalleryHeader.js +3 -4
- package/lib/commonjs/components/ImageGallery/components/ImageGalleryHeader.js.map +1 -1
- package/lib/commonjs/components/ImageGallery/hooks/useAnimatedGalleryStyle.js +2 -2
- package/lib/commonjs/components/ImageGallery/hooks/useAnimatedGalleryStyle.js.map +1 -1
- package/lib/commonjs/components/Message/Message.js +7 -0
- package/lib/commonjs/components/Message/Message.js.map +1 -1
- package/lib/commonjs/components/Message/MessageSimple/MessageContent.js +17 -4
- package/lib/commonjs/components/Message/MessageSimple/MessageContent.js.map +1 -1
- package/lib/commonjs/components/Message/MessageSimple/MessageFooter.js +15 -6
- package/lib/commonjs/components/Message/MessageSimple/MessageFooter.js.map +1 -1
- package/lib/commonjs/components/Message/MessageSimple/StreamingMessageView.js +36 -0
- package/lib/commonjs/components/Message/MessageSimple/StreamingMessageView.js.map +1 -0
- package/lib/commonjs/components/Message/MessageSimple/utils/generateMarkdownText.js +9 -1
- package/lib/commonjs/components/Message/MessageSimple/utils/generateMarkdownText.js.map +1 -1
- package/lib/commonjs/components/Message/MessageSimple/utils/renderText.js +209 -23
- package/lib/commonjs/components/Message/MessageSimple/utils/renderText.js.map +1 -1
- package/lib/commonjs/components/Message/hooks/useCreateMessageContext.js +2 -0
- package/lib/commonjs/components/Message/hooks/useCreateMessageContext.js.map +1 -1
- package/lib/commonjs/components/Message/hooks/useStreamingMessage.js +43 -0
- package/lib/commonjs/components/Message/hooks/useStreamingMessage.js.map +1 -0
- package/lib/commonjs/components/MessageInput/MessageInput.js +41 -21
- package/lib/commonjs/components/MessageInput/MessageInput.js.map +1 -1
- package/lib/commonjs/components/MessageInput/StopMessageStreamingButton.js +39 -0
- package/lib/commonjs/components/MessageInput/StopMessageStreamingButton.js.map +1 -0
- package/lib/commonjs/components/MessageList/MessageList.js +74 -73
- package/lib/commonjs/components/MessageList/MessageList.js.map +1 -1
- package/lib/commonjs/components/MessageList/ScrollToBottomButton.js +1 -1
- package/lib/commonjs/components/MessageList/ScrollToBottomButton.js.map +1 -1
- package/lib/commonjs/components/MessageList/hooks/useMessageList.js.map +1 -1
- package/lib/commonjs/components/MessageList/utils/getReadStates.js.map +1 -1
- package/lib/commonjs/components/MessageMenu/MessageUserReactions.js +1 -1
- package/lib/commonjs/components/MessageMenu/MessageUserReactions.js.map +1 -1
- package/lib/commonjs/components/MessageMenu/MessageUserReactionsItem.js +4 -2
- package/lib/commonjs/components/MessageMenu/MessageUserReactionsItem.js.map +1 -1
- package/lib/commonjs/components/MessageMenu/hooks/useFetchReactions.js +3 -2
- package/lib/commonjs/components/MessageMenu/hooks/useFetchReactions.js.map +1 -1
- package/lib/commonjs/components/Poll/CreatePollContent.js +14 -9
- package/lib/commonjs/components/Poll/CreatePollContent.js.map +1 -1
- package/lib/commonjs/components/Poll/Poll.js +2 -8
- package/lib/commonjs/components/Poll/Poll.js.map +1 -1
- package/lib/commonjs/components/Poll/components/Button.js +9 -474
- package/lib/commonjs/components/Poll/components/Button.js.map +1 -1
- package/lib/commonjs/components/Poll/components/CreatePollIcon.js +2 -2
- package/lib/commonjs/components/Poll/components/CreatePollIcon.js.map +1 -1
- package/lib/commonjs/components/Poll/components/CreatePollOptions.js +9 -4
- package/lib/commonjs/components/Poll/components/CreatePollOptions.js.map +1 -1
- package/lib/commonjs/components/Poll/components/PollAnswersList.js +99 -26
- package/lib/commonjs/components/Poll/components/PollAnswersList.js.map +1 -1
- package/lib/commonjs/components/Poll/components/PollButtons.js +291 -0
- package/lib/commonjs/components/Poll/components/PollButtons.js.map +1 -0
- package/lib/commonjs/components/Poll/components/PollInputDialog.js +14 -4
- package/lib/commonjs/components/Poll/components/PollInputDialog.js.map +1 -1
- package/lib/commonjs/components/Poll/components/PollModalHeader.js +7 -1
- package/lib/commonjs/components/Poll/components/PollModalHeader.js.map +1 -1
- package/lib/commonjs/components/Poll/components/PollOption.js +88 -6
- package/lib/commonjs/components/Poll/components/PollOption.js.map +1 -1
- package/lib/commonjs/components/Poll/components/PollResults/PollOptionFullResults.js +2 -2
- package/lib/commonjs/components/Poll/components/PollResults/PollOptionFullResults.js.map +1 -1
- package/lib/commonjs/components/Poll/components/PollResults/PollResultItem.js +62 -67
- package/lib/commonjs/components/Poll/components/PollResults/PollResultItem.js.map +1 -1
- package/lib/commonjs/components/Poll/components/PollResults/PollVote.js +89 -0
- package/lib/commonjs/components/Poll/components/PollResults/PollVote.js.map +1 -0
- package/lib/commonjs/components/Poll/components/index.js +11 -0
- package/lib/commonjs/components/Poll/components/index.js.map +1 -1
- package/lib/commonjs/components/ThreadList/ThreadList.js +0 -3
- package/lib/commonjs/components/ThreadList/ThreadList.js.map +1 -1
- package/lib/commonjs/components/UIComponents/BottomSheetModal.js +11 -5
- package/lib/commonjs/components/UIComponents/BottomSheetModal.js.map +1 -1
- package/lib/commonjs/components/index.js +66 -0
- package/lib/commonjs/components/index.js.map +1 -1
- package/lib/commonjs/contexts/channelContext/ChannelContext.js.map +1 -1
- package/lib/commonjs/contexts/channelsStateContext/ChannelsStateContext.js +0 -35
- package/lib/commonjs/contexts/channelsStateContext/ChannelsStateContext.js.map +1 -1
- package/lib/commonjs/contexts/channelsStateContext/useChannelState.js +7 -84
- package/lib/commonjs/contexts/channelsStateContext/useChannelState.js.map +1 -1
- package/lib/commonjs/contexts/chatContext/ChatContext.js.map +1 -1
- package/lib/commonjs/contexts/messageContext/MessageContext.js.map +1 -1
- package/lib/commonjs/contexts/messageInputContext/MessageInputContext.js +4 -2
- package/lib/commonjs/contexts/messageInputContext/MessageInputContext.js.map +1 -1
- package/lib/commonjs/contexts/messageInputContext/hooks/useCreateMessageInputContext.js +2 -0
- package/lib/commonjs/contexts/messageInputContext/hooks/useCreateMessageInputContext.js.map +1 -1
- package/lib/commonjs/contexts/messagesContext/MessagesContext.js.map +1 -1
- package/lib/commonjs/contexts/paginatedMessageListContext/PaginatedMessageListContext.js.map +1 -1
- package/lib/commonjs/contexts/themeContext/utils/theme.js +15 -0
- package/lib/commonjs/contexts/themeContext/utils/theme.js.map +1 -1
- package/lib/commonjs/i18n/en.json +2 -0
- package/lib/commonjs/i18n/es.json +2 -0
- package/lib/commonjs/i18n/fr.json +2 -0
- package/lib/commonjs/i18n/he.json +2 -0
- package/lib/commonjs/i18n/hi.json +2 -0
- package/lib/commonjs/i18n/it.json +2 -0
- package/lib/commonjs/i18n/ja.json +2 -0
- package/lib/commonjs/i18n/ko.json +2 -0
- package/lib/commonjs/i18n/nl.json +2 -0
- package/lib/commonjs/i18n/pt-br.json +2 -0
- package/lib/commonjs/i18n/ru.json +2 -0
- package/lib/commonjs/i18n/tr.json +2 -0
- package/lib/commonjs/mock-builders/event/notificationChannelMutesUpdated.js +14 -0
- package/lib/commonjs/mock-builders/event/notificationChannelMutesUpdated.js.map +1 -0
- package/lib/commonjs/mock-builders/event/notificationMarkRead.js +14 -0
- package/lib/commonjs/mock-builders/event/notificationMarkRead.js.map +1 -0
- package/lib/commonjs/mock-builders/event/notificationMarkUnread.js +17 -0
- package/lib/commonjs/mock-builders/event/notificationMarkUnread.js.map +1 -0
- package/lib/commonjs/mock-builders/generator/channel.js +1 -0
- package/lib/commonjs/mock-builders/generator/channel.js.map +1 -1
- package/lib/commonjs/store/SqliteClient.js +11 -2
- package/lib/commonjs/store/SqliteClient.js.map +1 -1
- package/lib/commonjs/utils/getTrimmedAttachmentTitle.js +8 -2
- package/lib/commonjs/utils/getTrimmedAttachmentTitle.js.map +1 -1
- package/lib/commonjs/utils/utils.js +3 -2
- package/lib/commonjs/utils/utils.js.map +1 -1
- package/lib/commonjs/version.json +1 -1
- package/lib/module/components/AITypingIndicatorView/AITypingIndicatorView.js +53 -0
- package/lib/module/components/AITypingIndicatorView/AITypingIndicatorView.js.map +1 -0
- package/lib/module/components/AITypingIndicatorView/hooks/useAIState.js +59 -0
- package/lib/module/components/AITypingIndicatorView/hooks/useAIState.js.map +1 -0
- package/lib/module/components/AITypingIndicatorView/index.js +26 -0
- package/lib/module/components/AITypingIndicatorView/index.js.map +1 -0
- package/lib/module/components/Attachment/AudioAttachment.js +27 -22
- package/lib/module/components/Attachment/AudioAttachment.js.map +1 -1
- package/lib/module/components/Attachment/Gallery.js +3 -1
- package/lib/module/components/Attachment/Gallery.js.map +1 -1
- package/lib/module/components/AttachmentPicker/AttachmentPicker.js +2 -2
- package/lib/module/components/AttachmentPicker/AttachmentPicker.js.map +1 -1
- package/lib/module/components/AttachmentPicker/components/AttachmentPickerItem.js +37 -133
- package/lib/module/components/AttachmentPicker/components/AttachmentPickerItem.js.map +1 -1
- package/lib/module/components/AttachmentPicker/components/AttachmentPickerSelectionBar.js +6 -4
- package/lib/module/components/AttachmentPicker/components/AttachmentPickerSelectionBar.js.map +1 -1
- package/lib/module/components/Channel/Channel.js +478 -1045
- package/lib/module/components/Channel/Channel.js.map +1 -1
- package/lib/module/components/Channel/hooks/useChannelDataState.js +174 -0
- package/lib/module/components/Channel/hooks/useChannelDataState.js.map +1 -0
- package/lib/module/components/Channel/hooks/useCreateInputMessageInputContext.js +2 -0
- package/lib/module/components/Channel/hooks/useCreateInputMessageInputContext.js.map +1 -1
- package/lib/module/components/Channel/hooks/useCreateMessagesContext.js +4 -0
- package/lib/module/components/Channel/hooks/useCreateMessagesContext.js.map +1 -1
- package/lib/module/components/Channel/hooks/useCreatePaginatedMessageListContext.js +3 -3
- package/lib/module/components/Channel/hooks/useCreatePaginatedMessageListContext.js.map +1 -1
- package/lib/module/components/Channel/hooks/useMessageListPagination.js +324 -0
- package/lib/module/components/Channel/hooks/useMessageListPagination.js.map +1 -0
- package/lib/module/components/ChannelList/Skeleton.js +7 -3
- package/lib/module/components/ChannelList/Skeleton.js.map +1 -1
- package/lib/module/components/ChannelList/hooks/usePaginatedChannels.js +85 -45
- package/lib/module/components/ChannelList/hooks/usePaginatedChannels.js.map +1 -1
- package/lib/module/components/ChannelPreview/ChannelPreview.js +17 -91
- package/lib/module/components/ChannelPreview/ChannelPreview.js.map +1 -1
- package/lib/module/components/ChannelPreview/ChannelPreviewMessenger.js +3 -24
- package/lib/module/components/ChannelPreview/ChannelPreviewMessenger.js.map +1 -1
- package/lib/module/components/ChannelPreview/ChannelPreviewMutedStatus.js +2 -2
- package/lib/module/components/ChannelPreview/ChannelPreviewMutedStatus.js.map +1 -1
- package/lib/module/components/ChannelPreview/hooks/useChannelPreviewData.js +121 -0
- package/lib/module/components/ChannelPreview/hooks/useChannelPreviewData.js.map +1 -0
- package/lib/module/components/ChannelPreview/hooks/useIsChannelMuted.js +35 -0
- package/lib/module/components/ChannelPreview/hooks/useIsChannelMuted.js.map +1 -0
- package/lib/module/components/Chat/Chat.js +5 -1
- package/lib/module/components/Chat/Chat.js.map +1 -1
- package/lib/module/components/Chat/hooks/useAppSettings.js +15 -9
- package/lib/module/components/Chat/hooks/useAppSettings.js.map +1 -1
- package/lib/module/components/Chat/hooks/useCreateChatContext.js +2 -0
- package/lib/module/components/Chat/hooks/useCreateChatContext.js.map +1 -1
- package/lib/module/components/Chat/hooks/useIsOnline.js +0 -4
- package/lib/module/components/Chat/hooks/useIsOnline.js.map +1 -1
- package/lib/module/components/ImageGallery/ImageGallery.js.map +1 -1
- package/lib/module/components/ImageGallery/components/ImageGalleryFooter.js +46 -46
- package/lib/module/components/ImageGallery/components/ImageGalleryFooter.js.map +1 -1
- package/lib/module/components/ImageGallery/components/ImageGalleryHeader.js +3 -4
- package/lib/module/components/ImageGallery/components/ImageGalleryHeader.js.map +1 -1
- package/lib/module/components/ImageGallery/hooks/useAnimatedGalleryStyle.js +2 -2
- package/lib/module/components/ImageGallery/hooks/useAnimatedGalleryStyle.js.map +1 -1
- package/lib/module/components/Message/Message.js +7 -0
- package/lib/module/components/Message/Message.js.map +1 -1
- package/lib/module/components/Message/MessageSimple/MessageContent.js +17 -4
- package/lib/module/components/Message/MessageSimple/MessageContent.js.map +1 -1
- package/lib/module/components/Message/MessageSimple/MessageFooter.js +15 -6
- package/lib/module/components/Message/MessageSimple/MessageFooter.js.map +1 -1
- package/lib/module/components/Message/MessageSimple/StreamingMessageView.js +36 -0
- package/lib/module/components/Message/MessageSimple/StreamingMessageView.js.map +1 -0
- package/lib/module/components/Message/MessageSimple/utils/generateMarkdownText.js +9 -1
- package/lib/module/components/Message/MessageSimple/utils/generateMarkdownText.js.map +1 -1
- package/lib/module/components/Message/MessageSimple/utils/renderText.js +209 -23
- package/lib/module/components/Message/MessageSimple/utils/renderText.js.map +1 -1
- package/lib/module/components/Message/hooks/useCreateMessageContext.js +2 -0
- package/lib/module/components/Message/hooks/useCreateMessageContext.js.map +1 -1
- package/lib/module/components/Message/hooks/useStreamingMessage.js +43 -0
- package/lib/module/components/Message/hooks/useStreamingMessage.js.map +1 -0
- package/lib/module/components/MessageInput/MessageInput.js +41 -21
- package/lib/module/components/MessageInput/MessageInput.js.map +1 -1
- package/lib/module/components/MessageInput/StopMessageStreamingButton.js +39 -0
- package/lib/module/components/MessageInput/StopMessageStreamingButton.js.map +1 -0
- package/lib/module/components/MessageList/MessageList.js +74 -73
- package/lib/module/components/MessageList/MessageList.js.map +1 -1
- package/lib/module/components/MessageList/ScrollToBottomButton.js +1 -1
- package/lib/module/components/MessageList/ScrollToBottomButton.js.map +1 -1
- package/lib/module/components/MessageList/hooks/useMessageList.js.map +1 -1
- package/lib/module/components/MessageList/utils/getReadStates.js.map +1 -1
- package/lib/module/components/MessageMenu/MessageUserReactions.js +1 -1
- package/lib/module/components/MessageMenu/MessageUserReactions.js.map +1 -1
- package/lib/module/components/MessageMenu/MessageUserReactionsItem.js +4 -2
- package/lib/module/components/MessageMenu/MessageUserReactionsItem.js.map +1 -1
- package/lib/module/components/MessageMenu/hooks/useFetchReactions.js +3 -2
- package/lib/module/components/MessageMenu/hooks/useFetchReactions.js.map +1 -1
- package/lib/module/components/Poll/CreatePollContent.js +14 -9
- package/lib/module/components/Poll/CreatePollContent.js.map +1 -1
- package/lib/module/components/Poll/Poll.js +2 -8
- package/lib/module/components/Poll/Poll.js.map +1 -1
- package/lib/module/components/Poll/components/Button.js +9 -474
- package/lib/module/components/Poll/components/Button.js.map +1 -1
- package/lib/module/components/Poll/components/CreatePollIcon.js +2 -2
- package/lib/module/components/Poll/components/CreatePollIcon.js.map +1 -1
- package/lib/module/components/Poll/components/CreatePollOptions.js +9 -4
- package/lib/module/components/Poll/components/CreatePollOptions.js.map +1 -1
- package/lib/module/components/Poll/components/PollAnswersList.js +99 -26
- package/lib/module/components/Poll/components/PollAnswersList.js.map +1 -1
- package/lib/module/components/Poll/components/PollButtons.js +291 -0
- package/lib/module/components/Poll/components/PollButtons.js.map +1 -0
- package/lib/module/components/Poll/components/PollInputDialog.js +14 -4
- package/lib/module/components/Poll/components/PollInputDialog.js.map +1 -1
- package/lib/module/components/Poll/components/PollModalHeader.js +7 -1
- package/lib/module/components/Poll/components/PollModalHeader.js.map +1 -1
- package/lib/module/components/Poll/components/PollOption.js +88 -6
- package/lib/module/components/Poll/components/PollOption.js.map +1 -1
- package/lib/module/components/Poll/components/PollResults/PollOptionFullResults.js +2 -2
- package/lib/module/components/Poll/components/PollResults/PollOptionFullResults.js.map +1 -1
- package/lib/module/components/Poll/components/PollResults/PollResultItem.js +62 -67
- package/lib/module/components/Poll/components/PollResults/PollResultItem.js.map +1 -1
- package/lib/module/components/Poll/components/PollResults/PollVote.js +89 -0
- package/lib/module/components/Poll/components/PollResults/PollVote.js.map +1 -0
- package/lib/module/components/Poll/components/index.js +11 -0
- package/lib/module/components/Poll/components/index.js.map +1 -1
- package/lib/module/components/ThreadList/ThreadList.js +0 -3
- package/lib/module/components/ThreadList/ThreadList.js.map +1 -1
- package/lib/module/components/UIComponents/BottomSheetModal.js +11 -5
- package/lib/module/components/UIComponents/BottomSheetModal.js.map +1 -1
- package/lib/module/components/index.js +66 -0
- package/lib/module/components/index.js.map +1 -1
- package/lib/module/contexts/channelContext/ChannelContext.js.map +1 -1
- package/lib/module/contexts/channelsStateContext/ChannelsStateContext.js +0 -35
- package/lib/module/contexts/channelsStateContext/ChannelsStateContext.js.map +1 -1
- package/lib/module/contexts/channelsStateContext/useChannelState.js +7 -84
- package/lib/module/contexts/channelsStateContext/useChannelState.js.map +1 -1
- package/lib/module/contexts/chatContext/ChatContext.js.map +1 -1
- package/lib/module/contexts/messageContext/MessageContext.js.map +1 -1
- package/lib/module/contexts/messageInputContext/MessageInputContext.js +4 -2
- package/lib/module/contexts/messageInputContext/MessageInputContext.js.map +1 -1
- package/lib/module/contexts/messageInputContext/hooks/useCreateMessageInputContext.js +2 -0
- package/lib/module/contexts/messageInputContext/hooks/useCreateMessageInputContext.js.map +1 -1
- package/lib/module/contexts/messagesContext/MessagesContext.js.map +1 -1
- package/lib/module/contexts/paginatedMessageListContext/PaginatedMessageListContext.js.map +1 -1
- package/lib/module/contexts/themeContext/utils/theme.js +15 -0
- package/lib/module/contexts/themeContext/utils/theme.js.map +1 -1
- package/lib/module/i18n/en.json +2 -0
- package/lib/module/i18n/es.json +2 -0
- package/lib/module/i18n/fr.json +2 -0
- package/lib/module/i18n/he.json +2 -0
- package/lib/module/i18n/hi.json +2 -0
- package/lib/module/i18n/it.json +2 -0
- package/lib/module/i18n/ja.json +2 -0
- package/lib/module/i18n/ko.json +2 -0
- package/lib/module/i18n/nl.json +2 -0
- package/lib/module/i18n/pt-br.json +2 -0
- package/lib/module/i18n/ru.json +2 -0
- package/lib/module/i18n/tr.json +2 -0
- package/lib/module/mock-builders/event/notificationChannelMutesUpdated.js +14 -0
- package/lib/module/mock-builders/event/notificationChannelMutesUpdated.js.map +1 -0
- package/lib/module/mock-builders/event/notificationMarkRead.js +14 -0
- package/lib/module/mock-builders/event/notificationMarkRead.js.map +1 -0
- package/lib/module/mock-builders/event/notificationMarkUnread.js +17 -0
- package/lib/module/mock-builders/event/notificationMarkUnread.js.map +1 -0
- package/lib/module/mock-builders/generator/channel.js +1 -0
- package/lib/module/mock-builders/generator/channel.js.map +1 -1
- package/lib/module/store/SqliteClient.js +11 -2
- package/lib/module/store/SqliteClient.js.map +1 -1
- package/lib/module/utils/getTrimmedAttachmentTitle.js +8 -2
- package/lib/module/utils/getTrimmedAttachmentTitle.js.map +1 -1
- package/lib/module/utils/utils.js +3 -2
- package/lib/module/utils/utils.js.map +1 -1
- package/lib/module/version.json +1 -1
- package/lib/typescript/components/AITypingIndicatorView/AITypingIndicatorView.d.ts +11 -0
- package/lib/typescript/components/AITypingIndicatorView/AITypingIndicatorView.d.ts.map +1 -0
- package/lib/typescript/components/AITypingIndicatorView/hooks/useAIState.d.ts +18 -0
- package/lib/typescript/components/AITypingIndicatorView/hooks/useAIState.d.ts.map +1 -0
- package/lib/typescript/components/AITypingIndicatorView/index.d.ts +3 -0
- package/lib/typescript/components/AITypingIndicatorView/index.d.ts.map +1 -0
- package/lib/typescript/components/Attachment/AudioAttachment.d.ts.map +1 -1
- package/lib/typescript/components/AttachmentPicker/AttachmentPicker.d.ts.map +1 -1
- package/lib/typescript/components/AttachmentPicker/components/AttachmentPickerItem.d.ts.map +1 -1
- package/lib/typescript/components/AttachmentPicker/components/AttachmentPickerSelectionBar.d.ts.map +1 -1
- package/lib/typescript/components/Channel/Channel.d.ts +7 -6
- package/lib/typescript/components/Channel/Channel.d.ts.map +1 -1
- package/lib/typescript/components/Channel/hooks/useChannelDataState.d.ts +75 -0
- package/lib/typescript/components/Channel/hooks/useChannelDataState.d.ts.map +1 -0
- package/lib/typescript/components/Channel/hooks/useCreateInputMessageInputContext.d.ts +1 -1
- package/lib/typescript/components/Channel/hooks/useCreateInputMessageInputContext.d.ts.map +1 -1
- package/lib/typescript/components/Channel/hooks/useCreateMessagesContext.d.ts +128 -1
- package/lib/typescript/components/Channel/hooks/useCreateMessagesContext.d.ts.map +1 -1
- package/lib/typescript/components/Channel/hooks/useCreatePaginatedMessageListContext.d.ts +1 -1
- package/lib/typescript/components/Channel/hooks/useCreatePaginatedMessageListContext.d.ts.map +1 -1
- package/lib/typescript/components/Channel/hooks/useMessageListPagination.d.ts +28 -0
- package/lib/typescript/components/Channel/hooks/useMessageListPagination.d.ts.map +1 -0
- package/lib/typescript/components/ChannelList/Skeleton.d.ts.map +1 -1
- package/lib/typescript/components/ChannelList/hooks/usePaginatedChannels.d.ts.map +1 -1
- package/lib/typescript/components/ChannelPreview/ChannelPreview.d.ts +1 -2
- package/lib/typescript/components/ChannelPreview/ChannelPreview.d.ts.map +1 -1
- package/lib/typescript/components/ChannelPreview/ChannelPreviewMessenger.d.ts +2 -0
- package/lib/typescript/components/ChannelPreview/ChannelPreviewMessenger.d.ts.map +1 -1
- package/lib/typescript/components/ChannelPreview/ChannelPreviewMutedStatus.d.ts.map +1 -1
- package/lib/typescript/components/ChannelPreview/hooks/useChannelPreviewData.d.ts +8 -0
- package/lib/typescript/components/ChannelPreview/hooks/useChannelPreviewData.d.ts.map +1 -0
- package/lib/typescript/components/ChannelPreview/hooks/useIsChannelMuted.d.ts +8 -0
- package/lib/typescript/components/ChannelPreview/hooks/useIsChannelMuted.d.ts.map +1 -0
- package/lib/typescript/components/Chat/Chat.d.ts +7 -1
- package/lib/typescript/components/Chat/Chat.d.ts.map +1 -1
- package/lib/typescript/components/Chat/hooks/useAppSettings.d.ts.map +1 -1
- package/lib/typescript/components/Chat/hooks/useCreateChatContext.d.ts +1 -1
- package/lib/typescript/components/Chat/hooks/useCreateChatContext.d.ts.map +1 -1
- package/lib/typescript/components/Chat/hooks/useIsOnline.d.ts.map +1 -1
- package/lib/typescript/components/ImageGallery/ImageGallery.d.ts.map +1 -1
- package/lib/typescript/components/Message/Message.d.ts +1 -1
- package/lib/typescript/components/Message/Message.d.ts.map +1 -1
- package/lib/typescript/components/Message/MessageSimple/MessageContent.d.ts +1 -1
- package/lib/typescript/components/Message/MessageSimple/MessageContent.d.ts.map +1 -1
- package/lib/typescript/components/Message/MessageSimple/MessageFooter.d.ts.map +1 -1
- package/lib/typescript/components/Message/MessageSimple/StreamingMessageView.d.ts +12 -0
- package/lib/typescript/components/Message/MessageSimple/StreamingMessageView.d.ts.map +1 -0
- package/lib/typescript/components/Message/MessageSimple/utils/generateMarkdownText.d.ts.map +1 -1
- package/lib/typescript/components/Message/MessageSimple/utils/renderText.d.ts +16 -1
- package/lib/typescript/components/Message/MessageSimple/utils/renderText.d.ts.map +1 -1
- package/lib/typescript/components/Message/hooks/useCreateMessageContext.d.ts +1 -1
- package/lib/typescript/components/Message/hooks/useCreateMessageContext.d.ts.map +1 -1
- package/lib/typescript/components/Message/hooks/useStreamingMessage.d.ts +17 -0
- package/lib/typescript/components/Message/hooks/useStreamingMessage.d.ts.map +1 -0
- package/lib/typescript/components/MessageInput/MessageInput.d.ts +1 -1
- package/lib/typescript/components/MessageInput/MessageInput.d.ts.map +1 -1
- package/lib/typescript/components/MessageInput/StopMessageStreamingButton.d.ts +10 -0
- package/lib/typescript/components/MessageInput/StopMessageStreamingButton.d.ts.map +1 -0
- package/lib/typescript/components/MessageList/MessageList.d.ts +1 -1
- package/lib/typescript/components/MessageList/MessageList.d.ts.map +1 -1
- package/lib/typescript/components/MessageList/hooks/useMessageList.d.ts.map +1 -1
- package/lib/typescript/components/MessageList/utils/getReadStates.d.ts +1 -1
- package/lib/typescript/components/MessageList/utils/getReadStates.d.ts.map +1 -1
- package/lib/typescript/components/MessageMenu/MessageUserReactionsItem.d.ts.map +1 -1
- package/lib/typescript/components/MessageMenu/hooks/useFetchReactions.d.ts +3 -2
- package/lib/typescript/components/MessageMenu/hooks/useFetchReactions.d.ts.map +1 -1
- package/lib/typescript/components/Poll/Poll.d.ts +0 -1
- package/lib/typescript/components/Poll/Poll.d.ts.map +1 -1
- package/lib/typescript/components/Poll/components/Button.d.ts +0 -17
- package/lib/typescript/components/Poll/components/Button.d.ts.map +1 -1
- package/lib/typescript/components/Poll/components/CreatePollOptions.d.ts.map +1 -1
- package/lib/typescript/components/Poll/components/PollAnswersList.d.ts +2 -0
- package/lib/typescript/components/Poll/components/PollAnswersList.d.ts.map +1 -1
- package/lib/typescript/components/Poll/components/PollButtons.d.ts +10 -0
- package/lib/typescript/components/Poll/components/PollButtons.d.ts.map +1 -0
- package/lib/typescript/components/Poll/components/PollInputDialog.d.ts.map +1 -1
- package/lib/typescript/components/Poll/components/PollOption.d.ts +2 -0
- package/lib/typescript/components/Poll/components/PollOption.d.ts.map +1 -1
- package/lib/typescript/components/Poll/components/PollResults/PollResultItem.d.ts +11 -4
- package/lib/typescript/components/Poll/components/PollResults/PollResultItem.d.ts.map +1 -1
- package/lib/typescript/components/Poll/components/PollResults/PollVote.d.ts +6 -0
- package/lib/typescript/components/Poll/components/PollResults/PollVote.d.ts.map +1 -0
- package/lib/typescript/components/Poll/components/index.d.ts +1 -0
- package/lib/typescript/components/Poll/components/index.d.ts.map +1 -1
- package/lib/typescript/components/ThreadList/ThreadList.d.ts.map +1 -1
- package/lib/typescript/components/UIComponents/BottomSheetModal.d.ts.map +1 -1
- package/lib/typescript/components/index.d.ts +6 -0
- package/lib/typescript/components/index.d.ts.map +1 -1
- package/lib/typescript/contexts/channelContext/ChannelContext.d.ts +27 -25
- package/lib/typescript/contexts/channelContext/ChannelContext.d.ts.map +1 -1
- package/lib/typescript/contexts/channelsStateContext/ChannelsStateContext.d.ts +0 -16
- package/lib/typescript/contexts/channelsStateContext/ChannelsStateContext.d.ts.map +1 -1
- package/lib/typescript/contexts/channelsStateContext/useChannelState.d.ts +7 -13
- package/lib/typescript/contexts/channelsStateContext/useChannelState.d.ts.map +1 -1
- package/lib/typescript/contexts/chatContext/ChatContext.d.ts +2 -1
- package/lib/typescript/contexts/chatContext/ChatContext.d.ts.map +1 -1
- package/lib/typescript/contexts/messageContext/MessageContext.d.ts +4 -0
- package/lib/typescript/contexts/messageContext/MessageContext.d.ts.map +1 -1
- package/lib/typescript/contexts/messageInputContext/MessageInputContext.d.ts +2 -1
- package/lib/typescript/contexts/messageInputContext/MessageInputContext.d.ts.map +1 -1
- package/lib/typescript/contexts/messageInputContext/hooks/useCreateMessageInputContext.d.ts +1 -1
- package/lib/typescript/contexts/messageInputContext/hooks/useCreateMessageInputContext.d.ts.map +1 -1
- package/lib/typescript/contexts/messagesContext/MessagesContext.d.ts +8 -4
- package/lib/typescript/contexts/messagesContext/MessagesContext.d.ts.map +1 -1
- package/lib/typescript/contexts/paginatedMessageListContext/PaginatedMessageListContext.d.ts +17 -16
- package/lib/typescript/contexts/paginatedMessageListContext/PaginatedMessageListContext.d.ts.map +1 -1
- package/lib/typescript/contexts/themeContext/utils/theme.d.ts +16 -1
- package/lib/typescript/contexts/themeContext/utils/theme.d.ts.map +1 -1
- package/lib/typescript/i18n/en.json +2 -0
- package/lib/typescript/i18n/es.json +2 -0
- package/lib/typescript/i18n/fr.json +2 -0
- package/lib/typescript/i18n/he.json +2 -0
- package/lib/typescript/i18n/hi.json +2 -0
- package/lib/typescript/i18n/it.json +2 -0
- package/lib/typescript/i18n/ja.json +2 -0
- package/lib/typescript/i18n/ko.json +2 -0
- package/lib/typescript/i18n/nl.json +2 -0
- package/lib/typescript/i18n/pt-br.json +2 -0
- package/lib/typescript/i18n/ru.json +2 -0
- package/lib/typescript/i18n/tr.json +2 -0
- package/lib/typescript/store/SqliteClient.d.ts.map +1 -1
- package/lib/typescript/types/types.d.ts +3 -0
- package/lib/typescript/types/types.d.ts.map +1 -1
- package/lib/typescript/utils/getTrimmedAttachmentTitle.d.ts.map +1 -1
- package/lib/typescript/utils/i18n/Streami18n.d.ts +2 -0
- package/lib/typescript/utils/i18n/Streami18n.d.ts.map +1 -1
- package/lib/typescript/utils/utils.d.ts.map +1 -1
- package/package.json +5 -5
- package/src/components/AITypingIndicatorView/AITypingIndicatorView.tsx +50 -0
- package/src/components/AITypingIndicatorView/hooks/useAIState.ts +68 -0
- package/src/components/AITypingIndicatorView/index.ts +2 -0
- package/src/components/Attachment/AudioAttachment.tsx +20 -19
- package/src/components/Attachment/Gallery.tsx +1 -1
- package/src/components/AttachmentPicker/AttachmentPicker.tsx +7 -2
- package/src/components/AttachmentPicker/components/AttachmentPickerItem.tsx +16 -32
- package/src/components/AttachmentPicker/components/AttachmentPickerSelectionBar.tsx +3 -5
- package/src/components/Channel/Channel.tsx +262 -821
- package/src/components/Channel/__tests__/Channel.test.js +244 -13
- package/src/components/Channel/__tests__/useMessageListPagination.test.js +419 -0
- package/src/components/Channel/hooks/useChannelDataState.ts +235 -0
- package/src/components/Channel/hooks/useCreateInputMessageInputContext.ts +2 -0
- package/src/components/Channel/hooks/useCreateMessagesContext.ts +4 -0
- package/src/components/Channel/hooks/useCreatePaginatedMessageListContext.ts +3 -10
- package/src/components/Channel/hooks/useMessageListPagination.tsx +246 -0
- package/src/components/ChannelList/Skeleton.tsx +9 -1
- package/src/components/ChannelList/hooks/usePaginatedChannels.ts +37 -30
- package/src/components/ChannelPreview/ChannelPreview.tsx +28 -107
- package/src/components/ChannelPreview/ChannelPreviewMessenger.tsx +5 -15
- package/src/components/ChannelPreview/ChannelPreviewMutedStatus.tsx +2 -7
- package/src/components/ChannelPreview/__tests__/ChannelPreview.test.tsx +226 -10
- package/src/components/ChannelPreview/hooks/__tests__/useChannelPreviewDisplayName.test.tsx +1 -1
- package/src/components/ChannelPreview/hooks/__tests__/useChannelPreviewMuted.test.tsx +62 -0
- package/src/components/ChannelPreview/hooks/useChannelPreviewData.ts +138 -0
- package/src/components/ChannelPreview/hooks/useIsChannelMuted.ts +29 -0
- package/src/components/Chat/Chat.tsx +11 -2
- package/src/components/Chat/hooks/__tests__/useAppSettings.test.tsx +1 -0
- package/src/components/Chat/hooks/useAppSettings.ts +2 -0
- package/src/components/Chat/hooks/useCreateChatContext.ts +2 -0
- package/src/components/Chat/hooks/useIsOnline.ts +0 -5
- package/src/components/ImageGallery/ImageGallery.tsx +1 -0
- package/src/components/ImageGallery/components/ImageGalleryFooter.tsx +32 -32
- package/src/components/ImageGallery/components/ImageGalleryHeader.tsx +5 -6
- package/src/components/ImageGallery/hooks/useAnimatedGalleryStyle.tsx +2 -2
- package/src/components/Message/Message.tsx +16 -2
- package/src/components/Message/MessageSimple/MessageContent.tsx +22 -2
- package/src/components/Message/MessageSimple/MessageFooter.tsx +16 -5
- package/src/components/Message/MessageSimple/StreamingMessageView.tsx +34 -0
- package/src/components/Message/MessageSimple/utils/generateMarkdownText.ts +15 -1
- package/src/components/Message/MessageSimple/utils/renderText.tsx +207 -3
- package/src/components/Message/hooks/useCreateMessageContext.ts +2 -0
- package/src/components/Message/hooks/useStreamingMessage.ts +54 -0
- package/src/components/MessageInput/MessageInput.tsx +38 -20
- package/src/components/MessageInput/StopMessageStreamingButton.tsx +34 -0
- package/src/components/MessageInput/__tests__/MessageInput.test.js +116 -2
- package/src/components/MessageList/MessageList.tsx +53 -85
- package/src/components/MessageList/ScrollToBottomButton.tsx +1 -1
- package/src/components/MessageList/__tests__/MessageList.test.js +174 -2
- package/src/components/MessageList/__tests__/ScrollToBottomButton.test.js +3 -3
- package/src/components/MessageList/__tests__/__snapshots__/ScrollToBottomButton.test.js.snap +1 -1
- package/src/components/MessageList/hooks/useMessageList.ts +2 -5
- package/src/components/MessageList/utils/getReadStates.ts +3 -2
- package/src/components/MessageMenu/MessageUserReactions.tsx +1 -1
- package/src/components/MessageMenu/MessageUserReactionsItem.tsx +4 -2
- package/src/components/MessageMenu/hooks/useFetchReactions.ts +6 -3
- package/src/components/Poll/CreatePollContent.tsx +4 -4
- package/src/components/Poll/Poll.tsx +1 -20
- package/src/components/Poll/components/Button.tsx +8 -420
- package/src/components/Poll/components/CreatePollIcon.tsx +1 -1
- package/src/components/Poll/components/CreatePollOptions.tsx +9 -4
- package/src/components/Poll/components/PollAnswersList.tsx +66 -3
- package/src/components/Poll/components/PollButtons.tsx +241 -0
- package/src/components/Poll/components/PollInputDialog.tsx +9 -6
- package/src/components/Poll/components/PollModalHeader.tsx +3 -3
- package/src/components/Poll/components/PollOption.tsx +74 -4
- package/src/components/Poll/components/PollResults/PollOptionFullResults.tsx +1 -1
- package/src/components/Poll/components/PollResults/PollResultItem.tsx +68 -52
- package/src/components/Poll/components/PollResults/PollVote.tsx +68 -0
- package/src/components/Poll/components/index.ts +1 -0
- package/src/components/Thread/__tests__/__snapshots__/Thread.test.js.snap +37 -4
- package/src/components/ThreadList/ThreadList.tsx +0 -2
- package/src/components/UIComponents/BottomSheetModal.tsx +7 -3
- package/src/components/index.ts +7 -0
- package/src/contexts/channelContext/ChannelContext.tsx +35 -25
- package/src/contexts/channelsStateContext/ChannelsStateContext.tsx +1 -67
- package/src/contexts/channelsStateContext/useChannelState.ts +6 -108
- package/src/contexts/chatContext/ChatContext.tsx +2 -1
- package/src/contexts/messageContext/MessageContext.tsx +4 -0
- package/src/contexts/messageInputContext/MessageInputContext.tsx +5 -1
- package/src/contexts/messageInputContext/hooks/useCreateMessageInputContext.ts +2 -0
- package/src/contexts/messagesContext/MessagesContext.tsx +8 -3
- package/src/contexts/paginatedMessageListContext/PaginatedMessageListContext.tsx +17 -16
- package/src/contexts/themeContext/utils/theme.ts +30 -1
- package/src/i18n/en.json +2 -0
- package/src/i18n/es.json +2 -0
- package/src/i18n/fr.json +2 -0
- package/src/i18n/he.json +2 -0
- package/src/i18n/hi.json +2 -0
- package/src/i18n/it.json +2 -0
- package/src/i18n/ja.json +2 -0
- package/src/i18n/ko.json +2 -0
- package/src/i18n/nl.json +2 -0
- package/src/i18n/pt-br.json +2 -0
- package/src/i18n/ru.json +2 -0
- package/src/i18n/tr.json +2 -0
- package/src/mock-builders/event/notificationChannelMutesUpdated.js +7 -0
- package/src/mock-builders/event/notificationMarkRead.js +7 -0
- package/src/mock-builders/event/notificationMarkUnread.js +9 -0
- package/src/mock-builders/generator/channel.ts +1 -0
- package/src/store/SqliteClient.ts +5 -1
- package/src/types/types.ts +3 -0
- package/src/utils/getTrimmedAttachmentTitle.ts +10 -2
- package/src/utils/utils.ts +5 -2
- package/src/version.json +1 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import React
|
|
1
|
+
import React from 'react';
|
|
2
2
|
|
|
3
|
-
import type { Channel
|
|
3
|
+
import type { Channel } from 'stream-chat';
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { useChannelPreviewData } from './hooks/useChannelPreviewData';
|
|
6
6
|
|
|
7
7
|
import {
|
|
8
8
|
ChannelsContextValue,
|
|
@@ -12,120 +12,41 @@ import { ChatContextValue, useChatContext } from '../../contexts/chatContext/Cha
|
|
|
12
12
|
|
|
13
13
|
import type { DefaultStreamChatGenerics } from '../../types/types';
|
|
14
14
|
|
|
15
|
-
export type
|
|
15
|
+
export type ChannelPreviewProps<
|
|
16
16
|
StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
|
|
17
|
-
> = Pick<ChatContextValue<StreamChatGenerics>, 'client'
|
|
18
|
-
Pick<ChannelsContextValue<StreamChatGenerics>, 'Preview' | 'forceUpdate'
|
|
17
|
+
> = Partial<Pick<ChatContextValue<StreamChatGenerics>, 'client'>> &
|
|
18
|
+
Partial<Pick<ChannelsContextValue<StreamChatGenerics>, 'Preview' | 'forceUpdate'>> & {
|
|
19
19
|
/**
|
|
20
20
|
* Instance of Channel from stream-chat package.
|
|
21
21
|
*/
|
|
22
22
|
channel: Channel<StreamChatGenerics>;
|
|
23
23
|
};
|
|
24
24
|
|
|
25
|
-
/**
|
|
26
|
-
* This component manages state for the ChannelPreviewMessenger UI component and receives
|
|
27
|
-
* all props from the ChannelListMessenger component.
|
|
28
|
-
*/
|
|
29
|
-
const ChannelPreviewWithContext = <
|
|
30
|
-
StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
|
|
31
|
-
>(
|
|
32
|
-
props: ChannelPreviewPropsWithContext<StreamChatGenerics>,
|
|
33
|
-
) => {
|
|
34
|
-
const { channel, client, forceUpdate: channelListForceUpdate, Preview } = props;
|
|
35
|
-
|
|
36
|
-
const [lastMessage, setLastMessage] = useState<
|
|
37
|
-
| ReturnType<ChannelState<StreamChatGenerics>['formatMessage']>
|
|
38
|
-
| MessageResponse<StreamChatGenerics>
|
|
39
|
-
| undefined
|
|
40
|
-
>(channel.state.messages[channel.state.messages.length - 1]);
|
|
41
|
-
|
|
42
|
-
const [forceUpdate, setForceUpdate] = useState(0);
|
|
43
|
-
const [unread, setUnread] = useState(channel.countUnread());
|
|
44
|
-
|
|
45
|
-
const latestMessagePreview = useLatestMessagePreview(channel, forceUpdate, lastMessage);
|
|
46
|
-
|
|
47
|
-
const channelLastMessage = channel.lastMessage();
|
|
48
|
-
const channelLastMessageString = `${channelLastMessage?.id}${channelLastMessage?.updated_at}`;
|
|
49
|
-
|
|
50
|
-
useEffect(() => {
|
|
51
|
-
const { unsubscribe } = client.on('notification.mark_read', () => {
|
|
52
|
-
setUnread(channel.countUnread());
|
|
53
|
-
});
|
|
54
|
-
return unsubscribe;
|
|
55
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
56
|
-
}, []);
|
|
57
|
-
|
|
58
|
-
useEffect(() => {
|
|
59
|
-
if (
|
|
60
|
-
channelLastMessage &&
|
|
61
|
-
(channelLastMessage.id !== lastMessage?.id ||
|
|
62
|
-
channelLastMessage.updated_at !== lastMessage?.updated_at)
|
|
63
|
-
) {
|
|
64
|
-
setLastMessage(channelLastMessage);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
const newUnreadCount = channel.countUnread();
|
|
68
|
-
setUnread(newUnreadCount);
|
|
69
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
70
|
-
}, [channelLastMessageString, channelListForceUpdate]);
|
|
71
|
-
|
|
72
|
-
useEffect(() => {
|
|
73
|
-
const handleNewMessageEvent = (event: Event<StreamChatGenerics>) => {
|
|
74
|
-
const message = event.message;
|
|
75
|
-
if (message && (!message.parent_id || message.show_in_channel)) {
|
|
76
|
-
setLastMessage(event.message);
|
|
77
|
-
setUnread(channel.countUnread());
|
|
78
|
-
}
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
const handleUpdatedOrDeletedMessage = (event: Event<StreamChatGenerics>) => {
|
|
82
|
-
setLastMessage((prevLastMessage) => {
|
|
83
|
-
if (prevLastMessage?.id === event.message?.id) {
|
|
84
|
-
return event.message;
|
|
85
|
-
}
|
|
86
|
-
return prevLastMessage;
|
|
87
|
-
});
|
|
88
|
-
};
|
|
89
|
-
|
|
90
|
-
const listeners = [
|
|
91
|
-
channel.on('message.new', handleNewMessageEvent),
|
|
92
|
-
channel.on('message.updated', handleUpdatedOrDeletedMessage),
|
|
93
|
-
channel.on('message.deleted', handleUpdatedOrDeletedMessage),
|
|
94
|
-
];
|
|
95
|
-
|
|
96
|
-
return () => listeners.forEach((l) => l.unsubscribe());
|
|
97
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
98
|
-
}, []);
|
|
99
|
-
|
|
100
|
-
useEffect(() => {
|
|
101
|
-
const handleReadEvent = (event: Event<StreamChatGenerics>) => {
|
|
102
|
-
if (event.user?.id === client.userID) {
|
|
103
|
-
setUnread(0);
|
|
104
|
-
} else if (event.user?.id) {
|
|
105
|
-
setForceUpdate((prev) => prev + 1);
|
|
106
|
-
}
|
|
107
|
-
};
|
|
108
|
-
|
|
109
|
-
const listener = channel.on('message.read', handleReadEvent);
|
|
110
|
-
return () => listener.unsubscribe();
|
|
111
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
112
|
-
}, []);
|
|
113
|
-
|
|
114
|
-
return <Preview channel={channel} latestMessagePreview={latestMessagePreview} unread={unread} />;
|
|
115
|
-
};
|
|
116
|
-
|
|
117
|
-
export type ChannelPreviewProps<
|
|
118
|
-
StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
|
|
119
|
-
> = Partial<Omit<ChannelPreviewPropsWithContext<StreamChatGenerics>, 'channel'>> &
|
|
120
|
-
Pick<ChannelPreviewPropsWithContext<StreamChatGenerics>, 'channel'>;
|
|
121
|
-
|
|
122
25
|
export const ChannelPreview = <
|
|
123
26
|
StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
|
|
124
27
|
>(
|
|
125
28
|
props: ChannelPreviewProps<StreamChatGenerics>,
|
|
126
29
|
) => {
|
|
127
|
-
const { client } =
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
30
|
+
const { channel, client: propClient, forceUpdate: propForceUpdate, Preview: propPreview } = props;
|
|
31
|
+
|
|
32
|
+
const { client: contextClient } = useChatContext<StreamChatGenerics>();
|
|
33
|
+
const { Preview: contextPreview } = useChannelsContext<StreamChatGenerics>();
|
|
34
|
+
|
|
35
|
+
const client = propClient || contextClient;
|
|
36
|
+
const Preview = propPreview || contextPreview;
|
|
37
|
+
|
|
38
|
+
const { latestMessagePreview, muted, unread } = useChannelPreviewData(
|
|
39
|
+
channel,
|
|
40
|
+
client,
|
|
41
|
+
propForceUpdate,
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
return (
|
|
45
|
+
<Preview
|
|
46
|
+
channel={channel}
|
|
47
|
+
latestMessagePreview={latestMessagePreview}
|
|
48
|
+
muted={muted}
|
|
49
|
+
unread={unread}
|
|
50
|
+
/>
|
|
51
|
+
);
|
|
131
52
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React
|
|
1
|
+
import React from 'react';
|
|
2
2
|
import { StyleSheet, View } from 'react-native';
|
|
3
3
|
import { TouchableOpacity } from 'react-native-gesture-handler';
|
|
4
4
|
|
|
@@ -17,7 +17,6 @@ import {
|
|
|
17
17
|
ChannelsContextValue,
|
|
18
18
|
useChannelsContext,
|
|
19
19
|
} from '../../contexts/channelsContext/ChannelsContext';
|
|
20
|
-
import { useChatContext } from '../../contexts/chatContext/ChatContext';
|
|
21
20
|
import { useTheme } from '../../contexts/themeContext/ThemeContext';
|
|
22
21
|
import { useViewport } from '../../hooks/useViewport';
|
|
23
22
|
import type { DefaultStreamChatGenerics } from '../../types/types';
|
|
@@ -95,6 +94,8 @@ export type ChannelPreviewMessengerPropsWithContext<
|
|
|
95
94
|
* default formatted date. This default logic is part of ChannelPreview component.
|
|
96
95
|
*/
|
|
97
96
|
formatLatestMessageDate?: (date: Date) => string;
|
|
97
|
+
/** If the channel is muted. */
|
|
98
|
+
muted?: boolean;
|
|
98
99
|
/** Number of unread messages on the channel */
|
|
99
100
|
unread?: number;
|
|
100
101
|
};
|
|
@@ -109,6 +110,7 @@ const ChannelPreviewMessengerWithContext = <
|
|
|
109
110
|
formatLatestMessageDate,
|
|
110
111
|
latestMessagePreview,
|
|
111
112
|
maxUnreadCount,
|
|
113
|
+
muted,
|
|
112
114
|
onSelect,
|
|
113
115
|
PreviewAvatar = ChannelAvatar,
|
|
114
116
|
PreviewMessage = ChannelPreviewMessage,
|
|
@@ -129,23 +131,11 @@ const ChannelPreviewMessengerWithContext = <
|
|
|
129
131
|
},
|
|
130
132
|
} = useTheme();
|
|
131
133
|
|
|
132
|
-
const { client } = useChatContext<StreamChatGenerics>();
|
|
133
|
-
|
|
134
134
|
const displayName = useChannelPreviewDisplayName(
|
|
135
135
|
channel,
|
|
136
136
|
Math.floor(maxWidth / ((title.fontSize || styles.title.fontSize) / 2)),
|
|
137
137
|
);
|
|
138
138
|
|
|
139
|
-
const [isChannelMuted, setIsChannelMuted] = useState(() => channel.muteStatus().muted);
|
|
140
|
-
|
|
141
|
-
useEffect(() => {
|
|
142
|
-
const handleEvent = () => setIsChannelMuted(channel.muteStatus().muted);
|
|
143
|
-
|
|
144
|
-
client.on('notification.channel_mutes_updated', handleEvent);
|
|
145
|
-
return () => client.off('notification.channel_mutes_updated', handleEvent);
|
|
146
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
147
|
-
}, [client]);
|
|
148
|
-
|
|
149
139
|
return (
|
|
150
140
|
<TouchableOpacity
|
|
151
141
|
onPress={() => {
|
|
@@ -168,7 +158,7 @@ const ChannelPreviewMessengerWithContext = <
|
|
|
168
158
|
<View style={[styles.row, row]}>
|
|
169
159
|
<PreviewTitle channel={channel} displayName={displayName} />
|
|
170
160
|
<View style={[styles.statusContainer, row]}>
|
|
171
|
-
{
|
|
161
|
+
{muted && <PreviewMutedStatus />}
|
|
172
162
|
<PreviewUnreadCount channel={channel} maxUnreadCount={maxUnreadCount} unread={unread} />
|
|
173
163
|
</View>
|
|
174
164
|
</View>
|
|
@@ -20,16 +20,11 @@ export const ChannelPreviewMutedStatus = () => {
|
|
|
20
20
|
channelPreview: {
|
|
21
21
|
mutedStatus: { height, iconStyle, width },
|
|
22
22
|
},
|
|
23
|
-
colors: {
|
|
23
|
+
colors: { grey },
|
|
24
24
|
},
|
|
25
25
|
} = useTheme();
|
|
26
26
|
|
|
27
27
|
return (
|
|
28
|
-
<Mute
|
|
29
|
-
height={height}
|
|
30
|
-
pathFill={grey_dark}
|
|
31
|
-
style={[styles.iconStyle, iconStyle]}
|
|
32
|
-
width={width}
|
|
33
|
-
/>
|
|
28
|
+
<Mute height={height} pathFill={grey} style={[styles.iconStyle, iconStyle]} width={width} />
|
|
34
29
|
);
|
|
35
30
|
};
|
|
@@ -11,8 +11,9 @@ import {
|
|
|
11
11
|
} from '../../../mock-builders/api/getOrCreateChannel';
|
|
12
12
|
import { useMockedApis } from '../../../mock-builders/api/useMockedApis';
|
|
13
13
|
import dispatchMessageNewEvent from '../../../mock-builders/event/messageNew';
|
|
14
|
-
import
|
|
15
|
-
import
|
|
14
|
+
import dispatchNotificationMarkRead from '../../../mock-builders/event/notificationMarkRead';
|
|
15
|
+
import dispatchNotificationMarkUnread from '../../../mock-builders/event/notificationMarkUnread';
|
|
16
|
+
import { generateChannel, generateChannelResponse } from '../../../mock-builders/generator/channel';
|
|
16
17
|
import { generateMessage } from '../../../mock-builders/generator/message';
|
|
17
18
|
import { generateUser } from '../../../mock-builders/generator/user';
|
|
18
19
|
import { getTestClientWithUser } from '../../../mock-builders/mock';
|
|
@@ -68,6 +69,15 @@ describe('ChannelPreview', () => {
|
|
|
68
69
|
);
|
|
69
70
|
};
|
|
70
71
|
|
|
72
|
+
const generateChannelWrapper = (overrides: Record<string, unknown>) =>
|
|
73
|
+
generateChannel({
|
|
74
|
+
countUnread: jest.fn().mockReturnValue(0),
|
|
75
|
+
initialized: true,
|
|
76
|
+
lastMessage: jest.fn().mockReturnValue(generateMessage()),
|
|
77
|
+
muteStatus: jest.fn().mockReturnValue({ muted: false }),
|
|
78
|
+
...overrides,
|
|
79
|
+
});
|
|
80
|
+
|
|
71
81
|
const useInitializeChannel = async (c: GetOrCreateChannelApiParams) => {
|
|
72
82
|
useMockedApis(chatClient, [getOrCreateChannelApi(c)]);
|
|
73
83
|
|
|
@@ -84,22 +94,228 @@ describe('ChannelPreview', () => {
|
|
|
84
94
|
channel = null;
|
|
85
95
|
});
|
|
86
96
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
97
|
+
describe('notification.mark_read event', () => {
|
|
98
|
+
it("should not update the unread count if the event's cid does not match the channel's cid", async () => {
|
|
99
|
+
const channelOnMock = jest.fn().mockReturnValue({ unsubscribe: jest.fn() });
|
|
90
100
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
101
|
+
const c = generateChannelWrapper({
|
|
102
|
+
countUnread: jest.fn().mockReturnValue(10),
|
|
103
|
+
on: channelOnMock,
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
channel = c as unknown as Channel;
|
|
107
|
+
|
|
108
|
+
const { getByTestId } = render(<TestComponent />);
|
|
109
|
+
|
|
110
|
+
await waitFor(() => getByTestId('channel-id'));
|
|
111
|
+
|
|
112
|
+
await waitFor(() => {
|
|
113
|
+
expect(getByTestId('unread-count')).toHaveTextContent('10');
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
act(() => {
|
|
117
|
+
dispatchNotificationMarkRead(chatClient, { cid: 'channel-id' });
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
await waitFor(() => {
|
|
121
|
+
expect(getByTestId('unread-count')).toHaveTextContent('10');
|
|
122
|
+
});
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
it('should update the unread count to 0', async () => {
|
|
126
|
+
const channelOnMock = jest.fn().mockReturnValue({ unsubscribe: jest.fn() });
|
|
127
|
+
|
|
128
|
+
const c = generateChannelWrapper({
|
|
129
|
+
countUnread: jest.fn().mockReturnValue(10),
|
|
130
|
+
on: channelOnMock,
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
channel = c as unknown as Channel;
|
|
134
|
+
|
|
135
|
+
const { getByTestId } = render(<TestComponent />);
|
|
136
|
+
|
|
137
|
+
await waitFor(() => getByTestId('channel-id'));
|
|
138
|
+
|
|
139
|
+
await waitFor(() => {
|
|
140
|
+
expect(getByTestId('unread-count')).toHaveTextContent('10');
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
act(() => {
|
|
144
|
+
dispatchNotificationMarkRead(chatClient, channel || {});
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
await waitFor(() => {
|
|
148
|
+
expect(getByTestId('unread-count')).toHaveTextContent('0');
|
|
149
|
+
});
|
|
150
|
+
});
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
describe('notification.mark_unread event', () => {
|
|
154
|
+
it("should not update the unread count if the event's cid is undefined", async () => {
|
|
155
|
+
const channelOnMock = jest.fn().mockReturnValue({ unsubscribe: jest.fn() });
|
|
156
|
+
|
|
157
|
+
const c = generateChannelWrapper({
|
|
158
|
+
on: channelOnMock,
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
channel = c as unknown as Channel;
|
|
162
|
+
|
|
163
|
+
const { getByTestId } = render(<TestComponent />);
|
|
164
|
+
|
|
165
|
+
await waitFor(() => getByTestId('channel-id'));
|
|
166
|
+
|
|
167
|
+
await waitFor(() => {
|
|
168
|
+
expect(getByTestId('unread-count')).toHaveTextContent('0');
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
act(() => {
|
|
172
|
+
dispatchNotificationMarkUnread(
|
|
173
|
+
chatClient,
|
|
174
|
+
{},
|
|
175
|
+
{
|
|
176
|
+
unread_channels: 2,
|
|
177
|
+
unread_messages: 5,
|
|
178
|
+
},
|
|
179
|
+
);
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
await waitFor(() => {
|
|
183
|
+
expect(getByTestId('unread-count')).toHaveTextContent('0');
|
|
184
|
+
});
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
it("should not update the unread count if the event's cid does not match the channel's cid", async () => {
|
|
188
|
+
const channelOnMock = jest.fn().mockReturnValue({ unsubscribe: jest.fn() });
|
|
189
|
+
|
|
190
|
+
const c = generateChannelWrapper({
|
|
191
|
+
on: channelOnMock,
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
channel = c as unknown as Channel;
|
|
195
|
+
|
|
196
|
+
const { getByTestId } = render(<TestComponent />);
|
|
197
|
+
|
|
198
|
+
await waitFor(() => getByTestId('channel-id'));
|
|
199
|
+
|
|
200
|
+
await waitFor(() => {
|
|
201
|
+
expect(getByTestId('unread-count')).toHaveTextContent('0');
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
act(() => {
|
|
205
|
+
dispatchNotificationMarkUnread(
|
|
206
|
+
chatClient,
|
|
207
|
+
{ cid: 'channel-id' },
|
|
208
|
+
{
|
|
209
|
+
unread_channels: 2,
|
|
210
|
+
unread_messages: 5,
|
|
211
|
+
},
|
|
212
|
+
);
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
await waitFor(() => {
|
|
216
|
+
expect(getByTestId('unread-count')).toHaveTextContent('0');
|
|
217
|
+
});
|
|
218
|
+
});
|
|
219
|
+
|
|
220
|
+
it("should not update the unread count if the event's user id does not match the client's user id", async () => {
|
|
221
|
+
const channelOnMock = jest.fn().mockReturnValue({ unsubscribe: jest.fn() });
|
|
222
|
+
|
|
223
|
+
const c = generateChannelWrapper({
|
|
224
|
+
on: channelOnMock,
|
|
225
|
+
});
|
|
226
|
+
|
|
227
|
+
channel = c as unknown as Channel;
|
|
228
|
+
|
|
229
|
+
const { getByTestId } = render(<TestComponent />);
|
|
230
|
+
|
|
231
|
+
await waitFor(() => getByTestId('channel-id'));
|
|
232
|
+
|
|
233
|
+
await waitFor(() => {
|
|
234
|
+
expect(getByTestId('unread-count')).toHaveTextContent('0');
|
|
235
|
+
});
|
|
236
|
+
|
|
237
|
+
act(() => {
|
|
238
|
+
dispatchNotificationMarkUnread(
|
|
239
|
+
chatClient,
|
|
240
|
+
{ cid: channel?.cid },
|
|
241
|
+
{
|
|
242
|
+
unread_channels: 2,
|
|
243
|
+
unread_messages: 5,
|
|
244
|
+
user: { id: 'random-id' },
|
|
245
|
+
},
|
|
246
|
+
);
|
|
247
|
+
});
|
|
248
|
+
|
|
249
|
+
await waitFor(() => {
|
|
250
|
+
expect(getByTestId('unread-count')).toHaveTextContent('0');
|
|
251
|
+
});
|
|
252
|
+
});
|
|
253
|
+
|
|
254
|
+
it("should update the unread count if the event's user id matches the client's user id", async () => {
|
|
255
|
+
const c = generateChannelResponse();
|
|
256
|
+
await useInitializeChannel(c);
|
|
257
|
+
const channelOnMock = jest.fn().mockReturnValue({ unsubscribe: jest.fn() });
|
|
258
|
+
|
|
259
|
+
const testChannel = generateChannelWrapper({
|
|
260
|
+
...channel,
|
|
261
|
+
on: channelOnMock,
|
|
262
|
+
});
|
|
263
|
+
|
|
264
|
+
const { getByTestId } = render(<TestComponent />);
|
|
265
|
+
|
|
266
|
+
await waitFor(() => getByTestId('channel-id'));
|
|
267
|
+
|
|
268
|
+
await waitFor(() => {
|
|
269
|
+
expect(getByTestId('unread-count')).toHaveTextContent('0');
|
|
270
|
+
});
|
|
271
|
+
|
|
272
|
+
act(() => {
|
|
273
|
+
dispatchNotificationMarkUnread(
|
|
274
|
+
chatClient,
|
|
275
|
+
{ cid: testChannel?.cid },
|
|
276
|
+
{
|
|
277
|
+
unread_channels: 2,
|
|
278
|
+
unread_messages: 5,
|
|
279
|
+
user: { id: clientUser.id },
|
|
280
|
+
},
|
|
281
|
+
);
|
|
282
|
+
});
|
|
283
|
+
|
|
284
|
+
await waitFor(() => {
|
|
285
|
+
expect(getByTestId('unread-count')).toHaveTextContent('5');
|
|
286
|
+
});
|
|
287
|
+
});
|
|
288
|
+
});
|
|
289
|
+
|
|
290
|
+
it('should update the unread count to 0 if the channel is muted', async () => {
|
|
291
|
+
const channelOnMock = jest.fn().mockReturnValue({ unsubscribe: jest.fn() });
|
|
292
|
+
|
|
293
|
+
const c = generateChannelWrapper({
|
|
294
|
+
countUnread: jest.fn().mockReturnValue(10),
|
|
295
|
+
muteStatus: jest.fn().mockReturnValue({ muted: true }),
|
|
296
|
+
on: channelOnMock,
|
|
297
|
+
});
|
|
298
|
+
|
|
299
|
+
channel = c as unknown as Channel;
|
|
94
300
|
|
|
95
301
|
const { getByTestId } = render(<TestComponent />);
|
|
96
302
|
|
|
97
303
|
await waitFor(() => getByTestId('channel-id'));
|
|
98
304
|
|
|
99
|
-
|
|
305
|
+
await waitFor(() => {
|
|
306
|
+
expect(getByTestId('unread-count')).toHaveTextContent('0');
|
|
307
|
+
});
|
|
100
308
|
|
|
101
309
|
act(() => {
|
|
102
|
-
|
|
310
|
+
dispatchNotificationMarkUnread(
|
|
311
|
+
chatClient,
|
|
312
|
+
{ cid: channel?.cid },
|
|
313
|
+
{
|
|
314
|
+
unread_channels: 2,
|
|
315
|
+
unread_messages: 5,
|
|
316
|
+
user: { id: clientUser.id },
|
|
317
|
+
},
|
|
318
|
+
);
|
|
103
319
|
});
|
|
104
320
|
|
|
105
321
|
await waitFor(() => {
|
|
@@ -3,7 +3,6 @@ import { Text } from 'react-native';
|
|
|
3
3
|
|
|
4
4
|
import { render, screen, waitFor } from '@testing-library/react-native';
|
|
5
5
|
|
|
6
|
-
import type { DefaultStreamChatGenerics } from 'src/types/types';
|
|
7
6
|
import type { Channel, ChannelMemberResponse, DefaultGenerics, StreamChat } from 'stream-chat';
|
|
8
7
|
|
|
9
8
|
import {
|
|
@@ -13,6 +12,7 @@ import {
|
|
|
13
12
|
} from '../../../../mock-builders/api/queryMembers';
|
|
14
13
|
import { generateUser } from '../../../../mock-builders/generator/user';
|
|
15
14
|
import { getTestClientWithUser } from '../../../../mock-builders/mock';
|
|
15
|
+
import type { DefaultStreamChatGenerics } from '../../../../types/types';
|
|
16
16
|
import {
|
|
17
17
|
getChannelPreviewDisplayName,
|
|
18
18
|
useChannelPreviewDisplayName,
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { act, renderHook, waitFor } from '@testing-library/react-native';
|
|
2
|
+
import { Channel, DefaultGenerics, StreamChat } from 'stream-chat';
|
|
3
|
+
|
|
4
|
+
import * as ChatContext from '../../../../contexts/chatContext/ChatContext';
|
|
5
|
+
import dispatchNotificationChannelMutesUpdated from '../../../../mock-builders/event/notificationChannelMutesUpdated';
|
|
6
|
+
import { generateUser } from '../../../../mock-builders/generator/user';
|
|
7
|
+
import { getTestClientWithUser } from '../../../../mock-builders/mock';
|
|
8
|
+
import { DefaultStreamChatGenerics } from '../../../../types/types';
|
|
9
|
+
import { useIsChannelMuted } from '../useIsChannelMuted';
|
|
10
|
+
|
|
11
|
+
describe('useChannelPreviewMuted', () => {
|
|
12
|
+
const clientUser = generateUser();
|
|
13
|
+
let chatClient: StreamChat<DefaultGenerics> | StreamChat<DefaultStreamChatGenerics>;
|
|
14
|
+
|
|
15
|
+
beforeEach(async () => {
|
|
16
|
+
chatClient = await getTestClientWithUser(clientUser);
|
|
17
|
+
jest.spyOn(ChatContext, 'useChatContext').mockImplementation(
|
|
18
|
+
jest.fn(
|
|
19
|
+
() =>
|
|
20
|
+
({
|
|
21
|
+
client: chatClient,
|
|
22
|
+
} as unknown as ChatContext.ChatContextValue),
|
|
23
|
+
),
|
|
24
|
+
);
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
afterEach(() => {
|
|
28
|
+
jest.clearAllMocks();
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
const mockChannel = {
|
|
32
|
+
initialized: true,
|
|
33
|
+
muteStatus: jest.fn().mockReturnValue({
|
|
34
|
+
createdAt: Date.now(),
|
|
35
|
+
expiresAt: Date.now() + 5000,
|
|
36
|
+
muted: false,
|
|
37
|
+
}),
|
|
38
|
+
} as unknown as Channel<DefaultStreamChatGenerics>;
|
|
39
|
+
|
|
40
|
+
it('should return the correct mute status', () => {
|
|
41
|
+
const { result } = renderHook(() => useIsChannelMuted(mockChannel));
|
|
42
|
+
expect(result.current.muted).toBe(false);
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
it("should update the mute status when the notification.channel_mutes_updated event is emitted'", () => {
|
|
46
|
+
renderHook(() => useIsChannelMuted(mockChannel));
|
|
47
|
+
|
|
48
|
+
act(() => dispatchNotificationChannelMutesUpdated(chatClient, mockChannel));
|
|
49
|
+
|
|
50
|
+
expect(mockChannel.muteStatus).toHaveBeenCalledTimes(2);
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
it('should clean up the event listener when the component is unmounted', async () => {
|
|
54
|
+
const { unmount } = renderHook(() => useIsChannelMuted(mockChannel));
|
|
55
|
+
|
|
56
|
+
unmount();
|
|
57
|
+
|
|
58
|
+
await waitFor(() => {
|
|
59
|
+
expect(mockChannel.muteStatus).toHaveBeenCalledTimes(1);
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
});
|