stream-chat-react-native-core 7.0.0-rc.8 → 7.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/Attachment/AudioAttachment.js +19 -9
- package/lib/commonjs/components/Attachment/AudioAttachment.js.map +1 -1
- package/lib/commonjs/components/Attachment/FileAttachmentGroup.js +3 -1
- package/lib/commonjs/components/Attachment/FileAttachmentGroup.js.map +1 -1
- package/lib/commonjs/components/Attachment/Gallery.js +16 -3
- package/lib/commonjs/components/Attachment/Gallery.js.map +1 -1
- package/lib/commonjs/components/Attachment/ImageReloadIndicator.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 +7 -24
- package/lib/commonjs/components/AttachmentPicker/components/AttachmentPickerItem.js.map +1 -1
- package/lib/commonjs/components/AutoCompleteInput/AutoCompleteInput.js +2 -4
- package/lib/commonjs/components/AutoCompleteInput/AutoCompleteInput.js.map +1 -1
- package/lib/commonjs/components/Channel/Channel.js +320 -310
- package/lib/commonjs/components/Channel/Channel.js.map +1 -1
- package/lib/commonjs/components/Channel/hooks/useChannelDataState.js.map +1 -1
- package/lib/commonjs/components/Channel/hooks/useCreateMessagesContext.js +2 -0
- package/lib/commonjs/components/Channel/hooks/useCreateMessagesContext.js.map +1 -1
- package/lib/commonjs/components/Channel/hooks/useMessageListPagination.js +133 -147
- package/lib/commonjs/components/Channel/hooks/useMessageListPagination.js.map +1 -1
- package/lib/commonjs/components/Chat/Chat.js.map +1 -1
- package/lib/commonjs/components/KeyboardCompatibleView/KeyboardCompatibleView.js +8 -13
- package/lib/commonjs/components/KeyboardCompatibleView/KeyboardCompatibleView.js.map +1 -1
- package/lib/commonjs/components/Message/Message.js +14 -7
- package/lib/commonjs/components/Message/Message.js.map +1 -1
- package/lib/commonjs/components/Message/MessageSimple/MessageFooter.js.map +1 -1
- package/lib/commonjs/components/Message/MessageSimple/MessageSimple.js +70 -54
- package/lib/commonjs/components/Message/MessageSimple/MessageSimple.js.map +1 -1
- package/lib/commonjs/components/Message/MessageSimple/MessageStatus.js +14 -6
- package/lib/commonjs/components/Message/MessageSimple/MessageStatus.js.map +1 -1
- package/lib/commonjs/components/Message/MessageSimple/MessageTextContainer.js.map +1 -1
- package/lib/commonjs/components/Message/MessageSimple/utils/renderText.js.map +1 -1
- package/lib/commonjs/components/Message/hooks/useCreateMessageContext.js +3 -1
- package/lib/commonjs/components/Message/hooks/useCreateMessageContext.js.map +1 -1
- package/lib/commonjs/components/Message/hooks/useMessageActionHandlers.js.map +1 -1
- package/lib/commonjs/components/Message/hooks/useMessageActions.js.map +1 -1
- package/lib/commonjs/components/MessageInput/FileUploadPreview.js +25 -39
- package/lib/commonjs/components/MessageInput/FileUploadPreview.js.map +1 -1
- package/lib/commonjs/components/MessageInput/InputButtons.js +18 -15
- package/lib/commonjs/components/MessageInput/InputButtons.js.map +1 -1
- package/lib/commonjs/components/MessageInput/MessageInput.js +96 -74
- package/lib/commonjs/components/MessageInput/MessageInput.js.map +1 -1
- package/lib/commonjs/components/MessageInput/components/AudioRecorder/AudioRecordingButton.js +2 -1
- package/lib/commonjs/components/MessageInput/components/AudioRecorder/AudioRecordingButton.js.map +1 -1
- package/lib/commonjs/components/MessageInput/hooks/useAudioController.js +4 -4
- package/lib/commonjs/components/MessageInput/hooks/useAudioController.js.map +1 -1
- package/lib/commonjs/components/MessageList/MessageList.js +281 -223
- package/lib/commonjs/components/MessageList/MessageList.js.map +1 -1
- package/lib/commonjs/components/MessageList/hooks/useMessageList.js +65 -48
- package/lib/commonjs/components/MessageList/hooks/useMessageList.js.map +1 -1
- package/lib/commonjs/components/MessageList/hooks/useShouldScrollToRecentOnNewOwnMessage.js.map +1 -1
- package/lib/commonjs/components/MessageList/utils/getGroupStyles.js +1 -1
- package/lib/commonjs/components/MessageList/utils/getGroupStyles.js.map +1 -1
- package/lib/commonjs/components/MessageList/utils/getLastReceivedMessage.js.map +1 -1
- package/lib/commonjs/components/MessageList/utils/getReadState.js +20 -0
- package/lib/commonjs/components/MessageList/utils/getReadState.js.map +1 -0
- package/lib/commonjs/components/MessageMenu/hooks/useFetchReactions.js.map +1 -1
- package/lib/commonjs/components/Poll/components/Button.js.map +1 -1
- package/lib/commonjs/components/Poll/components/PollResults/PollResultItem.js.map +1 -1
- package/lib/commonjs/components/Reply/Reply.js +2 -2
- package/lib/commonjs/components/Reply/Reply.js.map +1 -1
- package/lib/commonjs/components/Thread/components/ThreadFooterComponent.js +24 -6
- package/lib/commonjs/components/Thread/components/ThreadFooterComponent.js.map +1 -1
- package/lib/commonjs/components/ThreadList/ThreadListItem.js.map +1 -1
- package/lib/commonjs/components/UIComponents/BottomSheetModal.js +10 -6
- package/lib/commonjs/components/UIComponents/BottomSheetModal.js.map +1 -1
- package/lib/commonjs/components/index.js +15 -4
- package/lib/commonjs/components/index.js.map +1 -1
- package/lib/commonjs/contexts/attachmentPickerContext/AttachmentPickerContext.js.map +1 -1
- package/lib/commonjs/contexts/channelsStateContext/useChannelState.js +5 -1
- package/lib/commonjs/contexts/channelsStateContext/useChannelState.js.map +1 -1
- package/lib/commonjs/contexts/debugContext/DebugContext.js.map +1 -1
- package/lib/commonjs/contexts/imageGalleryContext/ImageGalleryContext.js.map +1 -1
- package/lib/commonjs/contexts/messageContext/MessageContext.js.map +1 -1
- package/lib/commonjs/contexts/messageInputContext/MessageInputContext.js +535 -523
- package/lib/commonjs/contexts/messageInputContext/MessageInputContext.js.map +1 -1
- package/lib/commonjs/contexts/messageInputContext/hooks/useCreateMessageInputContext.js +7 -6
- package/lib/commonjs/contexts/messageInputContext/hooks/useCreateMessageInputContext.js.map +1 -1
- package/lib/commonjs/contexts/messageInputContext/hooks/useMessageDetailsForState.js +37 -41
- package/lib/commonjs/contexts/messageInputContext/hooks/useMessageDetailsForState.js.map +1 -1
- package/lib/commonjs/contexts/messageInputContext/utils/utils.js +4 -4
- package/lib/commonjs/contexts/messageInputContext/utils/utils.js.map +1 -1
- package/lib/commonjs/contexts/messagesContext/MessagesContext.js.map +1 -1
- package/lib/commonjs/contexts/pollContext/pollContext.js.map +1 -1
- package/lib/commonjs/contexts/suggestionsContext/SuggestionsContext.js +23 -14
- package/lib/commonjs/contexts/suggestionsContext/SuggestionsContext.js.map +1 -1
- package/lib/commonjs/contexts/themeContext/utils/theme.js +2 -1
- package/lib/commonjs/contexts/themeContext/utils/theme.js.map +1 -1
- package/lib/commonjs/contexts/threadContext/ThreadContext.js.map +1 -1
- package/lib/commonjs/contexts/threadsContext/ThreadListItemContext.js.map +1 -1
- package/lib/commonjs/hooks/index.js +22 -0
- package/lib/commonjs/hooks/index.js.map +1 -1
- package/lib/commonjs/hooks/useAudioPlayer.js +60 -69
- package/lib/commonjs/hooks/useAudioPlayer.js.map +1 -1
- package/lib/commonjs/hooks/useStableCallback.js +13 -0
- package/lib/commonjs/hooks/useStableCallback.js.map +1 -0
- package/lib/commonjs/hooks/useTranslatedMessage.js.map +1 -1
- package/lib/commonjs/i18n/en.json +3 -0
- package/lib/commonjs/i18n/es.json +3 -0
- package/lib/commonjs/i18n/fr.json +3 -0
- package/lib/commonjs/i18n/he.json +3 -0
- package/lib/commonjs/i18n/hi.json +2 -0
- package/lib/commonjs/i18n/it.json +3 -0
- package/lib/commonjs/i18n/ja.json +1 -0
- package/lib/commonjs/i18n/ko.json +1 -0
- package/lib/commonjs/i18n/nl.json +2 -0
- package/lib/commonjs/i18n/pt-br.json +3 -0
- package/lib/commonjs/i18n/ru.json +4 -0
- package/lib/commonjs/i18n/tr.json +2 -0
- package/lib/commonjs/mock-builders/api/channelMocks.js.map +1 -1
- package/lib/commonjs/native.js.map +1 -1
- package/lib/commonjs/store/mappers/mapMessageToStorable.js.map +1 -1
- package/lib/commonjs/types/types.js.map +1 -1
- package/lib/commonjs/utils/compressImage.js +1 -1
- package/lib/commonjs/utils/compressImage.js.map +1 -1
- package/lib/commonjs/utils/removeReservedFields.js.map +1 -1
- package/lib/commonjs/utils/utils.js +17 -4
- package/lib/commonjs/utils/utils.js.map +1 -1
- package/lib/commonjs/version.json +1 -1
- package/lib/module/components/Attachment/AudioAttachment.js +19 -9
- package/lib/module/components/Attachment/AudioAttachment.js.map +1 -1
- package/lib/module/components/Attachment/FileAttachmentGroup.js +3 -1
- package/lib/module/components/Attachment/FileAttachmentGroup.js.map +1 -1
- package/lib/module/components/Attachment/Gallery.js +16 -3
- package/lib/module/components/Attachment/Gallery.js.map +1 -1
- package/lib/module/components/Attachment/ImageReloadIndicator.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 +7 -24
- package/lib/module/components/AttachmentPicker/components/AttachmentPickerItem.js.map +1 -1
- package/lib/module/components/AutoCompleteInput/AutoCompleteInput.js +2 -4
- package/lib/module/components/AutoCompleteInput/AutoCompleteInput.js.map +1 -1
- package/lib/module/components/Channel/Channel.js +320 -310
- package/lib/module/components/Channel/Channel.js.map +1 -1
- package/lib/module/components/Channel/hooks/useChannelDataState.js.map +1 -1
- package/lib/module/components/Channel/hooks/useCreateMessagesContext.js +2 -0
- package/lib/module/components/Channel/hooks/useCreateMessagesContext.js.map +1 -1
- package/lib/module/components/Channel/hooks/useMessageListPagination.js +133 -147
- package/lib/module/components/Channel/hooks/useMessageListPagination.js.map +1 -1
- package/lib/module/components/Chat/Chat.js.map +1 -1
- package/lib/module/components/KeyboardCompatibleView/KeyboardCompatibleView.js +8 -13
- package/lib/module/components/KeyboardCompatibleView/KeyboardCompatibleView.js.map +1 -1
- package/lib/module/components/Message/Message.js +14 -7
- package/lib/module/components/Message/Message.js.map +1 -1
- package/lib/module/components/Message/MessageSimple/MessageFooter.js.map +1 -1
- package/lib/module/components/Message/MessageSimple/MessageSimple.js +70 -54
- package/lib/module/components/Message/MessageSimple/MessageSimple.js.map +1 -1
- package/lib/module/components/Message/MessageSimple/MessageStatus.js +14 -6
- package/lib/module/components/Message/MessageSimple/MessageStatus.js.map +1 -1
- package/lib/module/components/Message/MessageSimple/MessageTextContainer.js.map +1 -1
- package/lib/module/components/Message/MessageSimple/utils/renderText.js.map +1 -1
- package/lib/module/components/Message/hooks/useCreateMessageContext.js +3 -1
- package/lib/module/components/Message/hooks/useCreateMessageContext.js.map +1 -1
- package/lib/module/components/Message/hooks/useMessageActionHandlers.js.map +1 -1
- package/lib/module/components/Message/hooks/useMessageActions.js.map +1 -1
- package/lib/module/components/MessageInput/FileUploadPreview.js +25 -39
- package/lib/module/components/MessageInput/FileUploadPreview.js.map +1 -1
- package/lib/module/components/MessageInput/InputButtons.js +18 -15
- package/lib/module/components/MessageInput/InputButtons.js.map +1 -1
- package/lib/module/components/MessageInput/MessageInput.js +96 -74
- package/lib/module/components/MessageInput/MessageInput.js.map +1 -1
- package/lib/module/components/MessageInput/components/AudioRecorder/AudioRecordingButton.js +2 -1
- package/lib/module/components/MessageInput/components/AudioRecorder/AudioRecordingButton.js.map +1 -1
- package/lib/module/components/MessageInput/hooks/useAudioController.js +4 -4
- package/lib/module/components/MessageInput/hooks/useAudioController.js.map +1 -1
- package/lib/module/components/MessageList/MessageList.js +281 -223
- package/lib/module/components/MessageList/MessageList.js.map +1 -1
- package/lib/module/components/MessageList/hooks/useMessageList.js +65 -48
- package/lib/module/components/MessageList/hooks/useMessageList.js.map +1 -1
- package/lib/module/components/MessageList/hooks/useShouldScrollToRecentOnNewOwnMessage.js.map +1 -1
- package/lib/module/components/MessageList/utils/getGroupStyles.js +1 -1
- package/lib/module/components/MessageList/utils/getGroupStyles.js.map +1 -1
- package/lib/module/components/MessageList/utils/getLastReceivedMessage.js.map +1 -1
- package/lib/module/components/MessageList/utils/getReadState.js +20 -0
- package/lib/module/components/MessageList/utils/getReadState.js.map +1 -0
- package/lib/module/components/MessageMenu/hooks/useFetchReactions.js.map +1 -1
- package/lib/module/components/Poll/components/Button.js.map +1 -1
- package/lib/module/components/Poll/components/PollResults/PollResultItem.js.map +1 -1
- package/lib/module/components/Reply/Reply.js +2 -2
- package/lib/module/components/Reply/Reply.js.map +1 -1
- package/lib/module/components/Thread/components/ThreadFooterComponent.js +24 -6
- package/lib/module/components/Thread/components/ThreadFooterComponent.js.map +1 -1
- package/lib/module/components/ThreadList/ThreadListItem.js.map +1 -1
- package/lib/module/components/UIComponents/BottomSheetModal.js +10 -6
- package/lib/module/components/UIComponents/BottomSheetModal.js.map +1 -1
- package/lib/module/components/index.js +15 -4
- package/lib/module/components/index.js.map +1 -1
- package/lib/module/contexts/attachmentPickerContext/AttachmentPickerContext.js.map +1 -1
- package/lib/module/contexts/channelsStateContext/useChannelState.js +5 -1
- package/lib/module/contexts/channelsStateContext/useChannelState.js.map +1 -1
- package/lib/module/contexts/debugContext/DebugContext.js.map +1 -1
- package/lib/module/contexts/imageGalleryContext/ImageGalleryContext.js.map +1 -1
- package/lib/module/contexts/messageContext/MessageContext.js.map +1 -1
- package/lib/module/contexts/messageInputContext/MessageInputContext.js +535 -523
- package/lib/module/contexts/messageInputContext/MessageInputContext.js.map +1 -1
- package/lib/module/contexts/messageInputContext/hooks/useCreateMessageInputContext.js +7 -6
- package/lib/module/contexts/messageInputContext/hooks/useCreateMessageInputContext.js.map +1 -1
- package/lib/module/contexts/messageInputContext/hooks/useMessageDetailsForState.js +37 -41
- package/lib/module/contexts/messageInputContext/hooks/useMessageDetailsForState.js.map +1 -1
- package/lib/module/contexts/messageInputContext/utils/utils.js +4 -4
- package/lib/module/contexts/messageInputContext/utils/utils.js.map +1 -1
- package/lib/module/contexts/messagesContext/MessagesContext.js.map +1 -1
- package/lib/module/contexts/pollContext/pollContext.js.map +1 -1
- package/lib/module/contexts/suggestionsContext/SuggestionsContext.js +23 -14
- package/lib/module/contexts/suggestionsContext/SuggestionsContext.js.map +1 -1
- package/lib/module/contexts/themeContext/utils/theme.js +2 -1
- package/lib/module/contexts/themeContext/utils/theme.js.map +1 -1
- package/lib/module/contexts/threadContext/ThreadContext.js.map +1 -1
- package/lib/module/contexts/threadsContext/ThreadListItemContext.js.map +1 -1
- package/lib/module/hooks/index.js +22 -0
- package/lib/module/hooks/index.js.map +1 -1
- package/lib/module/hooks/useAudioPlayer.js +60 -69
- package/lib/module/hooks/useAudioPlayer.js.map +1 -1
- package/lib/module/hooks/useStableCallback.js +13 -0
- package/lib/module/hooks/useStableCallback.js.map +1 -0
- package/lib/module/hooks/useTranslatedMessage.js.map +1 -1
- package/lib/module/i18n/en.json +3 -0
- package/lib/module/i18n/es.json +3 -0
- package/lib/module/i18n/fr.json +3 -0
- package/lib/module/i18n/he.json +3 -0
- package/lib/module/i18n/hi.json +2 -0
- package/lib/module/i18n/it.json +3 -0
- package/lib/module/i18n/ja.json +1 -0
- package/lib/module/i18n/ko.json +1 -0
- package/lib/module/i18n/nl.json +2 -0
- package/lib/module/i18n/pt-br.json +3 -0
- package/lib/module/i18n/ru.json +4 -0
- package/lib/module/i18n/tr.json +2 -0
- package/lib/module/mock-builders/api/channelMocks.js.map +1 -1
- package/lib/module/native.js.map +1 -1
- package/lib/module/store/mappers/mapMessageToStorable.js.map +1 -1
- package/lib/module/types/types.js.map +1 -1
- package/lib/module/utils/compressImage.js +1 -1
- package/lib/module/utils/compressImage.js.map +1 -1
- package/lib/module/utils/removeReservedFields.js.map +1 -1
- package/lib/module/utils/utils.js +17 -4
- package/lib/module/utils/utils.js.map +1 -1
- package/lib/module/version.json +1 -1
- package/lib/typescript/components/Attachment/AudioAttachment.d.ts +2 -2
- package/lib/typescript/components/Attachment/AudioAttachment.d.ts.map +1 -1
- package/lib/typescript/components/Attachment/FileAttachmentGroup.d.ts.map +1 -1
- package/lib/typescript/components/Attachment/Gallery.d.ts +3 -3
- package/lib/typescript/components/Attachment/Gallery.d.ts.map +1 -1
- package/lib/typescript/components/Attachment/ImageReloadIndicator.d.ts +4 -3
- package/lib/typescript/components/Attachment/ImageReloadIndicator.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 +2 -2
- package/lib/typescript/components/AttachmentPicker/components/AttachmentPickerItem.d.ts.map +1 -1
- package/lib/typescript/components/AutoCompleteInput/AutoCompleteInput.d.ts +2 -3
- package/lib/typescript/components/AutoCompleteInput/AutoCompleteInput.d.ts.map +1 -1
- package/lib/typescript/components/Channel/Channel.d.ts +3 -4
- package/lib/typescript/components/Channel/Channel.d.ts.map +1 -1
- package/lib/typescript/components/Channel/hooks/useChannelDataState.d.ts +2 -3
- package/lib/typescript/components/Channel/hooks/useChannelDataState.d.ts.map +1 -1
- package/lib/typescript/components/Channel/hooks/useCreateMessagesContext.d.ts +1 -1
- package/lib/typescript/components/Channel/hooks/useCreateMessagesContext.d.ts.map +1 -1
- package/lib/typescript/components/Channel/hooks/useCreateThreadContext.d.ts +6 -6
- package/lib/typescript/components/Channel/hooks/useCreateThreadContext.d.ts.map +1 -1
- package/lib/typescript/components/Channel/hooks/useMessageListPagination.d.ts +3 -3
- package/lib/typescript/components/Channel/hooks/useMessageListPagination.d.ts.map +1 -1
- package/lib/typescript/components/ChannelPreview/hooks/useChannelPreviewData.d.ts +1 -1
- package/lib/typescript/components/ChannelPreview/hooks/useLatestMessagePreview.d.ts +1 -1
- package/lib/typescript/components/Chat/Chat.d.ts +0 -9
- package/lib/typescript/components/Chat/Chat.d.ts.map +1 -1
- package/lib/typescript/components/KeyboardCompatibleView/KeyboardCompatibleView.d.ts +3 -0
- package/lib/typescript/components/KeyboardCompatibleView/KeyboardCompatibleView.d.ts.map +1 -1
- package/lib/typescript/components/Message/Message.d.ts +4 -5
- package/lib/typescript/components/Message/Message.d.ts.map +1 -1
- package/lib/typescript/components/Message/MessageSimple/MessageFooter.d.ts +2 -3
- package/lib/typescript/components/Message/MessageSimple/MessageFooter.d.ts.map +1 -1
- package/lib/typescript/components/Message/MessageSimple/MessageSimple.d.ts.map +1 -1
- package/lib/typescript/components/Message/MessageSimple/MessageStatus.d.ts +1 -1
- package/lib/typescript/components/Message/MessageSimple/MessageStatus.d.ts.map +1 -1
- package/lib/typescript/components/Message/MessageSimple/MessageTextContainer.d.ts.map +1 -1
- package/lib/typescript/components/Message/MessageSimple/utils/renderText.d.ts +2 -2
- 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/useMessageActionHandlers.d.ts.map +1 -1
- package/lib/typescript/components/Message/hooks/useMessageActions.d.ts +2 -2
- package/lib/typescript/components/Message/hooks/useMessageActions.d.ts.map +1 -1
- package/lib/typescript/components/MessageInput/FileUploadPreview.d.ts +2 -4
- package/lib/typescript/components/MessageInput/FileUploadPreview.d.ts.map +1 -1
- package/lib/typescript/components/MessageInput/InputButtons.d.ts +1 -1
- package/lib/typescript/components/MessageInput/InputButtons.d.ts.map +1 -1
- 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/hooks/useAudioController.d.ts.map +1 -1
- package/lib/typescript/components/MessageList/MessageList.d.ts +4 -4
- package/lib/typescript/components/MessageList/MessageList.d.ts.map +1 -1
- package/lib/typescript/components/MessageList/MessageSystem.d.ts +2 -2
- package/lib/typescript/components/MessageList/MessageSystem.d.ts.map +1 -1
- package/lib/typescript/components/MessageList/hooks/useMessageList.d.ts +14 -9
- package/lib/typescript/components/MessageList/hooks/useMessageList.d.ts.map +1 -1
- package/lib/typescript/components/MessageList/hooks/useShouldScrollToRecentOnNewOwnMessage.d.ts +2 -2
- package/lib/typescript/components/MessageList/hooks/useShouldScrollToRecentOnNewOwnMessage.d.ts.map +1 -1
- package/lib/typescript/components/MessageList/utils/getGroupStyles.d.ts.map +1 -1
- package/lib/typescript/components/MessageList/utils/getLastReceivedMessage.d.ts +2 -2
- package/lib/typescript/components/MessageList/utils/getLastReceivedMessage.d.ts.map +1 -1
- package/lib/typescript/components/MessageList/utils/getReadState.d.ts +9 -0
- package/lib/typescript/components/MessageList/utils/getReadState.d.ts.map +1 -0
- package/lib/typescript/components/MessageMenu/hooks/useFetchReactions.d.ts +2 -3
- package/lib/typescript/components/MessageMenu/hooks/useFetchReactions.d.ts.map +1 -1
- package/lib/typescript/components/Poll/components/Button.d.ts +2 -3
- package/lib/typescript/components/Poll/components/Button.d.ts.map +1 -1
- package/lib/typescript/components/Poll/components/PollResults/PollResultItem.d.ts +2 -3
- package/lib/typescript/components/Poll/components/PollResults/PollResultItem.d.ts.map +1 -1
- package/lib/typescript/components/Reply/Reply.d.ts.map +1 -1
- package/lib/typescript/components/Thread/components/ThreadFooterComponent.d.ts.map +1 -1
- package/lib/typescript/components/ThreadList/ThreadListItem.d.ts.map +1 -1
- package/lib/typescript/components/UIComponents/BottomSheetModal.d.ts.map +1 -1
- package/lib/typescript/components/index.d.ts +2 -1
- package/lib/typescript/components/index.d.ts.map +1 -1
- package/lib/typescript/contexts/attachmentPickerContext/AttachmentPickerContext.d.ts +3 -3
- package/lib/typescript/contexts/attachmentPickerContext/AttachmentPickerContext.d.ts.map +1 -1
- package/lib/typescript/contexts/channelsStateContext/useChannelState.d.ts.map +1 -1
- package/lib/typescript/contexts/debugContext/DebugContext.d.ts +2 -3
- package/lib/typescript/contexts/debugContext/DebugContext.d.ts.map +1 -1
- package/lib/typescript/contexts/imageGalleryContext/ImageGalleryContext.d.ts +3 -3
- package/lib/typescript/contexts/imageGalleryContext/ImageGalleryContext.d.ts.map +1 -1
- package/lib/typescript/contexts/messageContext/MessageContext.d.ts +6 -4
- package/lib/typescript/contexts/messageContext/MessageContext.d.ts.map +1 -1
- package/lib/typescript/contexts/messageInputContext/MessageInputContext.d.ts +13 -15
- 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/messageInputContext/hooks/useMessageDetailsForState.d.ts +3 -3
- package/lib/typescript/contexts/messageInputContext/hooks/useMessageDetailsForState.d.ts.map +1 -1
- package/lib/typescript/contexts/messageInputContext/utils/utils.d.ts +2 -2
- package/lib/typescript/contexts/messageInputContext/utils/utils.d.ts.map +1 -1
- package/lib/typescript/contexts/messagesContext/MessagesContext.d.ts +25 -21
- package/lib/typescript/contexts/messagesContext/MessagesContext.d.ts.map +1 -1
- package/lib/typescript/contexts/pollContext/pollContext.d.ts +2 -3
- package/lib/typescript/contexts/pollContext/pollContext.d.ts.map +1 -1
- package/lib/typescript/contexts/suggestionsContext/SuggestionsContext.d.ts.map +1 -1
- package/lib/typescript/contexts/themeContext/utils/theme.d.ts +1 -0
- package/lib/typescript/contexts/themeContext/utils/theme.d.ts.map +1 -1
- package/lib/typescript/contexts/threadContext/ThreadContext.d.ts +4 -5
- package/lib/typescript/contexts/threadContext/ThreadContext.d.ts.map +1 -1
- package/lib/typescript/contexts/threadsContext/ThreadListItemContext.d.ts +3 -4
- package/lib/typescript/contexts/threadsContext/ThreadListItemContext.d.ts.map +1 -1
- package/lib/typescript/hooks/index.d.ts +2 -0
- package/lib/typescript/hooks/index.d.ts.map +1 -1
- package/lib/typescript/hooks/useAudioPlayer.d.ts.map +1 -1
- package/lib/typescript/hooks/useStableCallback.d.ts +26 -0
- package/lib/typescript/hooks/useStableCallback.d.ts.map +1 -0
- package/lib/typescript/hooks/useTranslatedMessage.d.ts +59 -58
- package/lib/typescript/hooks/useTranslatedMessage.d.ts.map +1 -1
- package/lib/typescript/i18n/en.json +3 -0
- package/lib/typescript/i18n/es.json +3 -0
- package/lib/typescript/i18n/fr.json +3 -0
- package/lib/typescript/i18n/he.json +3 -0
- package/lib/typescript/i18n/hi.json +2 -0
- package/lib/typescript/i18n/it.json +3 -0
- package/lib/typescript/i18n/ja.json +1 -0
- package/lib/typescript/i18n/ko.json +1 -0
- package/lib/typescript/i18n/nl.json +2 -0
- package/lib/typescript/i18n/pt-br.json +3 -0
- package/lib/typescript/i18n/ru.json +4 -0
- package/lib/typescript/i18n/tr.json +2 -0
- package/lib/typescript/native.d.ts +8 -11
- package/lib/typescript/native.d.ts.map +1 -1
- package/lib/typescript/store/apis/insertReaction.d.ts +2 -2
- package/lib/typescript/store/apis/insertReaction.d.ts.map +1 -1
- package/lib/typescript/store/apis/updateMessage.d.ts +2 -2
- package/lib/typescript/store/apis/updateMessage.d.ts.map +1 -1
- package/lib/typescript/store/apis/updateReaction.d.ts +2 -2
- package/lib/typescript/store/apis/updateReaction.d.ts.map +1 -1
- package/lib/typescript/store/mappers/mapMessageToStorable.d.ts +2 -2
- package/lib/typescript/store/mappers/mapMessageToStorable.d.ts.map +1 -1
- package/lib/typescript/types/types.d.ts +28 -50
- package/lib/typescript/types/types.d.ts.map +1 -1
- package/lib/typescript/utils/compressImage.d.ts +2 -2
- package/lib/typescript/utils/compressImage.d.ts.map +1 -1
- package/lib/typescript/utils/i18n/Streami18n.d.ts +3 -0
- package/lib/typescript/utils/i18n/Streami18n.d.ts.map +1 -1
- package/lib/typescript/utils/removeReservedFields.d.ts +2 -3
- package/lib/typescript/utils/removeReservedFields.d.ts.map +1 -1
- package/lib/typescript/utils/utils.d.ts +10 -10
- package/lib/typescript/utils/utils.d.ts.map +1 -1
- package/package.json +4 -3
- package/src/components/Attachment/AudioAttachment.tsx +12 -6
- package/src/components/Attachment/FileAttachmentGroup.tsx +3 -1
- package/src/components/Attachment/Gallery.tsx +22 -7
- package/src/components/Attachment/ImageReloadIndicator.tsx +4 -5
- package/src/components/AttachmentPicker/AttachmentPicker.tsx +4 -10
- package/src/components/AttachmentPicker/components/AttachmentPickerItem.tsx +9 -37
- package/src/components/AutoCompleteInput/AutoCompleteInput.tsx +27 -23
- package/src/components/AutoCompleteInput/__tests__/AutoCompleteInput.test.js +12 -12
- package/src/components/Channel/Channel.tsx +423 -361
- package/src/components/Channel/__tests__/Channel.test.js +10 -3
- package/src/components/Channel/hooks/useChannelDataState.ts +2 -4
- package/src/components/Channel/hooks/useCreateMessagesContext.ts +2 -0
- package/src/components/Channel/hooks/useMessageListPagination.tsx +150 -150
- package/src/components/Chat/Chat.tsx +0 -9
- package/src/components/ImageGallery/__tests__/ImageGallery.test.tsx +8 -7
- package/src/components/ImageGallery/__tests__/ImageGalleryFooter.test.tsx +5 -4
- package/src/components/ImageGallery/__tests__/ImageGalleryHeader.test.tsx +5 -4
- package/src/components/ImageGallery/__tests__/ImageGalleryOverlay.test.tsx +3 -2
- package/src/components/KeyboardCompatibleView/KeyboardCompatibleView.tsx +12 -5
- package/src/components/Message/Message.tsx +16 -15
- package/src/components/Message/MessageSimple/MessageFooter.tsx +2 -3
- package/src/components/Message/MessageSimple/MessageSimple.tsx +112 -70
- package/src/components/Message/MessageSimple/MessageStatus.tsx +19 -17
- package/src/components/Message/MessageSimple/MessageTextContainer.tsx +3 -3
- package/src/components/Message/MessageSimple/__tests__/MessageStatus.test.js +11 -5
- package/src/components/Message/MessageSimple/__tests__/MessageTextContainer.test.tsx +5 -4
- package/src/components/Message/MessageSimple/utils/renderText.tsx +2 -3
- package/src/components/Message/hooks/useCreateMessageContext.ts +3 -0
- package/src/components/Message/hooks/useMessageActionHandlers.ts +1 -3
- package/src/components/Message/hooks/useMessageActions.tsx +4 -3
- package/src/components/MessageInput/FileUploadPreview.tsx +41 -70
- package/src/components/MessageInput/ImageUploadPreview.tsx +2 -2
- package/src/components/MessageInput/InputButtons.tsx +14 -10
- package/src/components/MessageInput/MessageInput.tsx +28 -30
- package/src/components/MessageInput/__tests__/FileUploadPreview.test.js +1 -1
- package/src/components/MessageInput/__tests__/MessageInput.test.js +3 -1
- package/src/components/MessageInput/components/AudioRecorder/AudioRecordingButton.tsx +1 -0
- package/src/components/MessageInput/hooks/useAudioController.tsx +6 -5
- package/src/components/MessageList/MessageList.tsx +253 -137
- package/src/components/MessageList/MessageSystem.tsx +2 -2
- package/src/components/MessageList/hooks/useMessageList.ts +82 -64
- package/src/components/MessageList/hooks/useShouldScrollToRecentOnNewOwnMessage.ts +2 -2
- package/src/components/MessageList/utils/getGroupStyles.ts +7 -5
- package/src/components/MessageList/utils/getLastReceivedMessage.ts +3 -3
- package/src/components/MessageList/utils/getReadState.ts +27 -0
- package/src/components/MessageMenu/__tests__/MessageUserReactions.test.tsx +2 -3
- package/src/components/MessageMenu/hooks/useFetchReactions.ts +2 -3
- package/src/components/Poll/components/Button.tsx +2 -4
- package/src/components/Poll/components/PollResults/PollResultItem.tsx +2 -3
- package/src/components/Reply/Reply.tsx +1 -2
- package/src/components/Thread/__tests__/__snapshots__/Thread.test.js.snap +318 -847
- package/src/components/Thread/components/ThreadFooterComponent.tsx +31 -9
- package/src/components/ThreadList/ThreadListItem.tsx +6 -4
- package/src/components/UIComponents/BottomSheetModal.tsx +11 -7
- package/src/components/index.ts +2 -1
- package/src/contexts/attachmentPickerContext/AttachmentPickerContext.tsx +5 -4
- package/src/contexts/channelsStateContext/useChannelState.ts +5 -1
- package/src/contexts/debugContext/DebugContext.tsx +2 -4
- package/src/contexts/imageGalleryContext/ImageGalleryContext.tsx +5 -4
- package/src/contexts/messageContext/MessageContext.tsx +6 -4
- package/src/contexts/messageInputContext/MessageInputContext.tsx +295 -262
- package/src/contexts/messageInputContext/__tests__/__snapshots__/sendMessage.test.tsx.snap +10 -6
- package/src/contexts/messageInputContext/__tests__/sendMessage.test.tsx +6 -5
- package/src/contexts/messageInputContext/__tests__/updateMessage.test.tsx +3 -5
- package/src/contexts/messageInputContext/__tests__/useMessageDetailsForState.test.tsx +14 -9
- package/src/contexts/messageInputContext/hooks/useCreateMessageInputContext.ts +7 -3
- package/src/contexts/messageInputContext/hooks/useMessageDetailsForState.ts +37 -40
- package/src/contexts/messageInputContext/utils/utils.ts +6 -8
- package/src/contexts/messagesContext/MessagesContext.tsx +26 -20
- package/src/contexts/pollContext/pollContext.tsx +2 -4
- package/src/contexts/suggestionsContext/SuggestionsContext.tsx +33 -14
- package/src/contexts/themeContext/utils/theme.ts +2 -0
- package/src/contexts/threadContext/ThreadContext.tsx +4 -6
- package/src/contexts/threadsContext/ThreadListItemContext.tsx +3 -5
- package/src/hooks/index.ts +2 -0
- package/src/hooks/useAudioPlayer.ts +37 -31
- package/src/hooks/useStableCallback.ts +37 -0
- package/src/hooks/useTranslatedMessage.ts +2 -2
- package/src/i18n/en.json +3 -0
- package/src/i18n/es.json +3 -0
- package/src/i18n/fr.json +3 -0
- package/src/i18n/he.json +3 -0
- package/src/i18n/hi.json +2 -0
- package/src/i18n/it.json +3 -0
- package/src/i18n/ja.json +1 -0
- package/src/i18n/ko.json +1 -0
- package/src/i18n/nl.json +2 -0
- package/src/i18n/pt-br.json +3 -0
- package/src/i18n/ru.json +4 -0
- package/src/i18n/tr.json +2 -0
- package/src/mock-builders/api/channelMocks.tsx +2 -8
- package/src/native.ts +13 -8
- package/src/store/apis/insertReaction.ts +2 -2
- package/src/store/apis/updateMessage.ts +2 -2
- package/src/store/apis/updateReaction.ts +2 -2
- package/src/store/mappers/mapMessageToStorable.ts +2 -2
- package/src/types/stream-chat-common-custom-data.d.ts +22 -22
- package/src/types/types.ts +35 -54
- package/src/utils/compressImage.ts +3 -4
- package/src/utils/removeReservedFields.ts +3 -5
- package/src/utils/utils.ts +25 -16
- package/src/version.json +1 -1
- package/lib/commonjs/components/MessageList/hooks/useLastReadData.js +0 -20
- package/lib/commonjs/components/MessageList/hooks/useLastReadData.js.map +0 -1
- package/lib/commonjs/components/MessageList/utils/getReadStates.js +0 -34
- package/lib/commonjs/components/MessageList/utils/getReadStates.js.map +0 -1
- package/lib/module/components/MessageList/hooks/useLastReadData.js +0 -20
- package/lib/module/components/MessageList/hooks/useLastReadData.js.map +0 -1
- package/lib/module/components/MessageList/utils/getReadStates.js +0 -34
- package/lib/module/components/MessageList/utils/getReadStates.js.map +0 -1
- package/lib/typescript/components/MessageList/hooks/useLastReadData.d.ts +0 -12
- package/lib/typescript/components/MessageList/hooks/useLastReadData.d.ts.map +0 -1
- package/lib/typescript/components/MessageList/utils/getReadStates.d.ts +0 -5
- package/lib/typescript/components/MessageList/utils/getReadStates.d.ts.map +0 -1
- package/src/components/MessageList/hooks/useLastReadData.ts +0 -29
- package/src/components/MessageList/utils/getReadStates.ts +0 -55
|
@@ -77,6 +77,8 @@ describe('Channel', () => {
|
|
|
77
77
|
useMockedApis(chatClient, [getOrCreateChannelApi(mockedChannel)]);
|
|
78
78
|
channel = chatClient.channel('messaging', mockedChannel.id);
|
|
79
79
|
channel.cid = mockedChannel.channel.cid;
|
|
80
|
+
const getConfigSpy = jest.fn();
|
|
81
|
+
channel.getConfig = getConfigSpy;
|
|
80
82
|
});
|
|
81
83
|
|
|
82
84
|
afterEach(() => {
|
|
@@ -356,7 +358,7 @@ describe('Channel initial load useEffect', () => {
|
|
|
356
358
|
cleanup();
|
|
357
359
|
});
|
|
358
360
|
|
|
359
|
-
it('should
|
|
361
|
+
it('should still call channel.watch if we are online and DB channels are loaded', async () => {
|
|
360
362
|
const messages = Array.from({ length: 10 }, (_, i) => generateMessage({ id: i }));
|
|
361
363
|
const mockedChannel = generateChannelResponse({
|
|
362
364
|
messages,
|
|
@@ -366,13 +368,18 @@ describe('Channel initial load useEffect', () => {
|
|
|
366
368
|
const channel = chatClient.channel('messaging', mockedChannel.id);
|
|
367
369
|
await channel.watch();
|
|
368
370
|
channel.offlineMode = true;
|
|
369
|
-
channel.state =
|
|
371
|
+
channel.state = {
|
|
372
|
+
...channelInitialState,
|
|
373
|
+
messagePagination: {
|
|
374
|
+
hasPrev: true,
|
|
375
|
+
},
|
|
376
|
+
};
|
|
370
377
|
const watchSpy = jest.fn();
|
|
371
378
|
channel.watch = watchSpy;
|
|
372
379
|
|
|
373
380
|
renderComponent({ channel });
|
|
374
381
|
|
|
375
|
-
await waitFor(() => expect(watchSpy).
|
|
382
|
+
await waitFor(() => expect(watchSpy).toHaveBeenCalledTimes(1));
|
|
376
383
|
});
|
|
377
384
|
|
|
378
385
|
it("should call channel.watch if channel is initialized and it's not in offline mode", async () => {
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { useCallback, useState } from 'react';
|
|
2
2
|
|
|
3
|
-
import { Channel, ChannelState as StreamChannelState } from 'stream-chat';
|
|
4
|
-
|
|
5
|
-
import { MessageType } from '../../MessageList/hooks/useMessageList';
|
|
3
|
+
import { Channel, LocalMessage, ChannelState as StreamChannelState } from 'stream-chat';
|
|
6
4
|
|
|
7
5
|
export const channelInitialState = {
|
|
8
6
|
hasMore: true,
|
|
@@ -38,7 +36,7 @@ export type ChannelMessagesState = {
|
|
|
38
36
|
* The ChannelThreadState object
|
|
39
37
|
*/
|
|
40
38
|
export type ChannelThreadState = {
|
|
41
|
-
thread:
|
|
39
|
+
thread: LocalMessage | null;
|
|
42
40
|
threadHasMore?: boolean;
|
|
43
41
|
threadLoadingMore?: boolean;
|
|
44
42
|
threadMessages?: StreamChannelState['messages'];
|
|
@@ -45,6 +45,7 @@ export const useCreateMessagesContext = ({
|
|
|
45
45
|
hasCreatePoll,
|
|
46
46
|
ImageLoadingFailedIndicator,
|
|
47
47
|
ImageLoadingIndicator,
|
|
48
|
+
ImageReloadIndicator,
|
|
48
49
|
initialScrollToFirstUnreadMessage,
|
|
49
50
|
InlineDateSeparator,
|
|
50
51
|
InlineUnreadIndicator,
|
|
@@ -162,6 +163,7 @@ export const useCreateMessagesContext = ({
|
|
|
162
163
|
hasCreatePoll,
|
|
163
164
|
ImageLoadingFailedIndicator,
|
|
164
165
|
ImageLoadingIndicator,
|
|
166
|
+
ImageReloadIndicator,
|
|
165
167
|
initialScrollToFirstUnreadMessage,
|
|
166
168
|
InlineDateSeparator,
|
|
167
169
|
InlineUnreadIndicator,
|
|
@@ -6,6 +6,7 @@ import { Channel, ChannelState, MessageResponse } from 'stream-chat';
|
|
|
6
6
|
import { useChannelMessageDataState } from './useChannelDataState';
|
|
7
7
|
|
|
8
8
|
import { ChannelContextValue } from '../../../contexts/channelContext/ChannelContext';
|
|
9
|
+
import { useStableCallback } from '../../../hooks';
|
|
9
10
|
import { findInMessagesByDate, findInMessagesById } from '../../../utils/utils';
|
|
10
11
|
|
|
11
12
|
const defaultDebounceInterval = 500;
|
|
@@ -59,7 +60,7 @@ export const useMessageListPagination = ({ channel }: { channel: Channel }) => {
|
|
|
59
60
|
/**
|
|
60
61
|
* This function loads the latest messages in the channel.
|
|
61
62
|
*/
|
|
62
|
-
const loadLatestMessages = async () => {
|
|
63
|
+
const loadLatestMessages = useStableCallback(async () => {
|
|
63
64
|
try {
|
|
64
65
|
setLoading(true);
|
|
65
66
|
await channel.state.loadMessageIntoState('latest');
|
|
@@ -68,12 +69,12 @@ export const useMessageListPagination = ({ channel }: { channel: Channel }) => {
|
|
|
68
69
|
} catch (err) {
|
|
69
70
|
console.warn('Loading latest messages failed with error:', err);
|
|
70
71
|
}
|
|
71
|
-
};
|
|
72
|
+
});
|
|
72
73
|
|
|
73
74
|
/**
|
|
74
75
|
* This function loads more messages before the first message in current channel state.
|
|
75
76
|
*/
|
|
76
|
-
const loadMore = async (limit = 20) => {
|
|
77
|
+
const loadMore = useStableCallback(async (limit: number = 20) => {
|
|
77
78
|
if (!channel.state.messagePagination.hasPrev) {
|
|
78
79
|
return;
|
|
79
80
|
}
|
|
@@ -97,12 +98,12 @@ export const useMessageListPagination = ({ channel }: { channel: Channel }) => {
|
|
|
97
98
|
setLoadingMore(false);
|
|
98
99
|
console.warn('Message pagination(fetching old messages) request failed with error:', e);
|
|
99
100
|
}
|
|
100
|
-
};
|
|
101
|
+
});
|
|
101
102
|
|
|
102
103
|
/**
|
|
103
104
|
* This function loads more messages after the most recent message in current channel state.
|
|
104
105
|
*/
|
|
105
|
-
const loadMoreRecent = async (limit = 10) => {
|
|
106
|
+
const loadMoreRecent = useStableCallback(async (limit: number = 10) => {
|
|
106
107
|
if (!channel.state.messagePagination.hasNext) {
|
|
107
108
|
return;
|
|
108
109
|
}
|
|
@@ -126,180 +127,179 @@ export const useMessageListPagination = ({ channel }: { channel: Channel }) => {
|
|
|
126
127
|
console.warn('Message pagination(fetching new messages) request failed with error:', e);
|
|
127
128
|
return;
|
|
128
129
|
}
|
|
129
|
-
};
|
|
130
|
+
});
|
|
130
131
|
|
|
131
132
|
/**
|
|
132
133
|
* Loads channel around a specific message
|
|
133
134
|
*
|
|
134
135
|
* @param messageId If undefined, channel will be loaded at most recent message.
|
|
135
136
|
*/
|
|
136
|
-
const loadChannelAroundMessage: ChannelContextValue['loadChannelAroundMessage'] =
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
loadMoreFinished(channel.state.messagePagination.hasPrev, channel.state.messages);
|
|
149
|
-
jumpToMessageFinished(channel.state.messagePagination.hasNext, messageIdToLoadAround);
|
|
137
|
+
const loadChannelAroundMessage: ChannelContextValue['loadChannelAroundMessage'] =
|
|
138
|
+
useStableCallback(
|
|
139
|
+
async ({ limit = 25, messageId: messageIdToLoadAround, setTargetedMessage }) => {
|
|
140
|
+
if (!messageIdToLoadAround) {
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
setLoadingMore(true);
|
|
144
|
+
setLoading(true);
|
|
145
|
+
try {
|
|
146
|
+
await channel.state.loadMessageIntoState(messageIdToLoadAround, undefined, limit);
|
|
147
|
+
loadMoreFinished(channel.state.messagePagination.hasPrev, channel.state.messages);
|
|
148
|
+
jumpToMessageFinished(channel.state.messagePagination.hasNext, messageIdToLoadAround);
|
|
150
149
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
150
|
+
if (setTargetedMessage) {
|
|
151
|
+
setTargetedMessage(messageIdToLoadAround);
|
|
152
|
+
}
|
|
153
|
+
} catch (error) {
|
|
154
|
+
setLoadingMore(false);
|
|
155
|
+
setLoading(false);
|
|
156
|
+
console.warn(
|
|
157
|
+
'Message pagination(fetching messages in the channel around a message id) request failed with error:',
|
|
158
|
+
error,
|
|
159
|
+
);
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
},
|
|
163
|
+
);
|
|
164
164
|
|
|
165
165
|
/**
|
|
166
166
|
* Fetch messages around a specific timestamp.
|
|
167
167
|
*/
|
|
168
|
-
const fetchMessagesAround =
|
|
169
|
-
channel: Channel,
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
}
|
|
183
|
-
};
|
|
168
|
+
const fetchMessagesAround = useStableCallback(
|
|
169
|
+
async (channel: Channel, timestamp: string, limit: number): Promise<MessageResponse[]> => {
|
|
170
|
+
try {
|
|
171
|
+
const { messages } = await channel.query(
|
|
172
|
+
{ messages: { created_at_around: timestamp, limit } },
|
|
173
|
+
'new',
|
|
174
|
+
);
|
|
175
|
+
return messages;
|
|
176
|
+
} catch (error) {
|
|
177
|
+
console.error('Error fetching messages around timestamp:', error);
|
|
178
|
+
throw error;
|
|
179
|
+
}
|
|
180
|
+
},
|
|
181
|
+
);
|
|
184
182
|
|
|
185
183
|
/**
|
|
186
184
|
* Loads channel at first unread message.
|
|
187
185
|
*/
|
|
188
186
|
const loadChannelAtFirstUnreadMessage: ChannelContextValue['loadChannelAtFirstUnreadMessage'] =
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
187
|
+
useStableCallback(
|
|
188
|
+
async ({ channelUnreadState, limit = 25, setChannelUnreadState, setTargetedMessage }) => {
|
|
189
|
+
try {
|
|
190
|
+
if (!channelUnreadState?.unread_messages) {
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
const { first_unread_message_id, last_read, last_read_message_id } = channelUnreadState;
|
|
194
|
+
let firstUnreadMessageId = first_unread_message_id;
|
|
195
|
+
let lastReadMessageId = last_read_message_id;
|
|
196
|
+
let isInCurrentMessageSet = false;
|
|
197
|
+
const messagesState = channel.state.messages;
|
|
199
198
|
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
} else {
|
|
211
|
-
const lastReadTimestamp = last_read.getTime();
|
|
212
|
-
const { index: lastReadIdx, message: lastReadMessage } = findInMessagesByDate(
|
|
213
|
-
messagesState,
|
|
214
|
-
last_read,
|
|
215
|
-
);
|
|
216
|
-
if (lastReadMessage) {
|
|
217
|
-
lastReadMessageId = lastReadMessage.id;
|
|
218
|
-
firstUnreadMessageId = messagesState[lastReadIdx + 1].id;
|
|
219
|
-
isInCurrentMessageSet = !!firstUnreadMessageId;
|
|
199
|
+
// If the first unread message is already in the current message set, we don't need to load more messages.
|
|
200
|
+
if (firstUnreadMessageId) {
|
|
201
|
+
const messageIdx = findInMessagesById(messagesState, firstUnreadMessageId);
|
|
202
|
+
isInCurrentMessageSet = messageIdx !== -1;
|
|
203
|
+
}
|
|
204
|
+
// If the last read message is already in the current message set, we don't need to load more messages, and we set the first unread message id as that is what we want to operate on.
|
|
205
|
+
else if (lastReadMessageId) {
|
|
206
|
+
const messageIdx = findInMessagesById(messagesState, lastReadMessageId);
|
|
207
|
+
isInCurrentMessageSet = messageIdx !== -1;
|
|
208
|
+
firstUnreadMessageId = messageIdx > -1 ? messagesState[messageIdx + 1]?.id : undefined;
|
|
220
209
|
} else {
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
210
|
+
const lastReadTimestamp = last_read.getTime();
|
|
211
|
+
const { index: lastReadIdx, message: lastReadMessage } = findInMessagesByDate(
|
|
212
|
+
messagesState,
|
|
213
|
+
last_read,
|
|
214
|
+
);
|
|
215
|
+
if (lastReadMessage) {
|
|
216
|
+
lastReadMessageId = lastReadMessage.id;
|
|
217
|
+
firstUnreadMessageId = messagesState[lastReadIdx + 1].id;
|
|
218
|
+
isInCurrentMessageSet = !!firstUnreadMessageId;
|
|
219
|
+
} else {
|
|
220
|
+
setLoadingMore(true);
|
|
221
|
+
setLoading(true);
|
|
222
|
+
let messages;
|
|
223
|
+
try {
|
|
224
|
+
messages = await fetchMessagesAround(channel, last_read.toISOString(), limit);
|
|
225
|
+
} catch (error) {
|
|
226
|
+
setLoading(false);
|
|
227
|
+
loadMoreFinished(channel.state.messagePagination.hasPrev, messagesState);
|
|
228
|
+
console.log('Loading channel at first unread message failed with error:', error);
|
|
229
|
+
return;
|
|
230
|
+
}
|
|
232
231
|
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
232
|
+
const firstMessageWithCreationDate = messages.find((msg) => msg.created_at);
|
|
233
|
+
if (!firstMessageWithCreationDate) {
|
|
234
|
+
loadMoreFinished(channel.state.messagePagination.hasPrev, channel.state.messages);
|
|
235
|
+
throw new Error('Failed to jump to first unread message id.');
|
|
236
|
+
}
|
|
237
|
+
const firstMessageTimestamp = new Date(
|
|
238
|
+
firstMessageWithCreationDate.created_at as string,
|
|
239
|
+
).getTime();
|
|
241
240
|
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
241
|
+
if (lastReadTimestamp < firstMessageTimestamp) {
|
|
242
|
+
// whole channel is unread
|
|
243
|
+
firstUnreadMessageId = firstMessageWithCreationDate.id;
|
|
244
|
+
} else {
|
|
245
|
+
const result = findInMessagesByDate(messages, last_read);
|
|
246
|
+
lastReadMessageId = result.message?.id;
|
|
247
|
+
}
|
|
248
|
+
loadMoreFinished(channel.state.messagePagination.hasPrev, channel.state.messages);
|
|
248
249
|
}
|
|
249
|
-
loadMoreFinished(channel.state.messagePagination.hasPrev, channel.state.messages);
|
|
250
250
|
}
|
|
251
|
-
}
|
|
252
251
|
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
252
|
+
// If we still don't have the first and last read message id, we can't proceed.
|
|
253
|
+
if (!firstUnreadMessageId && !lastReadMessageId) {
|
|
254
|
+
throw new Error('Failed to jump to first unread message id.');
|
|
255
|
+
}
|
|
257
256
|
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
257
|
+
// If the first unread message is not in the current message set, we need to load message around the id.
|
|
258
|
+
if (!isInCurrentMessageSet) {
|
|
259
|
+
try {
|
|
260
|
+
setLoadingMore(true);
|
|
261
|
+
setLoading(true);
|
|
262
|
+
const targetedMessage = (firstUnreadMessageId || lastReadMessageId) as string;
|
|
263
|
+
await channel.state.loadMessageIntoState(targetedMessage, undefined, limit);
|
|
264
|
+
/**
|
|
265
|
+
* if the index of the last read message on the page is beyond the half of the page,
|
|
266
|
+
* we have arrived to the oldest page of the channel
|
|
267
|
+
*/
|
|
268
|
+
const indexOfTarget = channel.state.messages.findIndex(
|
|
269
|
+
(message) => message.id === targetedMessage,
|
|
270
|
+
);
|
|
272
271
|
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
272
|
+
loadMoreFinished(channel.state.messagePagination.hasPrev, channel.state.messages);
|
|
273
|
+
firstUnreadMessageId =
|
|
274
|
+
firstUnreadMessageId ?? channel.state.messages[indexOfTarget + 1].id;
|
|
275
|
+
} catch (error) {
|
|
276
|
+
setLoading(false);
|
|
277
|
+
loadMoreFinished(channel.state.messagePagination.hasPrev, channel.state.messages);
|
|
278
|
+
console.log('Loading channel at first unread message failed with error:', error);
|
|
279
|
+
return;
|
|
280
|
+
}
|
|
281
281
|
}
|
|
282
|
-
}
|
|
283
282
|
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
283
|
+
if (!firstUnreadMessageId) {
|
|
284
|
+
throw new Error('Failed to jump to first unread message id.');
|
|
285
|
+
}
|
|
286
|
+
if (!first_unread_message_id && setChannelUnreadState) {
|
|
287
|
+
setChannelUnreadState({
|
|
288
|
+
...channelUnreadState,
|
|
289
|
+
first_unread_message_id: firstUnreadMessageId,
|
|
290
|
+
last_read_message_id: lastReadMessageId,
|
|
291
|
+
});
|
|
292
|
+
}
|
|
294
293
|
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
294
|
+
jumpToMessageFinished(channel.state.messagePagination.hasNext, firstUnreadMessageId);
|
|
295
|
+
if (setTargetedMessage) {
|
|
296
|
+
setTargetedMessage(firstUnreadMessageId);
|
|
297
|
+
}
|
|
298
|
+
} catch (error) {
|
|
299
|
+
console.log('Loading channel at first unread message failed with error:', error);
|
|
298
300
|
}
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
}
|
|
302
|
-
};
|
|
301
|
+
},
|
|
302
|
+
);
|
|
303
303
|
|
|
304
304
|
return {
|
|
305
305
|
copyMessagesStateFromChannel,
|
|
@@ -308,15 +308,6 @@ const ChatWithContext = (props: PropsWithChildren<ChatProps>) => {
|
|
|
308
308
|
* - connectionRecovering - whether or not websocket is reconnecting
|
|
309
309
|
* - isOnline - whether or not set user is active
|
|
310
310
|
* - setActiveChannel - function to set the currently active channel
|
|
311
|
-
*
|
|
312
|
-
* The Chat Component takes the following generics in order:
|
|
313
|
-
* - At (AttachmentType) - custom Attachment object extension
|
|
314
|
-
* - Ct (ChannelType) - custom Channel object extension
|
|
315
|
-
* - Co (CommandType) - custom Command string union extension
|
|
316
|
-
* - Ev (EventType) - custom Event object extension
|
|
317
|
-
* - Me (MessageType) - custom Message object extension
|
|
318
|
-
* - Re (ReactionType) - custom Reaction object extension
|
|
319
|
-
* - Us (UserType) - custom User object extension
|
|
320
311
|
*/
|
|
321
312
|
export const Chat = (props: PropsWithChildren<ChatProps>) => {
|
|
322
313
|
const { style } = useOverlayContext();
|
|
@@ -4,6 +4,8 @@ import type { SharedValue } from 'react-native-reanimated';
|
|
|
4
4
|
|
|
5
5
|
import { act, fireEvent, render, screen, waitFor } from '@testing-library/react-native';
|
|
6
6
|
|
|
7
|
+
import { LocalMessage } from 'stream-chat';
|
|
8
|
+
|
|
7
9
|
import {
|
|
8
10
|
ImageGalleryContext,
|
|
9
11
|
ImageGalleryContextValue,
|
|
@@ -18,7 +20,6 @@ import {
|
|
|
18
20
|
} from '../../../mock-builders/generator/attachment';
|
|
19
21
|
import { generateMessage } from '../../../mock-builders/generator/message';
|
|
20
22
|
|
|
21
|
-
import type { MessageType } from '../../MessageList/hooks/useMessageList';
|
|
22
23
|
import { ImageGallery } from '../ImageGallery';
|
|
23
24
|
|
|
24
25
|
jest.mock('../../../native.ts', () => {
|
|
@@ -56,7 +57,7 @@ describe('ImageGallery', () => {
|
|
|
56
57
|
generateVideoAttachment({ type: 'video' }),
|
|
57
58
|
],
|
|
58
59
|
}),
|
|
59
|
-
] as unknown as
|
|
60
|
+
] as unknown as LocalMessage[],
|
|
60
61
|
}),
|
|
61
62
|
);
|
|
62
63
|
|
|
@@ -73,7 +74,7 @@ describe('ImageGallery', () => {
|
|
|
73
74
|
});
|
|
74
75
|
render(
|
|
75
76
|
getComponent({
|
|
76
|
-
messages: [message] as unknown as
|
|
77
|
+
messages: [message] as unknown as LocalMessage[],
|
|
77
78
|
}),
|
|
78
79
|
);
|
|
79
80
|
|
|
@@ -102,7 +103,7 @@ describe('ImageGallery', () => {
|
|
|
102
103
|
generateMessage({
|
|
103
104
|
attachments: [generateVideoAttachment({ type: 'video' })],
|
|
104
105
|
}),
|
|
105
|
-
] as unknown as
|
|
106
|
+
] as unknown as LocalMessage[],
|
|
106
107
|
}),
|
|
107
108
|
);
|
|
108
109
|
|
|
@@ -128,7 +129,7 @@ describe('ImageGallery', () => {
|
|
|
128
129
|
|
|
129
130
|
render(
|
|
130
131
|
getComponent({
|
|
131
|
-
messages: [message] as unknown as
|
|
132
|
+
messages: [message] as unknown as LocalMessage[],
|
|
132
133
|
}),
|
|
133
134
|
);
|
|
134
135
|
|
|
@@ -163,7 +164,7 @@ describe('ImageGallery', () => {
|
|
|
163
164
|
generateMessage({
|
|
164
165
|
attachments: [generateVideoAttachment({ type: 'video' })],
|
|
165
166
|
}),
|
|
166
|
-
] as unknown as
|
|
167
|
+
] as unknown as LocalMessage[],
|
|
167
168
|
}),
|
|
168
169
|
);
|
|
169
170
|
|
|
@@ -193,7 +194,7 @@ describe('ImageGallery', () => {
|
|
|
193
194
|
});
|
|
194
195
|
render(
|
|
195
196
|
getComponent({
|
|
196
|
-
messages: [message] as unknown as
|
|
197
|
+
messages: [message] as unknown as LocalMessage[],
|
|
197
198
|
}),
|
|
198
199
|
);
|
|
199
200
|
|
|
@@ -7,6 +7,8 @@ import { ReactTestInstance } from 'react-test-renderer';
|
|
|
7
7
|
|
|
8
8
|
import { render, screen, userEvent, waitFor } from '@testing-library/react-native';
|
|
9
9
|
|
|
10
|
+
import { LocalMessage } from 'stream-chat';
|
|
11
|
+
|
|
10
12
|
import { Chat } from '../../../components/Chat/Chat';
|
|
11
13
|
import {
|
|
12
14
|
ImageGalleryContext,
|
|
@@ -20,7 +22,6 @@ import {
|
|
|
20
22
|
import { generateMessage } from '../../../mock-builders/generator/message';
|
|
21
23
|
import { getTestClientWithUser } from '../../../mock-builders/mock';
|
|
22
24
|
import { NativeHandlers } from '../../../native';
|
|
23
|
-
import type { MessageType } from '../../MessageList/hooks/useMessageList';
|
|
24
25
|
import { ImageGallery, ImageGalleryCustomComponents } from '../ImageGallery';
|
|
25
26
|
|
|
26
27
|
jest.mock('../../../native.ts', () => {
|
|
@@ -76,7 +77,7 @@ describe('ImageGalleryFooter', () => {
|
|
|
76
77
|
generateMessage({
|
|
77
78
|
attachments: [generateVideoAttachment({ type: 'video' })],
|
|
78
79
|
}),
|
|
79
|
-
] as unknown as
|
|
80
|
+
] as unknown as LocalMessage[],
|
|
80
81
|
} as unknown as ImageGalleryContextValue
|
|
81
82
|
}
|
|
82
83
|
>
|
|
@@ -131,7 +132,7 @@ describe('ImageGalleryFooter', () => {
|
|
|
131
132
|
generateMessage({
|
|
132
133
|
attachments: [generateVideoAttachment({ type: 'video' })],
|
|
133
134
|
}),
|
|
134
|
-
] as unknown as
|
|
135
|
+
] as unknown as LocalMessage[],
|
|
135
136
|
} as unknown as ImageGalleryContextValue
|
|
136
137
|
}
|
|
137
138
|
>
|
|
@@ -174,7 +175,7 @@ describe('ImageGalleryFooter', () => {
|
|
|
174
175
|
generateMessage({
|
|
175
176
|
attachments: [generateImageAttachment()],
|
|
176
177
|
}),
|
|
177
|
-
] as unknown as
|
|
178
|
+
] as unknown as LocalMessage[],
|
|
178
179
|
} as unknown as ImageGalleryContextValue
|
|
179
180
|
}
|
|
180
181
|
>
|
|
@@ -7,6 +7,8 @@ import { act } from 'react-test-renderer';
|
|
|
7
7
|
|
|
8
8
|
import { render, screen, userEvent, waitFor } from '@testing-library/react-native';
|
|
9
9
|
|
|
10
|
+
import { LocalMessage } from 'stream-chat';
|
|
11
|
+
|
|
10
12
|
import { Chat } from '../../../components/Chat/Chat';
|
|
11
13
|
import {
|
|
12
14
|
ImageGalleryContext,
|
|
@@ -24,7 +26,6 @@ import {
|
|
|
24
26
|
import { generateMessage } from '../../../mock-builders/generator/message';
|
|
25
27
|
import { getTestClientWithUser } from '../../../mock-builders/mock';
|
|
26
28
|
|
|
27
|
-
import type { MessageType } from '../../MessageList/hooks/useMessageList';
|
|
28
29
|
import { ImageGallery, ImageGalleryCustomComponents } from '../ImageGallery';
|
|
29
30
|
|
|
30
31
|
jest.mock('../../../native.ts', () => {
|
|
@@ -71,7 +72,7 @@ describe('ImageGalleryHeader', () => {
|
|
|
71
72
|
generateMessage({
|
|
72
73
|
attachments: [generateImageAttachment()],
|
|
73
74
|
}),
|
|
74
|
-
] as unknown as
|
|
75
|
+
] as unknown as LocalMessage[],
|
|
75
76
|
} as unknown as ImageGalleryContextValue
|
|
76
77
|
}
|
|
77
78
|
>
|
|
@@ -118,7 +119,7 @@ describe('ImageGalleryHeader', () => {
|
|
|
118
119
|
generateMessage({
|
|
119
120
|
attachments: [generateVideoAttachment({ type: 'video' })],
|
|
120
121
|
}),
|
|
121
|
-
] as unknown as
|
|
122
|
+
] as unknown as LocalMessage[],
|
|
122
123
|
} as unknown as ImageGalleryContextValue
|
|
123
124
|
}
|
|
124
125
|
>
|
|
@@ -158,7 +159,7 @@ describe('ImageGalleryHeader', () => {
|
|
|
158
159
|
generateMessage({
|
|
159
160
|
attachments: [generateImageAttachment()],
|
|
160
161
|
}),
|
|
161
|
-
] as unknown as
|
|
162
|
+
] as unknown as LocalMessage[],
|
|
162
163
|
} as unknown as ImageGalleryContextValue
|
|
163
164
|
}
|
|
164
165
|
>
|
|
@@ -7,6 +7,8 @@ import { act } from 'react-test-renderer';
|
|
|
7
7
|
|
|
8
8
|
import { fireEvent, render, waitFor } from '@testing-library/react-native';
|
|
9
9
|
|
|
10
|
+
import { LocalMessage } from 'stream-chat';
|
|
11
|
+
|
|
10
12
|
import { Chat } from '../../../components/Chat/Chat';
|
|
11
13
|
import {
|
|
12
14
|
ImageGalleryContext,
|
|
@@ -20,7 +22,6 @@ import { generateImageAttachment } from '../../../mock-builders/generator/attach
|
|
|
20
22
|
import { generateMessage } from '../../../mock-builders/generator/message';
|
|
21
23
|
import { getTestClientWithUser } from '../../../mock-builders/mock';
|
|
22
24
|
|
|
23
|
-
import type { MessageType } from '../../MessageList/hooks/useMessageList';
|
|
24
25
|
import { ImageGalleryOverlay } from '../components/ImageGalleryOverlay';
|
|
25
26
|
|
|
26
27
|
describe('ImageGalleryOverlay', () => {
|
|
@@ -39,7 +40,7 @@ describe('ImageGalleryOverlay', () => {
|
|
|
39
40
|
generateMessage({
|
|
40
41
|
attachments: [generateImageAttachment()],
|
|
41
42
|
}),
|
|
42
|
-
] as unknown as
|
|
43
|
+
] as unknown as LocalMessage[],
|
|
43
44
|
} as unknown as ImageGalleryContextValue
|
|
44
45
|
}
|
|
45
46
|
>
|