stream-chat-react-native-core 5.5.1-beta.1 → 5.6.0-beta.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/lib/commonjs/components/Attachment/Attachment.js +1 -1
- package/lib/commonjs/components/Attachment/AttachmentActions.js +1 -1
- package/lib/commonjs/components/Attachment/AudioAttachment.js +1 -1
- package/lib/commonjs/components/Attachment/Card.js +1 -1
- package/lib/commonjs/components/Attachment/FileAttachment.js +1 -1
- package/lib/commonjs/components/Attachment/FileAttachmentGroup.js +1 -1
- package/lib/commonjs/components/Attachment/FileIcon.js +1 -1
- package/lib/commonjs/components/Attachment/Gallery.js +1 -1
- package/lib/commonjs/components/Attachment/GalleryImage.js +20 -4
- package/lib/commonjs/components/Attachment/GalleryImage.js.map +1 -1
- package/lib/commonjs/components/Attachment/Giphy.js +1 -1
- package/lib/commonjs/components/Attachment/ImageLoadingFailedIndicator.js +1 -1
- package/lib/commonjs/components/Attachment/ImageLoadingIndicator.js +1 -1
- package/lib/commonjs/components/Attachment/VideoThumbnail.js +1 -1
- package/lib/commonjs/components/AttachmentPicker/AttachmentPicker.js +1 -1
- package/lib/commonjs/components/AttachmentPicker/components/AttachmentPickerBottomSheetHandle.js +1 -1
- package/lib/commonjs/components/AttachmentPicker/components/AttachmentPickerError.js +1 -1
- package/lib/commonjs/components/AttachmentPicker/components/AttachmentPickerErrorImage.js +1 -1
- package/lib/commonjs/components/AttachmentPicker/components/AttachmentPickerItem.js +1 -1
- package/lib/commonjs/components/AttachmentPicker/components/AttachmentSelectionBar.js +1 -1
- package/lib/commonjs/components/AttachmentPicker/components/CameraSelectorIcon.js +1 -1
- package/lib/commonjs/components/AttachmentPicker/components/FileSelectorIcon.js +1 -1
- package/lib/commonjs/components/AttachmentPicker/components/ImageOverlaySelectedComponent.js +1 -1
- package/lib/commonjs/components/AttachmentPicker/components/ImageSelectorIcon.js +1 -1
- package/lib/commonjs/components/AutoCompleteInput/AutoCompleteInput.js +1 -1
- package/lib/commonjs/components/AutoCompleteInput/AutoCompleteSuggestionCommandIcon.js +1 -1
- package/lib/commonjs/components/AutoCompleteInput/AutoCompleteSuggestionHeader.js +1 -1
- package/lib/commonjs/components/AutoCompleteInput/AutoCompleteSuggestionItem.js +1 -1
- package/lib/commonjs/components/AutoCompleteInput/AutoCompleteSuggestionList.js +1 -1
- package/lib/commonjs/components/Avatar/Avatar.js +1 -1
- package/lib/commonjs/components/Avatar/GroupAvatar.js +1 -1
- package/lib/commonjs/components/Channel/Channel.js +537 -155
- package/lib/commonjs/components/Channel/Channel.js.map +1 -1
- package/lib/commonjs/components/Channel/hooks/useCreateMessagesContext.js +6 -0
- package/lib/commonjs/components/Channel/hooks/useCreateMessagesContext.js.map +1 -1
- package/lib/commonjs/components/ChannelList/ChannelList.js +5 -16
- package/lib/commonjs/components/ChannelList/ChannelList.js.map +1 -1
- package/lib/commonjs/components/ChannelList/ChannelListFooterLoadingIndicator.js +1 -1
- package/lib/commonjs/components/ChannelList/ChannelListHeaderErrorIndicator.js +1 -1
- package/lib/commonjs/components/ChannelList/ChannelListHeaderNetworkDownIndicator.js +1 -1
- package/lib/commonjs/components/ChannelList/ChannelListLoadingIndicator.js +1 -1
- package/lib/commonjs/components/ChannelList/ChannelListMessenger.js +1 -1
- package/lib/commonjs/components/ChannelList/Skeleton.js +1 -1
- package/lib/commonjs/components/ChannelList/hooks/usePaginatedChannels.js +112 -42
- package/lib/commonjs/components/ChannelList/hooks/usePaginatedChannels.js.map +1 -1
- package/lib/commonjs/components/ChannelPreview/ChannelAvatar.js +1 -1
- package/lib/commonjs/components/ChannelPreview/ChannelPreview.js +1 -1
- package/lib/commonjs/components/ChannelPreview/ChannelPreviewMessage.js +1 -1
- package/lib/commonjs/components/ChannelPreview/ChannelPreviewMessenger.js +1 -1
- package/lib/commonjs/components/ChannelPreview/ChannelPreviewMutedStatus.js +1 -1
- package/lib/commonjs/components/ChannelPreview/ChannelPreviewStatus.js +1 -1
- package/lib/commonjs/components/ChannelPreview/ChannelPreviewTitle.js +1 -1
- package/lib/commonjs/components/ChannelPreview/ChannelPreviewUnreadCount.js +1 -1
- package/lib/commonjs/components/Chat/Chat.js +17 -21
- package/lib/commonjs/components/Chat/Chat.js.map +1 -1
- package/lib/commonjs/components/Chat/hooks/useCreateChatContext.js +2 -4
- package/lib/commonjs/components/Chat/hooks/useCreateChatContext.js.map +1 -1
- package/lib/commonjs/components/ImageBackground.js +1 -1
- package/lib/commonjs/components/ImageGallery/ImageGallery.js +1 -1
- package/lib/commonjs/components/ImageGallery/components/AnimatedGalleryImage.js +1 -1
- package/lib/commonjs/components/ImageGallery/components/AnimatedGalleryVideo.js +1 -1
- package/lib/commonjs/components/ImageGallery/components/ImageGalleryFooter.js +1 -1
- package/lib/commonjs/components/ImageGallery/components/ImageGalleryHeader.js +1 -1
- package/lib/commonjs/components/ImageGallery/components/ImageGalleryOverlay.js +1 -1
- package/lib/commonjs/components/ImageGallery/components/ImageGalleryVideoControl.js +1 -1
- package/lib/commonjs/components/ImageGallery/components/ImageGrid.js +1 -1
- package/lib/commonjs/components/ImageGallery/components/ImageGridHandle.js +1 -1
- package/lib/commonjs/components/Indicators/EmptyStateIndicator.js +1 -1
- package/lib/commonjs/components/Indicators/LoadingDot.js +1 -1
- package/lib/commonjs/components/Indicators/LoadingDots.js +1 -1
- package/lib/commonjs/components/Indicators/LoadingErrorIndicator.js +1 -1
- package/lib/commonjs/components/Indicators/LoadingIndicator.js +1 -1
- package/lib/commonjs/components/KeyboardCompatibleView/KeyboardCompatibleView.js +1 -1
- package/lib/commonjs/components/KeyboardCompatibleView/KeyboardCompatibleViewFC.js +1 -1
- package/lib/commonjs/components/Message/Message.js +22 -11
- package/lib/commonjs/components/Message/Message.js.map +1 -1
- package/lib/commonjs/components/Message/MessageSimple/MessageAvatar.js +1 -1
- package/lib/commonjs/components/Message/MessageSimple/MessageContent.js +1 -1
- package/lib/commonjs/components/Message/MessageSimple/MessageDeleted.js +1 -1
- package/lib/commonjs/components/Message/MessageSimple/MessageFooter.js +15 -13
- package/lib/commonjs/components/Message/MessageSimple/MessageFooter.js.map +1 -1
- package/lib/commonjs/components/Message/MessageSimple/MessagePinnedHeader.js +1 -1
- package/lib/commonjs/components/Message/MessageSimple/MessageReplies.js +1 -1
- package/lib/commonjs/components/Message/MessageSimple/MessageRepliesAvatars.js +1 -1
- package/lib/commonjs/components/Message/MessageSimple/MessageSimple.js +1 -1
- package/lib/commonjs/components/Message/MessageSimple/MessageStatus.js +1 -1
- package/lib/commonjs/components/Message/MessageSimple/MessageTextContainer.js +1 -1
- package/lib/commonjs/components/Message/MessageSimple/ReactionList.js +1 -1
- package/lib/commonjs/components/Message/MessageSimple/utils/renderText.js +1 -1
- package/lib/commonjs/components/Message/MessageSimple/utils/renderText.test.js +1 -1
- package/lib/commonjs/components/Message/hooks/useMessageActionHandlers.js +9 -30
- package/lib/commonjs/components/Message/hooks/useMessageActionHandlers.js.map +1 -1
- package/lib/commonjs/components/Message/hooks/useMessageActions.js +20 -18
- package/lib/commonjs/components/Message/hooks/useMessageActions.js.map +1 -1
- package/lib/commonjs/components/MessageInput/AttachButton.js +1 -1
- package/lib/commonjs/components/MessageInput/CommandsButton.js +1 -1
- package/lib/commonjs/components/MessageInput/CooldownTimer.js +1 -1
- package/lib/commonjs/components/MessageInput/FileUploadPreview.js +32 -22
- package/lib/commonjs/components/MessageInput/FileUploadPreview.js.map +1 -1
- package/lib/commonjs/components/MessageInput/ImageUploadPreview.js +52 -20
- package/lib/commonjs/components/MessageInput/ImageUploadPreview.js.map +1 -1
- package/lib/commonjs/components/MessageInput/InputButtons.js +1 -1
- package/lib/commonjs/components/MessageInput/MessageInput.js +40 -28
- package/lib/commonjs/components/MessageInput/MessageInput.js.map +1 -1
- package/lib/commonjs/components/MessageInput/MoreOptionsButton.js +1 -1
- package/lib/commonjs/components/MessageInput/SendButton.js +2 -2
- package/lib/commonjs/components/MessageInput/SendButton.js.map +1 -1
- package/lib/commonjs/components/MessageInput/SendMessageDisallowedIndicator.js +1 -1
- package/lib/commonjs/components/MessageInput/ShowThreadMessageInChannelButton.js +1 -1
- package/lib/commonjs/components/MessageInput/UploadProgressIndicator.js +1 -1
- package/lib/commonjs/components/MessageInput/components/InputEditingStateHeader.js +1 -1
- package/lib/commonjs/components/MessageInput/components/InputGiphySearch.js +1 -1
- package/lib/commonjs/components/MessageInput/components/InputReplyStateHeader.js +1 -1
- package/lib/commonjs/components/MessageList/DateHeader.js +1 -1
- package/lib/commonjs/components/MessageList/InlineDateSeparator.js +1 -1
- package/lib/commonjs/components/MessageList/InlineLoadingMoreIndicator.js +1 -1
- package/lib/commonjs/components/MessageList/InlineLoadingMoreRecentIndicator.js +1 -1
- package/lib/commonjs/components/MessageList/InlineLoadingMoreThreadIndicator.js +1 -1
- package/lib/commonjs/components/MessageList/InlineUnreadIndicator.js +1 -1
- package/lib/commonjs/components/MessageList/MessageList.js +1 -1
- package/lib/commonjs/components/MessageList/MessageSystem.js +1 -1
- package/lib/commonjs/components/MessageList/NetworkDownIndicator.js +1 -1
- package/lib/commonjs/components/MessageList/ScrollToBottomButton.js +1 -1
- package/lib/commonjs/components/MessageList/TypingIndicator.js +1 -1
- package/lib/commonjs/components/MessageList/TypingIndicatorContainer.js +1 -1
- package/lib/commonjs/components/MessageOverlay/MessageActionList.js +1 -1
- package/lib/commonjs/components/MessageOverlay/MessageActionListItem.js +1 -1
- package/lib/commonjs/components/MessageOverlay/MessageOverlay.js +1 -1
- package/lib/commonjs/components/MessageOverlay/OverlayBackdrop.js +1 -1
- package/lib/commonjs/components/MessageOverlay/OverlayReactionList.js +1 -1
- package/lib/commonjs/components/MessageOverlay/OverlayReactions.js +1 -1
- package/lib/commonjs/components/MessageOverlay/OverlayReactionsAvatar.js +1 -1
- package/lib/commonjs/components/ProgressControl/ProgressControl.js +1 -1
- package/lib/commonjs/components/RTLComponents/WritingDirectionAwareText.js +1 -1
- package/lib/commonjs/components/Reply/Reply.js +1 -1
- package/lib/commonjs/components/Spinner/Spinner.js +1 -1
- package/lib/commonjs/components/Thread/Thread.js +1 -1
- package/lib/commonjs/components/Thread/components/ThreadFooterComponent.js +1 -1
- package/lib/commonjs/components/index.js +0 -13
- package/lib/commonjs/components/index.js.map +1 -1
- package/lib/commonjs/contexts/activeChannelsRefContext/ActiveChannelsRefContext.js +1 -1
- package/lib/commonjs/contexts/attachmentPickerContext/AttachmentPickerContext.js +1 -1
- package/lib/commonjs/contexts/channelContext/ChannelContext.js +1 -1
- package/lib/commonjs/contexts/channelsContext/ChannelsContext.js +1 -1
- package/lib/commonjs/contexts/channelsStateContext/ChannelsStateContext.js +1 -1
- package/lib/commonjs/contexts/chatContext/ChatContext.js +3 -3
- package/lib/commonjs/contexts/chatContext/ChatContext.js.map +1 -1
- package/lib/commonjs/contexts/debugContext/DebugContext.js +1 -1
- package/lib/commonjs/contexts/imageGalleryContext/ImageGalleryContext.js +1 -1
- package/lib/commonjs/contexts/keyboardContext/KeyboardContext.js +1 -1
- package/lib/commonjs/contexts/messageContext/MessageContext.js +1 -1
- package/lib/commonjs/contexts/messageInputContext/MessageInputContext.js +23 -14
- package/lib/commonjs/contexts/messageInputContext/MessageInputContext.js.map +1 -1
- package/lib/commonjs/contexts/messageOverlayContext/MessageOverlayContext.js +1 -1
- package/lib/commonjs/contexts/messageOverlayContext/hooks/useResettableState.test.js +1 -1
- package/lib/commonjs/contexts/messagesContext/MessagesContext.js +3 -3
- package/lib/commonjs/contexts/messagesContext/MessagesContext.js.map +1 -1
- package/lib/commonjs/contexts/overlayContext/OverlayContext.js +1 -1
- package/lib/commonjs/contexts/overlayContext/OverlayProvider.js +1 -1
- package/lib/commonjs/contexts/ownCapabilitiesContext/OwnCapabilitiesContext.js +1 -1
- package/lib/commonjs/contexts/paginatedMessageListContext/PaginatedMessageListContext.js +1 -1
- package/lib/commonjs/contexts/suggestionsContext/SuggestionsContext.js +1 -1
- package/lib/commonjs/contexts/themeContext/ThemeContext.js +1 -1
- package/lib/commonjs/contexts/threadContext/ThreadContext.js +1 -1
- package/lib/commonjs/contexts/translationContext/TranslationContext.js +1 -1
- package/lib/commonjs/contexts/typingContext/TypingContext.js +1 -1
- package/lib/commonjs/hooks/useTranslatedMessage.js +1 -1
- package/lib/commonjs/hooks/useTranslatedMessage.js.map +1 -1
- package/lib/commonjs/icons/ArrowRight.js +1 -1
- package/lib/commonjs/icons/AtMentions.js +1 -1
- package/lib/commonjs/icons/Attach.js +1 -1
- package/lib/commonjs/icons/Audio.js +1 -1
- package/lib/commonjs/icons/CSV.js +1 -1
- package/lib/commonjs/icons/Camera.js +1 -1
- package/lib/commonjs/icons/Check.js +1 -1
- package/lib/commonjs/icons/CheckAll.js +1 -1
- package/lib/commonjs/icons/CheckSend.js +1 -1
- package/lib/commonjs/icons/CircleClose.js +1 -1
- package/lib/commonjs/icons/CirclePlus.js +1 -1
- package/lib/commonjs/icons/CircleRight.js +1 -1
- package/lib/commonjs/icons/Close.js +1 -1
- package/lib/commonjs/icons/Copy.js +1 -1
- package/lib/commonjs/icons/CurveLineLeftUp.js +1 -1
- package/lib/commonjs/icons/DOC.js +1 -1
- package/lib/commonjs/icons/DOCX.js +1 -1
- package/lib/commonjs/icons/Delete.js +1 -1
- package/lib/commonjs/icons/Down.js +1 -1
- package/lib/commonjs/icons/DownloadArrow.js +1 -1
- package/lib/commonjs/icons/DownloadCloud.js +1 -1
- package/lib/commonjs/icons/Edit.js +1 -1
- package/lib/commonjs/icons/Error.js +1 -1
- package/lib/commonjs/icons/Eye.js +1 -1
- package/lib/commonjs/icons/Flag.js +1 -1
- package/lib/commonjs/icons/Folder.js +1 -1
- package/lib/commonjs/icons/GenericFile.js +1 -1
- package/lib/commonjs/icons/GiphyIcon.js +1 -1
- package/lib/commonjs/icons/Grid.js +1 -1
- package/lib/commonjs/icons/Group.js +1 -1
- package/lib/commonjs/icons/HTML.js +1 -1
- package/lib/commonjs/icons/Imgur.js +1 -1
- package/lib/commonjs/icons/LOLReaction.js +1 -1
- package/lib/commonjs/icons/Lightning.js +1 -1
- package/lib/commonjs/icons/Link.js +1 -1
- package/lib/commonjs/icons/Loading.js +1 -1
- package/lib/commonjs/icons/Logo.js +1 -1
- package/lib/commonjs/icons/LoveReaction.js +1 -1
- package/lib/commonjs/icons/MD.js +1 -1
- package/lib/commonjs/icons/MailOpen.js +1 -1
- package/lib/commonjs/icons/MenuPointHorizontal.js +1 -1
- package/lib/commonjs/icons/MenuPointVertical.js +1 -1
- package/lib/commonjs/icons/MessageFlag.js +1 -1
- package/lib/commonjs/icons/MessageIcon.js +1 -1
- package/lib/commonjs/icons/Mute.js +1 -1
- package/lib/commonjs/icons/Notification.js +1 -1
- package/lib/commonjs/icons/ODT.js +1 -1
- package/lib/commonjs/icons/PDF.js +1 -1
- package/lib/commonjs/icons/PPT.js +1 -1
- package/lib/commonjs/icons/PPTX.js +1 -1
- package/lib/commonjs/icons/Pause.js +1 -1
- package/lib/commonjs/icons/Picture.js +1 -1
- package/lib/commonjs/icons/Pin.js +1 -1
- package/lib/commonjs/icons/PinHeader.js +1 -1
- package/lib/commonjs/icons/Play.js +1 -1
- package/lib/commonjs/icons/RAR.js +1 -1
- package/lib/commonjs/icons/RTF.js +1 -1
- package/lib/commonjs/icons/Recorder.js +1 -1
- package/lib/commonjs/icons/Refresh.js +1 -1
- package/lib/commonjs/icons/SEVEN_Z.js +1 -1
- package/lib/commonjs/icons/Search.js +1 -1
- package/lib/commonjs/icons/SendRight.js +1 -1
- package/lib/commonjs/icons/SendUp.js +1 -1
- package/lib/commonjs/icons/Share.js +1 -1
- package/lib/commonjs/icons/ShareRightArrow.js +1 -1
- package/lib/commonjs/icons/Smile.js +1 -1
- package/lib/commonjs/icons/Sound.js +1 -1
- package/lib/commonjs/icons/TAR.js +1 -1
- package/lib/commonjs/icons/TXT.js +1 -1
- package/lib/commonjs/icons/ThreadReply.js +1 -1
- package/lib/commonjs/icons/ThumbsDownReaction.js +1 -1
- package/lib/commonjs/icons/ThumbsUpReaction.js +1 -1
- package/lib/commonjs/icons/Time.js +1 -1
- package/lib/commonjs/icons/Unknown.js +1 -1
- package/lib/commonjs/icons/Unpin.js +1 -1
- package/lib/commonjs/icons/User.js +1 -1
- package/lib/commonjs/icons/UserAdd.js +1 -1
- package/lib/commonjs/icons/UserAdmin.js +1 -1
- package/lib/commonjs/icons/UserDelete.js +1 -1
- package/lib/commonjs/icons/UserMinus.js +1 -1
- package/lib/commonjs/icons/Video.js +1 -1
- package/lib/commonjs/icons/Warning.js +1 -1
- package/lib/commonjs/icons/WutReaction.js +1 -1
- package/lib/commonjs/icons/XLS.js +1 -1
- package/lib/commonjs/icons/XLSX.js +1 -1
- package/lib/commonjs/icons/ZIP.js +1 -1
- package/lib/commonjs/icons/utils/base.js +1 -1
- package/lib/commonjs/mock-builders/DB/mock.js +2 -2
- package/lib/commonjs/mock-builders/DB/mock.js.map +1 -1
- package/lib/commonjs/mock-builders/api/deleteMessage.js +20 -0
- package/lib/commonjs/mock-builders/api/deleteMessage.js.map +1 -0
- package/lib/commonjs/mock-builders/api/deleteReaction.js +21 -0
- package/lib/commonjs/mock-builders/api/deleteReaction.js.map +1 -0
- package/lib/commonjs/mock-builders/api/sendReaction.js +21 -0
- package/lib/commonjs/mock-builders/api/sendReaction.js.map +1 -0
- package/lib/commonjs/mock-builders/event/connectionChanged.js +2 -0
- package/lib/commonjs/mock-builders/event/connectionChanged.js.map +1 -1
- package/lib/commonjs/store/QuickSqliteClient.js +40 -51
- package/lib/commonjs/store/QuickSqliteClient.js.map +1 -1
- package/lib/commonjs/store/apis/addPendingTask.js +37 -0
- package/lib/commonjs/store/apis/addPendingTask.js.map +1 -0
- package/lib/commonjs/store/apis/deleteMessage.js +26 -0
- package/lib/commonjs/store/apis/deleteMessage.js.map +1 -0
- package/lib/commonjs/store/apis/deletePendingTask.js +22 -0
- package/lib/commonjs/store/apis/deletePendingTask.js.map +1 -0
- package/lib/commonjs/store/apis/deleteReaction.js +30 -0
- package/lib/commonjs/store/apis/deleteReaction.js.map +1 -0
- package/lib/commonjs/store/apis/getChannelMessages.js +3 -3
- package/lib/commonjs/store/apis/getChannelMessages.js.map +1 -1
- package/lib/commonjs/store/apis/getChannels.js +1 -1
- package/lib/commonjs/store/apis/getChannels.js.map +1 -1
- package/lib/commonjs/store/apis/getPendingTasks.js +26 -0
- package/lib/commonjs/store/apis/getPendingTasks.js.map +1 -0
- package/lib/commonjs/store/apis/index.js +13 -0
- package/lib/commonjs/store/apis/index.js.map +1 -1
- package/lib/commonjs/store/apis/insertReaction.js +28 -0
- package/lib/commonjs/store/apis/insertReaction.js.map +1 -0
- package/lib/commonjs/store/apis/updateMessage.js.map +1 -1
- package/lib/commonjs/store/apis/updateReaction.js.map +1 -1
- package/lib/commonjs/store/mappers/mapDateTimeToStorable.js.map +1 -1
- package/lib/commonjs/store/mappers/mapMessageToStorable.js +3 -1
- package/lib/commonjs/store/mappers/mapMessageToStorable.js.map +1 -1
- package/lib/commonjs/store/mappers/mapStorableToTask.js +23 -0
- package/lib/commonjs/store/mappers/mapStorableToTask.js.map +1 -0
- package/lib/commonjs/store/mappers/mapTaskToStorable.js +18 -0
- package/lib/commonjs/store/mappers/mapTaskToStorable.js.map +1 -0
- package/lib/commonjs/store/schema.js +11 -0
- package/lib/commonjs/store/schema.js.map +1 -1
- package/lib/commonjs/store/sqlite-utils/appendOrderByClause.js +24 -0
- package/lib/commonjs/store/sqlite-utils/appendOrderByClause.js.map +1 -0
- package/lib/commonjs/store/sqlite-utils/createCreateTableQuery.js +1 -1
- package/lib/commonjs/store/sqlite-utils/createCreateTableQuery.js.map +1 -1
- package/lib/commonjs/store/sqlite-utils/createSelectQuery.js +8 -1
- package/lib/commonjs/store/sqlite-utils/createSelectQuery.js.map +1 -1
- package/lib/commonjs/store/sqlite-utils/createUpdateQuery.js +2 -2
- package/lib/commonjs/store/sqlite-utils/createUpdateQuery.js.map +1 -1
- package/lib/commonjs/store/sqlite-utils/createUpsertQuery.js +1 -1
- package/lib/commonjs/store/sqlite-utils/createUpsertQuery.js.map +1 -1
- package/lib/commonjs/utils/DBSyncManager.js +436 -0
- package/lib/commonjs/utils/DBSyncManager.js.map +1 -0
- package/lib/commonjs/utils/addReactionToLocalState.js +92 -0
- package/lib/commonjs/utils/addReactionToLocalState.js.map +1 -0
- package/lib/commonjs/utils/pendingTaskUtils.js +302 -0
- package/lib/commonjs/utils/pendingTaskUtils.js.map +1 -0
- package/lib/commonjs/utils/removeReactionFromLocalState.js +39 -0
- package/lib/commonjs/utils/removeReactionFromLocalState.js.map +1 -0
- package/lib/commonjs/utils/utils.js +9 -3
- package/lib/commonjs/utils/utils.js.map +1 -1
- package/lib/commonjs/version.json +1 -1
- package/lib/module/components/Attachment/Attachment.js +1 -1
- package/lib/module/components/Attachment/AttachmentActions.js +1 -1
- package/lib/module/components/Attachment/AudioAttachment.js +1 -1
- package/lib/module/components/Attachment/Card.js +1 -1
- package/lib/module/components/Attachment/FileAttachment.js +1 -1
- package/lib/module/components/Attachment/FileAttachmentGroup.js +1 -1
- package/lib/module/components/Attachment/FileIcon.js +1 -1
- package/lib/module/components/Attachment/Gallery.js +1 -1
- package/lib/module/components/Attachment/GalleryImage.js +20 -4
- package/lib/module/components/Attachment/GalleryImage.js.map +1 -1
- package/lib/module/components/Attachment/Giphy.js +1 -1
- package/lib/module/components/Attachment/ImageLoadingFailedIndicator.js +1 -1
- package/lib/module/components/Attachment/ImageLoadingIndicator.js +1 -1
- package/lib/module/components/Attachment/VideoThumbnail.js +1 -1
- package/lib/module/components/AttachmentPicker/AttachmentPicker.js +1 -1
- package/lib/module/components/AttachmentPicker/components/AttachmentPickerBottomSheetHandle.js +1 -1
- package/lib/module/components/AttachmentPicker/components/AttachmentPickerError.js +1 -1
- package/lib/module/components/AttachmentPicker/components/AttachmentPickerErrorImage.js +1 -1
- package/lib/module/components/AttachmentPicker/components/AttachmentPickerItem.js +1 -1
- package/lib/module/components/AttachmentPicker/components/AttachmentSelectionBar.js +1 -1
- package/lib/module/components/AttachmentPicker/components/CameraSelectorIcon.js +1 -1
- package/lib/module/components/AttachmentPicker/components/FileSelectorIcon.js +1 -1
- package/lib/module/components/AttachmentPicker/components/ImageOverlaySelectedComponent.js +1 -1
- package/lib/module/components/AttachmentPicker/components/ImageSelectorIcon.js +1 -1
- package/lib/module/components/AutoCompleteInput/AutoCompleteInput.js +1 -1
- package/lib/module/components/AutoCompleteInput/AutoCompleteSuggestionCommandIcon.js +1 -1
- package/lib/module/components/AutoCompleteInput/AutoCompleteSuggestionHeader.js +1 -1
- package/lib/module/components/AutoCompleteInput/AutoCompleteSuggestionItem.js +1 -1
- package/lib/module/components/AutoCompleteInput/AutoCompleteSuggestionList.js +1 -1
- package/lib/module/components/Avatar/Avatar.js +1 -1
- package/lib/module/components/Avatar/GroupAvatar.js +1 -1
- package/lib/module/components/Channel/Channel.js +537 -155
- package/lib/module/components/Channel/Channel.js.map +1 -1
- package/lib/module/components/Channel/hooks/useCreateMessagesContext.js +6 -0
- package/lib/module/components/Channel/hooks/useCreateMessagesContext.js.map +1 -1
- package/lib/module/components/ChannelList/ChannelList.js +5 -16
- package/lib/module/components/ChannelList/ChannelList.js.map +1 -1
- package/lib/module/components/ChannelList/ChannelListFooterLoadingIndicator.js +1 -1
- package/lib/module/components/ChannelList/ChannelListHeaderErrorIndicator.js +1 -1
- package/lib/module/components/ChannelList/ChannelListHeaderNetworkDownIndicator.js +1 -1
- package/lib/module/components/ChannelList/ChannelListLoadingIndicator.js +1 -1
- package/lib/module/components/ChannelList/ChannelListMessenger.js +1 -1
- package/lib/module/components/ChannelList/Skeleton.js +1 -1
- package/lib/module/components/ChannelList/hooks/usePaginatedChannels.js +112 -42
- package/lib/module/components/ChannelList/hooks/usePaginatedChannels.js.map +1 -1
- package/lib/module/components/ChannelPreview/ChannelAvatar.js +1 -1
- package/lib/module/components/ChannelPreview/ChannelPreview.js +1 -1
- package/lib/module/components/ChannelPreview/ChannelPreviewMessage.js +1 -1
- package/lib/module/components/ChannelPreview/ChannelPreviewMessenger.js +1 -1
- package/lib/module/components/ChannelPreview/ChannelPreviewMutedStatus.js +1 -1
- package/lib/module/components/ChannelPreview/ChannelPreviewStatus.js +1 -1
- package/lib/module/components/ChannelPreview/ChannelPreviewTitle.js +1 -1
- package/lib/module/components/ChannelPreview/ChannelPreviewUnreadCount.js +1 -1
- package/lib/module/components/Chat/Chat.js +17 -21
- package/lib/module/components/Chat/Chat.js.map +1 -1
- package/lib/module/components/Chat/hooks/useCreateChatContext.js +2 -4
- package/lib/module/components/Chat/hooks/useCreateChatContext.js.map +1 -1
- package/lib/module/components/ImageBackground.js +1 -1
- package/lib/module/components/ImageGallery/ImageGallery.js +1 -1
- package/lib/module/components/ImageGallery/components/AnimatedGalleryImage.js +1 -1
- package/lib/module/components/ImageGallery/components/AnimatedGalleryVideo.js +1 -1
- package/lib/module/components/ImageGallery/components/ImageGalleryFooter.js +1 -1
- package/lib/module/components/ImageGallery/components/ImageGalleryHeader.js +1 -1
- package/lib/module/components/ImageGallery/components/ImageGalleryOverlay.js +1 -1
- package/lib/module/components/ImageGallery/components/ImageGalleryVideoControl.js +1 -1
- package/lib/module/components/ImageGallery/components/ImageGrid.js +1 -1
- package/lib/module/components/ImageGallery/components/ImageGridHandle.js +1 -1
- package/lib/module/components/Indicators/EmptyStateIndicator.js +1 -1
- package/lib/module/components/Indicators/LoadingDot.js +1 -1
- package/lib/module/components/Indicators/LoadingDots.js +1 -1
- package/lib/module/components/Indicators/LoadingErrorIndicator.js +1 -1
- package/lib/module/components/Indicators/LoadingIndicator.js +1 -1
- package/lib/module/components/KeyboardCompatibleView/KeyboardCompatibleView.js +1 -1
- package/lib/module/components/KeyboardCompatibleView/KeyboardCompatibleViewFC.js +1 -1
- package/lib/module/components/Message/Message.js +22 -11
- package/lib/module/components/Message/Message.js.map +1 -1
- package/lib/module/components/Message/MessageSimple/MessageAvatar.js +1 -1
- package/lib/module/components/Message/MessageSimple/MessageContent.js +1 -1
- package/lib/module/components/Message/MessageSimple/MessageDeleted.js +1 -1
- package/lib/module/components/Message/MessageSimple/MessageFooter.js +15 -13
- package/lib/module/components/Message/MessageSimple/MessageFooter.js.map +1 -1
- package/lib/module/components/Message/MessageSimple/MessagePinnedHeader.js +1 -1
- package/lib/module/components/Message/MessageSimple/MessageReplies.js +1 -1
- package/lib/module/components/Message/MessageSimple/MessageRepliesAvatars.js +1 -1
- package/lib/module/components/Message/MessageSimple/MessageSimple.js +1 -1
- package/lib/module/components/Message/MessageSimple/MessageStatus.js +1 -1
- package/lib/module/components/Message/MessageSimple/MessageTextContainer.js +1 -1
- package/lib/module/components/Message/MessageSimple/ReactionList.js +1 -1
- package/lib/module/components/Message/MessageSimple/utils/renderText.js +1 -1
- package/lib/module/components/Message/MessageSimple/utils/renderText.test.js +1 -1
- package/lib/module/components/Message/hooks/useMessageActionHandlers.js +9 -30
- package/lib/module/components/Message/hooks/useMessageActionHandlers.js.map +1 -1
- package/lib/module/components/Message/hooks/useMessageActions.js +20 -18
- package/lib/module/components/Message/hooks/useMessageActions.js.map +1 -1
- package/lib/module/components/MessageInput/AttachButton.js +1 -1
- package/lib/module/components/MessageInput/CommandsButton.js +1 -1
- package/lib/module/components/MessageInput/CooldownTimer.js +1 -1
- package/lib/module/components/MessageInput/FileUploadPreview.js +32 -22
- package/lib/module/components/MessageInput/FileUploadPreview.js.map +1 -1
- package/lib/module/components/MessageInput/ImageUploadPreview.js +52 -20
- package/lib/module/components/MessageInput/ImageUploadPreview.js.map +1 -1
- package/lib/module/components/MessageInput/InputButtons.js +1 -1
- package/lib/module/components/MessageInput/MessageInput.js +40 -28
- package/lib/module/components/MessageInput/MessageInput.js.map +1 -1
- package/lib/module/components/MessageInput/MoreOptionsButton.js +1 -1
- package/lib/module/components/MessageInput/SendButton.js +2 -2
- package/lib/module/components/MessageInput/SendButton.js.map +1 -1
- package/lib/module/components/MessageInput/SendMessageDisallowedIndicator.js +1 -1
- package/lib/module/components/MessageInput/ShowThreadMessageInChannelButton.js +1 -1
- package/lib/module/components/MessageInput/UploadProgressIndicator.js +1 -1
- package/lib/module/components/MessageInput/components/InputEditingStateHeader.js +1 -1
- package/lib/module/components/MessageInput/components/InputGiphySearch.js +1 -1
- package/lib/module/components/MessageInput/components/InputReplyStateHeader.js +1 -1
- package/lib/module/components/MessageList/DateHeader.js +1 -1
- package/lib/module/components/MessageList/InlineDateSeparator.js +1 -1
- package/lib/module/components/MessageList/InlineLoadingMoreIndicator.js +1 -1
- package/lib/module/components/MessageList/InlineLoadingMoreRecentIndicator.js +1 -1
- package/lib/module/components/MessageList/InlineLoadingMoreThreadIndicator.js +1 -1
- package/lib/module/components/MessageList/InlineUnreadIndicator.js +1 -1
- package/lib/module/components/MessageList/MessageList.js +1 -1
- package/lib/module/components/MessageList/MessageSystem.js +1 -1
- package/lib/module/components/MessageList/NetworkDownIndicator.js +1 -1
- package/lib/module/components/MessageList/ScrollToBottomButton.js +1 -1
- package/lib/module/components/MessageList/TypingIndicator.js +1 -1
- package/lib/module/components/MessageList/TypingIndicatorContainer.js +1 -1
- package/lib/module/components/MessageOverlay/MessageActionList.js +1 -1
- package/lib/module/components/MessageOverlay/MessageActionListItem.js +1 -1
- package/lib/module/components/MessageOverlay/MessageOverlay.js +1 -1
- package/lib/module/components/MessageOverlay/OverlayBackdrop.js +1 -1
- package/lib/module/components/MessageOverlay/OverlayReactionList.js +1 -1
- package/lib/module/components/MessageOverlay/OverlayReactions.js +1 -1
- package/lib/module/components/MessageOverlay/OverlayReactionsAvatar.js +1 -1
- package/lib/module/components/ProgressControl/ProgressControl.js +1 -1
- package/lib/module/components/RTLComponents/WritingDirectionAwareText.js +1 -1
- package/lib/module/components/Reply/Reply.js +1 -1
- package/lib/module/components/Spinner/Spinner.js +1 -1
- package/lib/module/components/Thread/Thread.js +1 -1
- package/lib/module/components/Thread/components/ThreadFooterComponent.js +1 -1
- package/lib/module/components/index.js +0 -13
- package/lib/module/components/index.js.map +1 -1
- package/lib/module/contexts/activeChannelsRefContext/ActiveChannelsRefContext.js +1 -1
- package/lib/module/contexts/attachmentPickerContext/AttachmentPickerContext.js +1 -1
- package/lib/module/contexts/channelContext/ChannelContext.js +1 -1
- package/lib/module/contexts/channelsContext/ChannelsContext.js +1 -1
- package/lib/module/contexts/channelsStateContext/ChannelsStateContext.js +1 -1
- package/lib/module/contexts/chatContext/ChatContext.js +3 -3
- package/lib/module/contexts/chatContext/ChatContext.js.map +1 -1
- package/lib/module/contexts/debugContext/DebugContext.js +1 -1
- package/lib/module/contexts/imageGalleryContext/ImageGalleryContext.js +1 -1
- package/lib/module/contexts/keyboardContext/KeyboardContext.js +1 -1
- package/lib/module/contexts/messageContext/MessageContext.js +1 -1
- package/lib/module/contexts/messageInputContext/MessageInputContext.js +23 -14
- package/lib/module/contexts/messageInputContext/MessageInputContext.js.map +1 -1
- package/lib/module/contexts/messageOverlayContext/MessageOverlayContext.js +1 -1
- package/lib/module/contexts/messageOverlayContext/hooks/useResettableState.test.js +1 -1
- package/lib/module/contexts/messagesContext/MessagesContext.js +3 -3
- package/lib/module/contexts/messagesContext/MessagesContext.js.map +1 -1
- package/lib/module/contexts/overlayContext/OverlayContext.js +1 -1
- package/lib/module/contexts/overlayContext/OverlayProvider.js +1 -1
- package/lib/module/contexts/ownCapabilitiesContext/OwnCapabilitiesContext.js +1 -1
- package/lib/module/contexts/paginatedMessageListContext/PaginatedMessageListContext.js +1 -1
- package/lib/module/contexts/suggestionsContext/SuggestionsContext.js +1 -1
- package/lib/module/contexts/themeContext/ThemeContext.js +1 -1
- package/lib/module/contexts/threadContext/ThreadContext.js +1 -1
- package/lib/module/contexts/translationContext/TranslationContext.js +1 -1
- package/lib/module/contexts/typingContext/TypingContext.js +1 -1
- package/lib/module/hooks/useTranslatedMessage.js +1 -1
- package/lib/module/hooks/useTranslatedMessage.js.map +1 -1
- package/lib/module/icons/ArrowRight.js +1 -1
- package/lib/module/icons/AtMentions.js +1 -1
- package/lib/module/icons/Attach.js +1 -1
- package/lib/module/icons/Audio.js +1 -1
- package/lib/module/icons/CSV.js +1 -1
- package/lib/module/icons/Camera.js +1 -1
- package/lib/module/icons/Check.js +1 -1
- package/lib/module/icons/CheckAll.js +1 -1
- package/lib/module/icons/CheckSend.js +1 -1
- package/lib/module/icons/CircleClose.js +1 -1
- package/lib/module/icons/CirclePlus.js +1 -1
- package/lib/module/icons/CircleRight.js +1 -1
- package/lib/module/icons/Close.js +1 -1
- package/lib/module/icons/Copy.js +1 -1
- package/lib/module/icons/CurveLineLeftUp.js +1 -1
- package/lib/module/icons/DOC.js +1 -1
- package/lib/module/icons/DOCX.js +1 -1
- package/lib/module/icons/Delete.js +1 -1
- package/lib/module/icons/Down.js +1 -1
- package/lib/module/icons/DownloadArrow.js +1 -1
- package/lib/module/icons/DownloadCloud.js +1 -1
- package/lib/module/icons/Edit.js +1 -1
- package/lib/module/icons/Error.js +1 -1
- package/lib/module/icons/Eye.js +1 -1
- package/lib/module/icons/Flag.js +1 -1
- package/lib/module/icons/Folder.js +1 -1
- package/lib/module/icons/GenericFile.js +1 -1
- package/lib/module/icons/GiphyIcon.js +1 -1
- package/lib/module/icons/Grid.js +1 -1
- package/lib/module/icons/Group.js +1 -1
- package/lib/module/icons/HTML.js +1 -1
- package/lib/module/icons/Imgur.js +1 -1
- package/lib/module/icons/LOLReaction.js +1 -1
- package/lib/module/icons/Lightning.js +1 -1
- package/lib/module/icons/Link.js +1 -1
- package/lib/module/icons/Loading.js +1 -1
- package/lib/module/icons/Logo.js +1 -1
- package/lib/module/icons/LoveReaction.js +1 -1
- package/lib/module/icons/MD.js +1 -1
- package/lib/module/icons/MailOpen.js +1 -1
- package/lib/module/icons/MenuPointHorizontal.js +1 -1
- package/lib/module/icons/MenuPointVertical.js +1 -1
- package/lib/module/icons/MessageFlag.js +1 -1
- package/lib/module/icons/MessageIcon.js +1 -1
- package/lib/module/icons/Mute.js +1 -1
- package/lib/module/icons/Notification.js +1 -1
- package/lib/module/icons/ODT.js +1 -1
- package/lib/module/icons/PDF.js +1 -1
- package/lib/module/icons/PPT.js +1 -1
- package/lib/module/icons/PPTX.js +1 -1
- package/lib/module/icons/Pause.js +1 -1
- package/lib/module/icons/Picture.js +1 -1
- package/lib/module/icons/Pin.js +1 -1
- package/lib/module/icons/PinHeader.js +1 -1
- package/lib/module/icons/Play.js +1 -1
- package/lib/module/icons/RAR.js +1 -1
- package/lib/module/icons/RTF.js +1 -1
- package/lib/module/icons/Recorder.js +1 -1
- package/lib/module/icons/Refresh.js +1 -1
- package/lib/module/icons/SEVEN_Z.js +1 -1
- package/lib/module/icons/Search.js +1 -1
- package/lib/module/icons/SendRight.js +1 -1
- package/lib/module/icons/SendUp.js +1 -1
- package/lib/module/icons/Share.js +1 -1
- package/lib/module/icons/ShareRightArrow.js +1 -1
- package/lib/module/icons/Smile.js +1 -1
- package/lib/module/icons/Sound.js +1 -1
- package/lib/module/icons/TAR.js +1 -1
- package/lib/module/icons/TXT.js +1 -1
- package/lib/module/icons/ThreadReply.js +1 -1
- package/lib/module/icons/ThumbsDownReaction.js +1 -1
- package/lib/module/icons/ThumbsUpReaction.js +1 -1
- package/lib/module/icons/Time.js +1 -1
- package/lib/module/icons/Unknown.js +1 -1
- package/lib/module/icons/Unpin.js +1 -1
- package/lib/module/icons/User.js +1 -1
- package/lib/module/icons/UserAdd.js +1 -1
- package/lib/module/icons/UserAdmin.js +1 -1
- package/lib/module/icons/UserDelete.js +1 -1
- package/lib/module/icons/UserMinus.js +1 -1
- package/lib/module/icons/Video.js +1 -1
- package/lib/module/icons/Warning.js +1 -1
- package/lib/module/icons/WutReaction.js +1 -1
- package/lib/module/icons/XLS.js +1 -1
- package/lib/module/icons/XLSX.js +1 -1
- package/lib/module/icons/ZIP.js +1 -1
- package/lib/module/icons/utils/base.js +1 -1
- package/lib/module/mock-builders/DB/mock.js +2 -2
- package/lib/module/mock-builders/DB/mock.js.map +1 -1
- package/lib/module/mock-builders/api/deleteMessage.js +20 -0
- package/lib/module/mock-builders/api/deleteMessage.js.map +1 -0
- package/lib/module/mock-builders/api/deleteReaction.js +21 -0
- package/lib/module/mock-builders/api/deleteReaction.js.map +1 -0
- package/lib/module/mock-builders/api/sendReaction.js +21 -0
- package/lib/module/mock-builders/api/sendReaction.js.map +1 -0
- package/lib/module/mock-builders/event/connectionChanged.js +2 -0
- package/lib/module/mock-builders/event/connectionChanged.js.map +1 -1
- package/lib/module/store/QuickSqliteClient.js +40 -51
- package/lib/module/store/QuickSqliteClient.js.map +1 -1
- package/lib/module/store/apis/addPendingTask.js +37 -0
- package/lib/module/store/apis/addPendingTask.js.map +1 -0
- package/lib/module/store/apis/deleteMessage.js +26 -0
- package/lib/module/store/apis/deleteMessage.js.map +1 -0
- package/lib/module/store/apis/deletePendingTask.js +22 -0
- package/lib/module/store/apis/deletePendingTask.js.map +1 -0
- package/lib/module/store/apis/deleteReaction.js +30 -0
- package/lib/module/store/apis/deleteReaction.js.map +1 -0
- package/lib/module/store/apis/getChannelMessages.js +3 -3
- package/lib/module/store/apis/getChannelMessages.js.map +1 -1
- package/lib/module/store/apis/getChannels.js +1 -1
- package/lib/module/store/apis/getChannels.js.map +1 -1
- package/lib/module/store/apis/getPendingTasks.js +26 -0
- package/lib/module/store/apis/getPendingTasks.js.map +1 -0
- package/lib/module/store/apis/index.js +13 -0
- package/lib/module/store/apis/index.js.map +1 -1
- package/lib/module/store/apis/insertReaction.js +28 -0
- package/lib/module/store/apis/insertReaction.js.map +1 -0
- package/lib/module/store/apis/updateMessage.js.map +1 -1
- package/lib/module/store/apis/updateReaction.js.map +1 -1
- package/lib/module/store/mappers/mapDateTimeToStorable.js.map +1 -1
- package/lib/module/store/mappers/mapMessageToStorable.js +3 -1
- package/lib/module/store/mappers/mapMessageToStorable.js.map +1 -1
- package/lib/module/store/mappers/mapStorableToTask.js +23 -0
- package/lib/module/store/mappers/mapStorableToTask.js.map +1 -0
- package/lib/module/store/mappers/mapTaskToStorable.js +18 -0
- package/lib/module/store/mappers/mapTaskToStorable.js.map +1 -0
- package/lib/module/store/schema.js +11 -0
- package/lib/module/store/schema.js.map +1 -1
- package/lib/module/store/sqlite-utils/appendOrderByClause.js +24 -0
- package/lib/module/store/sqlite-utils/appendOrderByClause.js.map +1 -0
- package/lib/module/store/sqlite-utils/createCreateTableQuery.js +1 -1
- package/lib/module/store/sqlite-utils/createCreateTableQuery.js.map +1 -1
- package/lib/module/store/sqlite-utils/createSelectQuery.js +8 -1
- package/lib/module/store/sqlite-utils/createSelectQuery.js.map +1 -1
- package/lib/module/store/sqlite-utils/createUpdateQuery.js +2 -2
- package/lib/module/store/sqlite-utils/createUpdateQuery.js.map +1 -1
- package/lib/module/store/sqlite-utils/createUpsertQuery.js +1 -1
- package/lib/module/store/sqlite-utils/createUpsertQuery.js.map +1 -1
- package/lib/module/utils/DBSyncManager.js +436 -0
- package/lib/module/utils/DBSyncManager.js.map +1 -0
- package/lib/module/utils/addReactionToLocalState.js +92 -0
- package/lib/module/utils/addReactionToLocalState.js.map +1 -0
- package/lib/module/utils/pendingTaskUtils.js +302 -0
- package/lib/module/utils/pendingTaskUtils.js.map +1 -0
- package/lib/module/utils/removeReactionFromLocalState.js +39 -0
- package/lib/module/utils/removeReactionFromLocalState.js.map +1 -0
- package/lib/module/utils/utils.js +9 -3
- package/lib/module/utils/utils.js.map +1 -1
- package/lib/module/version.json +1 -1
- package/lib/typescript/components/Channel/Channel.d.ts +1 -1
- package/lib/typescript/components/Channel/hooks/useCreateMessagesContext.d.ts +1 -1
- package/lib/typescript/components/ChannelList/hooks/usePaginatedChannels.d.ts +2 -1
- package/lib/typescript/components/Chat/hooks/useCreateChatContext.d.ts +1 -1
- package/lib/typescript/components/Message/Message.d.ts +1 -1
- package/lib/typescript/components/Message/hooks/useMessageActionHandlers.d.ts +1 -1
- package/lib/typescript/components/Message/hooks/useMessageActions.d.ts +1 -1
- package/lib/typescript/components/MessageInput/FileUploadPreview.d.ts +2 -1
- package/lib/typescript/components/MessageInput/ImageUploadPreview.d.ts +2 -1
- package/lib/typescript/components/MessageInput/MessageInput.d.ts +2 -1
- package/lib/typescript/components/index.d.ts +0 -1
- package/lib/typescript/contexts/chatContext/ChatContext.d.ts +1 -2
- package/lib/typescript/contexts/messageContext/MessageContext.d.ts +1 -1
- package/lib/typescript/contexts/messagesContext/MessagesContext.d.ts +3 -0
- package/lib/typescript/store/apis/addPendingTask.d.ts +2 -0
- package/lib/typescript/store/apis/deleteMessage.d.ts +4 -0
- package/lib/typescript/store/apis/deletePendingTask.d.ts +3 -0
- package/lib/typescript/store/apis/deleteReaction.d.ts +6 -0
- package/lib/typescript/store/apis/getChannelMessages.d.ts +1 -1
- package/lib/typescript/store/apis/getPendingTasks.d.ts +3 -0
- package/lib/typescript/store/apis/index.d.ts +1 -0
- package/lib/typescript/store/apis/insertReaction.d.ts +6 -0
- package/lib/typescript/store/apis/updateMessage.d.ts +2 -2
- package/lib/typescript/store/apis/updateReaction.d.ts +2 -2
- package/lib/typescript/store/mappers/mapDateTimeToStorable.d.ts +1 -1
- package/lib/typescript/store/mappers/mapMessageToStorable.d.ts +2 -2
- package/lib/typescript/store/mappers/mapStorableToTask.d.ts +2 -0
- package/lib/typescript/store/mappers/mapTaskToStorable.d.ts +34 -0
- package/lib/typescript/store/schema.d.ts +12 -1
- package/lib/typescript/store/sqlite-utils/appendOrderByClause.d.ts +3 -0
- package/lib/typescript/store/sqlite-utils/createSelectQuery.d.ts +1 -1
- package/lib/typescript/store/types.d.ts +25 -0
- package/lib/typescript/types/types.d.ts +3 -1
- package/lib/typescript/utils/DBSyncManager.d.ts +47 -0
- package/lib/typescript/utils/addReactionToLocalState.d.ts +9 -0
- package/lib/typescript/utils/pendingTaskUtils.d.ts +13 -0
- package/lib/typescript/utils/removeReactionFromLocalState.d.ts +8 -0
- package/lib/typescript/utils/utils.d.ts +3 -3
- package/package.json +2 -2
- package/src/__tests__/offline-feature.test.js +19 -2
- package/src/__tests__/optimistic-update.test.js +368 -0
- package/src/components/Attachment/GalleryImage.tsx +14 -2
- package/src/components/Channel/Channel.tsx +270 -62
- package/src/components/Channel/hooks/useCreateMessagesContext.ts +6 -0
- package/src/components/ChannelList/ChannelList.tsx +2 -10
- package/src/components/ChannelList/hooks/listeners/__tests__/useChannelUpdated.test.tsx +0 -1
- package/src/components/ChannelList/hooks/usePaginatedChannels.ts +75 -27
- package/src/components/Chat/Chat.tsx +5 -9
- package/src/components/Chat/__tests__/Chat.test.js +1 -1
- package/src/components/Chat/hooks/useCreateChatContext.ts +0 -2
- package/src/components/Message/Message.tsx +18 -2
- package/src/components/Message/MessageSimple/MessageFooter.tsx +2 -1
- package/src/components/Message/hooks/useMessageActionHandlers.ts +10 -21
- package/src/components/Message/hooks/useMessageActions.tsx +9 -4
- package/src/components/MessageInput/FileUploadPreview.tsx +8 -2
- package/src/components/MessageInput/ImageUploadPreview.tsx +37 -8
- package/src/components/MessageInput/MessageInput.tsx +17 -3
- package/src/components/MessageInput/SendButton.tsx +1 -1
- package/src/components/index.ts +0 -1
- package/src/contexts/chatContext/ChatContext.tsx +1 -2
- package/src/contexts/messageInputContext/MessageInputContext.tsx +29 -10
- package/src/contexts/messageInputContext/__tests__/__snapshots__/sendMessage.test.tsx.snap +29 -0
- package/src/contexts/messagesContext/MessagesContext.tsx +4 -1
- package/src/hooks/useTranslatedMessage.ts +1 -1
- package/src/mock-builders/DB/mock.ts +2 -2
- package/src/mock-builders/api/deleteMessage.js +18 -0
- package/src/mock-builders/api/deleteReaction.js +19 -0
- package/src/mock-builders/api/sendReaction.tsx +19 -0
- package/src/mock-builders/event/connectionChanged.js +2 -1
- package/src/store/QuickSqliteClient.ts +39 -37
- package/src/store/apis/addPendingTask.ts +24 -0
- package/src/store/apis/deleteMessage.ts +13 -0
- package/src/store/apis/deletePendingTask.ts +12 -0
- package/src/store/apis/deleteReaction.ts +26 -0
- package/src/store/apis/getChannelMessages.ts +1 -1
- package/src/store/apis/getChannels.ts +2 -2
- package/src/store/apis/getPendingTasks.ts +13 -0
- package/src/store/apis/index.ts +1 -0
- package/src/store/apis/insertReaction.ts +29 -0
- package/src/store/apis/updateMessage.ts +2 -2
- package/src/store/apis/updateReaction.ts +2 -2
- package/src/store/mappers/mapDateTimeToStorable.ts +1 -1
- package/src/store/mappers/mapMessageToStorable.ts +8 -2
- package/src/store/mappers/mapStorableToTask.ts +13 -0
- package/src/store/mappers/mapTaskToStorable.ts +7 -0
- package/src/store/schema.ts +25 -1
- package/src/store/sqlite-utils/appendOrderByClause.ts +24 -0
- package/src/store/sqlite-utils/createCreateTableQuery.ts +2 -2
- package/src/store/sqlite-utils/createSelectQuery.ts +4 -1
- package/src/store/sqlite-utils/createUpdateQuery.ts +3 -2
- package/src/store/sqlite-utils/createUpsertQuery.ts +1 -1
- package/src/store/types.ts +33 -0
- package/src/types/types.ts +4 -1
- package/src/utils/DBSyncManager.ts +222 -0
- package/src/utils/addReactionToLocalState.ts +87 -0
- package/src/utils/pendingTaskUtils.ts +131 -0
- package/src/utils/removeReactionFromLocalState.ts +39 -0
- package/src/utils/utils.ts +12 -4
- package/src/version.json +1 -1
- package/lib/commonjs/components/Chat/hooks/useConnectionRecovered.js +0 -171
- package/lib/commonjs/components/Chat/hooks/useConnectionRecovered.js.map +0 -1
- package/lib/module/components/Chat/hooks/useConnectionRecovered.js +0 -171
- package/lib/module/components/Chat/hooks/useConnectionRecovered.js.map +0 -1
- package/lib/typescript/components/Chat/hooks/useConnectionRecovered.d.ts +0 -10
- package/src/components/Chat/hooks/useConnectionRecovered.ts +0 -92
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { QuickSqliteClient } from '../QuickSqliteClient';
|
|
2
|
+
import { createDeleteQuery } from '../sqlite-utils/createDeleteQuery';
|
|
3
|
+
|
|
4
|
+
export const deleteReaction = ({
|
|
5
|
+
flush = true,
|
|
6
|
+
messageId,
|
|
7
|
+
reactionType,
|
|
8
|
+
userId,
|
|
9
|
+
}: {
|
|
10
|
+
messageId: string;
|
|
11
|
+
reactionType: string;
|
|
12
|
+
userId: string;
|
|
13
|
+
flush?: boolean;
|
|
14
|
+
}) => {
|
|
15
|
+
const query = createDeleteQuery('reactions', {
|
|
16
|
+
messageId,
|
|
17
|
+
type: reactionType,
|
|
18
|
+
userId,
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
if (flush) {
|
|
22
|
+
QuickSqliteClient.executeSql.apply(null, query);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return [query];
|
|
26
|
+
};
|
|
@@ -8,7 +8,7 @@ import type { DefaultStreamChatGenerics } from '../../types/types';
|
|
|
8
8
|
import { mapStorableToMessage } from '../mappers/mapStorableToMessage';
|
|
9
9
|
import type { TableRowJoinedUser } from '../types';
|
|
10
10
|
|
|
11
|
-
export const
|
|
11
|
+
export const getChannelMessages = <
|
|
12
12
|
StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
|
|
13
13
|
>({
|
|
14
14
|
channelIds,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ChannelAPIResponse } from 'stream-chat';
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { getChannelMessages } from './getChannelMessages';
|
|
4
4
|
import { getMembers } from './getMembers';
|
|
5
5
|
import { getReads } from './getReads';
|
|
6
6
|
import { selectChannels } from './queries/selectChannels';
|
|
@@ -30,7 +30,7 @@ export const getChannels = <
|
|
|
30
30
|
|
|
31
31
|
const cidVsMembers = getMembers<StreamChatGenerics>({ channelIds });
|
|
32
32
|
const cidVsReads = getReads<StreamChatGenerics>({ channelIds });
|
|
33
|
-
const cidVsMessages =
|
|
33
|
+
const cidVsMessages = getChannelMessages<StreamChatGenerics>({
|
|
34
34
|
channelIds,
|
|
35
35
|
currentUserId,
|
|
36
36
|
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { mapStorableToTask } from '../mappers/mapStorableToTask';
|
|
2
|
+
import { QuickSqliteClient } from '../QuickSqliteClient';
|
|
3
|
+
import { createSelectQuery } from '../sqlite-utils/createSelectQuery';
|
|
4
|
+
|
|
5
|
+
export const getPendingTasks = (conditions: { messageId?: string } = {}) => {
|
|
6
|
+
const query = createSelectQuery('pendingTasks', ['*'], conditions, {
|
|
7
|
+
createdAt: 1,
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
const result = QuickSqliteClient.executeSql.apply(null, query);
|
|
11
|
+
|
|
12
|
+
return result.map((r) => mapStorableToTask(r));
|
|
13
|
+
};
|
package/src/store/apis/index.ts
CHANGED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { ReactionResponse } from 'stream-chat';
|
|
2
|
+
|
|
3
|
+
import { mapReactionToStorable } from '../mappers/mapReactionToStorable';
|
|
4
|
+
import { QuickSqliteClient } from '../QuickSqliteClient';
|
|
5
|
+
import { createUpsertQuery } from '../sqlite-utils/createUpsertQuery';
|
|
6
|
+
import type { PreparedQueries } from '../types';
|
|
7
|
+
|
|
8
|
+
export const insertReaction = ({
|
|
9
|
+
flush = true,
|
|
10
|
+
reaction,
|
|
11
|
+
}: {
|
|
12
|
+
reaction: ReactionResponse;
|
|
13
|
+
flush?: boolean;
|
|
14
|
+
}) => {
|
|
15
|
+
const queries: PreparedQueries[] = [];
|
|
16
|
+
|
|
17
|
+
queries.push(createUpsertQuery('reactions', mapReactionToStorable(reaction)));
|
|
18
|
+
|
|
19
|
+
queries.push([
|
|
20
|
+
'UPDATE messages SET reactionCounts = reactionCounts + 1 WHERE id = ?',
|
|
21
|
+
[reaction.message_id],
|
|
22
|
+
]);
|
|
23
|
+
|
|
24
|
+
if (flush) {
|
|
25
|
+
QuickSqliteClient.executeSqlBatch(queries);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return queries;
|
|
29
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { MessageResponse } from 'stream-chat';
|
|
1
|
+
import type { FormatMessageResponse, MessageResponse } from 'stream-chat';
|
|
2
2
|
|
|
3
3
|
import { mapMessageToStorable } from '../mappers/mapMessageToStorable';
|
|
4
4
|
import { mapReactionToStorable } from '../mappers/mapReactionToStorable';
|
|
@@ -14,7 +14,7 @@ export const updateMessage = ({
|
|
|
14
14
|
flush = true,
|
|
15
15
|
message,
|
|
16
16
|
}: {
|
|
17
|
-
message: MessageResponse;
|
|
17
|
+
message: MessageResponse | FormatMessageResponse;
|
|
18
18
|
flush?: boolean;
|
|
19
19
|
}) => {
|
|
20
20
|
const queries: PreparedQueries[] = [];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { MessageResponse, ReactionResponse } from 'stream-chat';
|
|
1
|
+
import type { FormatMessageResponse, MessageResponse, ReactionResponse } from 'stream-chat';
|
|
2
2
|
|
|
3
3
|
import { mapMessageToStorable } from '../mappers/mapMessageToStorable';
|
|
4
4
|
import { mapReactionToStorable } from '../mappers/mapReactionToStorable';
|
|
@@ -13,7 +13,7 @@ export const updateReaction = ({
|
|
|
13
13
|
message,
|
|
14
14
|
reaction,
|
|
15
15
|
}: {
|
|
16
|
-
message: MessageResponse;
|
|
16
|
+
message: MessageResponse | FormatMessageResponse;
|
|
17
17
|
reaction: ReactionResponse;
|
|
18
18
|
flush?: boolean;
|
|
19
19
|
}) => {
|
|
@@ -1,16 +1,22 @@
|
|
|
1
|
-
import type { MessageResponse } from 'stream-chat';
|
|
1
|
+
import type { FormatMessageResponse, MessageResponse } from 'stream-chat';
|
|
2
2
|
|
|
3
3
|
import { mapDateTimeToStorable } from './mapDateTimeToStorable';
|
|
4
4
|
|
|
5
5
|
import type { TableRow } from '../types';
|
|
6
6
|
|
|
7
|
-
export const mapMessageToStorable = (
|
|
7
|
+
export const mapMessageToStorable = (
|
|
8
|
+
message: MessageResponse | FormatMessageResponse,
|
|
9
|
+
): TableRow<'messages'> => {
|
|
8
10
|
const {
|
|
9
11
|
attachments,
|
|
10
12
|
cid,
|
|
11
13
|
created_at,
|
|
12
14
|
deleted_at,
|
|
13
15
|
id,
|
|
16
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
17
|
+
latest_reactions,
|
|
18
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
19
|
+
own_reactions,
|
|
14
20
|
reaction_counts,
|
|
15
21
|
text,
|
|
16
22
|
type,
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { PendingTask, TableRowJoinedUser } from '../types';
|
|
2
|
+
|
|
3
|
+
export const mapStorableToTask = (row: TableRowJoinedUser<'pendingTasks'>): PendingTask => {
|
|
4
|
+
const { channelId, channelType, id, messageId, type } = row;
|
|
5
|
+
return {
|
|
6
|
+
channelId,
|
|
7
|
+
channelType,
|
|
8
|
+
id,
|
|
9
|
+
messageId,
|
|
10
|
+
payload: JSON.parse(row.payload),
|
|
11
|
+
type,
|
|
12
|
+
};
|
|
13
|
+
};
|
package/src/store/schema.ts
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import type { MessageLabel, Role } from 'stream-chat';
|
|
2
2
|
|
|
3
|
+
import type { PendingTaskTypes } from './types';
|
|
4
|
+
|
|
5
|
+
import type { ValueOf } from '../types/types';
|
|
6
|
+
|
|
3
7
|
type Tables = {
|
|
4
8
|
[P in keyof Schema]: {
|
|
5
9
|
columns: {
|
|
6
10
|
[K in keyof Schema[P]]: string;
|
|
7
11
|
};
|
|
8
|
-
primaryKey: Array<keyof Schema[P]>;
|
|
9
12
|
foreignKeys?: Array<{
|
|
10
13
|
column: `${Exclude<keyof Schema[P], symbol>}`;
|
|
11
14
|
referenceTable: `${keyof Schema}`;
|
|
@@ -18,6 +21,7 @@ type Tables = {
|
|
|
18
21
|
name: string;
|
|
19
22
|
unique: boolean;
|
|
20
23
|
}>;
|
|
24
|
+
primaryKey?: Array<keyof Schema[P]>;
|
|
21
25
|
};
|
|
22
26
|
};
|
|
23
27
|
|
|
@@ -121,6 +125,17 @@ export const tables: Tables = {
|
|
|
121
125
|
],
|
|
122
126
|
primaryKey: ['id'],
|
|
123
127
|
},
|
|
128
|
+
pendingTasks: {
|
|
129
|
+
columns: {
|
|
130
|
+
channelId: 'TEXT',
|
|
131
|
+
channelType: 'TEXT',
|
|
132
|
+
createdAt: 'TEXT',
|
|
133
|
+
id: 'INTEGER PRIMARY KEY AUTOINCREMENT',
|
|
134
|
+
messageId: 'TEXT',
|
|
135
|
+
payload: 'TEXT',
|
|
136
|
+
type: 'TEXT',
|
|
137
|
+
},
|
|
138
|
+
},
|
|
124
139
|
reactions: {
|
|
125
140
|
columns: {
|
|
126
141
|
createdAt: 'TEXT',
|
|
@@ -252,6 +267,15 @@ export type Schema = {
|
|
|
252
267
|
text?: string;
|
|
253
268
|
userId?: string;
|
|
254
269
|
};
|
|
270
|
+
pendingTasks: {
|
|
271
|
+
channelId: string;
|
|
272
|
+
channelType: string;
|
|
273
|
+
createdAt: string;
|
|
274
|
+
id: number;
|
|
275
|
+
messageId: string;
|
|
276
|
+
payload: string;
|
|
277
|
+
type: ValueOf<PendingTaskTypes>;
|
|
278
|
+
};
|
|
255
279
|
reactions: {
|
|
256
280
|
createdAt: string;
|
|
257
281
|
messageId: string;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { Schema } from '../schema';
|
|
2
|
+
import type { PreparedQueries, TableColumnNames } from '../types';
|
|
3
|
+
|
|
4
|
+
export const appendOrderByClause = <T extends keyof Schema>(
|
|
5
|
+
selectQuery: string,
|
|
6
|
+
orderBy?: Partial<{ [k in TableColumnNames<T>]: 1 | -1 }>,
|
|
7
|
+
): PreparedQueries => {
|
|
8
|
+
if (!orderBy) return [selectQuery, []];
|
|
9
|
+
|
|
10
|
+
const orderByClause = [];
|
|
11
|
+
|
|
12
|
+
for (const key in orderBy) {
|
|
13
|
+
const order = orderBy[key];
|
|
14
|
+
if (order === undefined) continue;
|
|
15
|
+
|
|
16
|
+
orderByClause.push(`${key} ${order === 1 ? 'ASC' : 'DESC'}`);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
if (!orderByClause.length) {
|
|
20
|
+
return [selectQuery, []];
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
return [`${selectQuery} ORDER BY ${orderByClause.join(', ')}`];
|
|
24
|
+
};
|
|
@@ -8,8 +8,8 @@ export const createCreateTableQuery = (tableName: Table): PreparedQueries[] => {
|
|
|
8
8
|
});
|
|
9
9
|
|
|
10
10
|
const primaryKeyConstraints =
|
|
11
|
-
tables[tableName].primaryKey.length > 0
|
|
12
|
-
? [`PRIMARY KEY (${tables[tableName].primaryKey.join(', ')})`]
|
|
11
|
+
(tables[tableName].primaryKey || []).length > 0
|
|
12
|
+
? [`PRIMARY KEY (${(tables[tableName].primaryKey || []).join(', ')})`]
|
|
13
13
|
: [];
|
|
14
14
|
const foreignKeysConstraints =
|
|
15
15
|
tables[tableName].foreignKeys?.map(
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { appendOrderByClause } from './appendOrderByClause';
|
|
1
2
|
import { appendWhereClause } from './appendWhereCluase';
|
|
2
3
|
|
|
3
4
|
import type { Schema } from '../schema';
|
|
@@ -17,9 +18,11 @@ export const createSelectQuery = <T extends keyof Schema>(
|
|
|
17
18
|
table: T,
|
|
18
19
|
fields: Array<'*'> | Array<TableColumnNames<T>> = ['*'],
|
|
19
20
|
whereCondition?: Partial<{ [k in TableColumnNames<T>]: TableColumnValue | TableColumnValue[] }>,
|
|
21
|
+
orderBy?: Partial<{ [k in TableColumnNames<T>]: 1 | -1 }>,
|
|
20
22
|
): PreparedQueries => {
|
|
21
23
|
const selectQuery = `SELECT ${fields.join(', ')} FROM ${table}`;
|
|
22
24
|
const [selectQueryWithWhere, whereParams] = appendWhereClause(selectQuery, whereCondition);
|
|
25
|
+
const [selectQueryWithOrderBy] = appendOrderByClause(selectQueryWithWhere, orderBy);
|
|
23
26
|
|
|
24
|
-
return [`${
|
|
27
|
+
return [`${selectQueryWithOrderBy}`, whereParams || []];
|
|
25
28
|
};
|
|
@@ -19,9 +19,10 @@ export const createUpdateQuery = <T extends keyof Schema>(
|
|
|
19
19
|
whereCondition: Partial<{ [k in TableColumnNames<T>]: TableColumnValue | TableColumnValue[] }>,
|
|
20
20
|
): PreparedQueries => {
|
|
21
21
|
const fields = Object.keys(set).map((key) => `${key} = ?`);
|
|
22
|
-
|
|
22
|
+
|
|
23
|
+
const updateQuery = `UPDATE OR IGNORE ${table} SET ${fields.join(',')}`;
|
|
23
24
|
|
|
24
25
|
const [updateQueryWithWhere, whereParams] = appendWhereClause(updateQuery, whereCondition);
|
|
25
26
|
|
|
26
|
-
return [updateQueryWithWhere
|
|
27
|
+
return [`${updateQueryWithWhere}`, [...Object.values(set), ...(whereParams || [])]];
|
|
27
28
|
};
|
|
@@ -30,7 +30,7 @@ export const createUpsertQuery = <T extends keyof Schema>(
|
|
|
30
30
|
const fields = Object.keys(filteredRow) as (keyof typeof row)[];
|
|
31
31
|
|
|
32
32
|
const questionMarks = Array(Object.keys(fields).length).fill('?').join(',');
|
|
33
|
-
const conflictKeys = conflictCheckKeys || tables[table].primaryKey;
|
|
33
|
+
const conflictKeys = conflictCheckKeys || tables[table].primaryKey || [];
|
|
34
34
|
const conflictMatchersWithoutPK: string[] = (fields as string[])
|
|
35
35
|
.filter((f) => !(conflictKeys as string[]).includes(f))
|
|
36
36
|
.map((f) => `${f}=excluded.${f}`);
|
package/src/store/types.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { Channel, StreamChat } from 'stream-chat';
|
|
2
|
+
|
|
1
3
|
import type { Schema } from './schema';
|
|
2
4
|
|
|
3
5
|
export type Table = keyof Schema;
|
|
@@ -10,3 +12,34 @@ export type TableColumnNames<T extends Table> = keyof Schema[T];
|
|
|
10
12
|
export type TableColumnValue = string | boolean | number | undefined;
|
|
11
13
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
12
14
|
export type PreparedQueries = [string] | [string, Array<any>];
|
|
15
|
+
|
|
16
|
+
export type PendingTaskTypes = {
|
|
17
|
+
deleteMessage: 'delete-message';
|
|
18
|
+
deleteReaction: 'delete-reaction';
|
|
19
|
+
sendMessage: 'send-message';
|
|
20
|
+
sendReaction: 'send-reaction';
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export type PendingTask = {
|
|
24
|
+
channelId: string;
|
|
25
|
+
channelType: string;
|
|
26
|
+
messageId: string;
|
|
27
|
+
id?: number;
|
|
28
|
+
} & (
|
|
29
|
+
| {
|
|
30
|
+
payload: Parameters<Channel['sendReaction']>;
|
|
31
|
+
type: PendingTaskTypes['sendReaction'];
|
|
32
|
+
}
|
|
33
|
+
| {
|
|
34
|
+
payload: Parameters<Channel['sendMessage']>;
|
|
35
|
+
type: PendingTaskTypes['sendMessage'];
|
|
36
|
+
}
|
|
37
|
+
| {
|
|
38
|
+
payload: Parameters<StreamChat['deleteMessage']>;
|
|
39
|
+
type: PendingTaskTypes['deleteMessage'];
|
|
40
|
+
}
|
|
41
|
+
| {
|
|
42
|
+
payload: Parameters<Channel['deleteReaction']>;
|
|
43
|
+
type: PendingTaskTypes['deleteReaction'];
|
|
44
|
+
}
|
|
45
|
+
);
|
package/src/types/types.ts
CHANGED
|
@@ -25,6 +25,7 @@ export type File = {
|
|
|
25
25
|
export type DefaultAttachmentType = UnknownType & {
|
|
26
26
|
file_size?: number | string;
|
|
27
27
|
mime_type?: string;
|
|
28
|
+
originalFile?: File;
|
|
28
29
|
};
|
|
29
30
|
|
|
30
31
|
interface DefaultUserType extends UnknownType {
|
|
@@ -37,7 +38,7 @@ interface DefaultChannelType extends UnknownType {
|
|
|
37
38
|
}
|
|
38
39
|
|
|
39
40
|
export interface DefaultStreamChatGenerics extends ExtendableGenerics {
|
|
40
|
-
attachmentType:
|
|
41
|
+
attachmentType: DefaultAttachmentType;
|
|
41
42
|
channelType: DefaultChannelType;
|
|
42
43
|
commandType: LiteralStringForUnion;
|
|
43
44
|
eventType: UnknownType;
|
|
@@ -47,3 +48,5 @@ export interface DefaultStreamChatGenerics extends ExtendableGenerics {
|
|
|
47
48
|
}
|
|
48
49
|
|
|
49
50
|
export type UnknownType = Record<string, unknown>;
|
|
51
|
+
|
|
52
|
+
export type ValueOf<T> = T[keyof T];
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
import type { AxiosError } from 'axios';
|
|
2
|
+
import type { APIErrorResponse, StreamChat } from 'stream-chat';
|
|
3
|
+
|
|
4
|
+
import { handleEventToSyncDB } from '../components/Chat/hooks/handleEventToSyncDB';
|
|
5
|
+
import { getAllChannelIds, getLastSyncedAt, upsertLastSyncedAt } from '../store/apis';
|
|
6
|
+
|
|
7
|
+
import { addPendingTask } from '../store/apis/addPendingTask';
|
|
8
|
+
|
|
9
|
+
import { deletePendingTask } from '../store/apis/deletePendingTask';
|
|
10
|
+
import { getPendingTasks } from '../store/apis/getPendingTasks';
|
|
11
|
+
import { QuickSqliteClient } from '../store/QuickSqliteClient';
|
|
12
|
+
import type { PendingTask, PreparedQueries } from '../store/types';
|
|
13
|
+
import type { DefaultStreamChatGenerics } from '../types/types';
|
|
14
|
+
/**
|
|
15
|
+
* DBSyncManager has the responsibility to sync the channel states
|
|
16
|
+
* within local database whenever possible.
|
|
17
|
+
*
|
|
18
|
+
* Components can get the current sync status using DBSyncManager.getCurrentStatus().
|
|
19
|
+
* Or components can attach a listener for status change as following:
|
|
20
|
+
*
|
|
21
|
+
* ```tsx
|
|
22
|
+
* useEffect(() => {
|
|
23
|
+
* const unsubscribe = DBSyncManager.onSyncStatusChange((syncStatus) => {
|
|
24
|
+
* if (syncStatus) {
|
|
25
|
+
* doSomething();
|
|
26
|
+
* }
|
|
27
|
+
* })
|
|
28
|
+
*
|
|
29
|
+
* return () => unsubscribe();
|
|
30
|
+
* })
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
const restBeforeNextTask = () => new Promise((resolve) => setTimeout(resolve, 500));
|
|
34
|
+
|
|
35
|
+
export class DBSyncManager {
|
|
36
|
+
static syncStatus = false;
|
|
37
|
+
static listeners: Array<(status: boolean) => void> = [];
|
|
38
|
+
static client: StreamChat | null = null;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Returns weather channel states in local DB are synced with backend or not.
|
|
42
|
+
* @returns boolean
|
|
43
|
+
*/
|
|
44
|
+
static getSyncStatus = () => this.syncStatus;
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Initializes the DBSyncManager. This function should be called only once
|
|
48
|
+
* throughout the lifetime of SDK.
|
|
49
|
+
*
|
|
50
|
+
* @param client
|
|
51
|
+
*/
|
|
52
|
+
static init = async (client: StreamChat) => {
|
|
53
|
+
this.client = client;
|
|
54
|
+
// If the websocket connection is already active, then straightaway
|
|
55
|
+
// call the sync api and also execute pending api calls.
|
|
56
|
+
// Otherwise wait for `connection.changed` event.
|
|
57
|
+
if (client.user?.id && client.wsConnection?.isHealthy) {
|
|
58
|
+
await this.syncAndExecutePendingTasks();
|
|
59
|
+
this.syncStatus = true;
|
|
60
|
+
this.listeners.forEach((l) => l(true));
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
this.client.on('connection.changed', async (event) => {
|
|
64
|
+
if (event.online) {
|
|
65
|
+
await this.syncAndExecutePendingTasks();
|
|
66
|
+
this.listeners.forEach((l) => l(true));
|
|
67
|
+
} else {
|
|
68
|
+
this.listeners.forEach((l) => l(false));
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Subscribes a listener for sync status change.
|
|
75
|
+
*
|
|
76
|
+
* @param listener {function}
|
|
77
|
+
* @returns {function} to unsubscribe the listener.
|
|
78
|
+
*/
|
|
79
|
+
static onSyncStatusChange = (listener: (status: boolean) => void) => {
|
|
80
|
+
this.listeners.push(listener);
|
|
81
|
+
|
|
82
|
+
return {
|
|
83
|
+
unsubscribe: () => {
|
|
84
|
+
this.listeners = this.listeners.filter((el) => el !== listener);
|
|
85
|
+
},
|
|
86
|
+
};
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
static sync = async () => {
|
|
90
|
+
if (!this.client?.user) return;
|
|
91
|
+
|
|
92
|
+
const lastSyncedAt = getLastSyncedAt({
|
|
93
|
+
currentUserId: this.client.user.id,
|
|
94
|
+
});
|
|
95
|
+
const cids = getAllChannelIds();
|
|
96
|
+
|
|
97
|
+
if (lastSyncedAt) {
|
|
98
|
+
try {
|
|
99
|
+
const result = await this.client.sync(cids, new Date(lastSyncedAt).toISOString());
|
|
100
|
+
const queries = result.events.reduce<PreparedQueries[]>((queries, event) => {
|
|
101
|
+
queries = queries.concat(handleEventToSyncDB(event, false));
|
|
102
|
+
return queries;
|
|
103
|
+
}, []);
|
|
104
|
+
|
|
105
|
+
if (queries.length) {
|
|
106
|
+
QuickSqliteClient.executeSqlBatch(queries);
|
|
107
|
+
}
|
|
108
|
+
} catch (e) {
|
|
109
|
+
// Error will be raised by the sync API if there are too many events.
|
|
110
|
+
// In that case reset the entire DB and start fresh.
|
|
111
|
+
QuickSqliteClient.resetDB();
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
upsertLastSyncedAt({
|
|
115
|
+
currentUserId: this.client.user.id,
|
|
116
|
+
lastSyncedAt: new Date().toString(),
|
|
117
|
+
});
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
static syncAndExecutePendingTasks = async () => {
|
|
121
|
+
if (!this.client) return;
|
|
122
|
+
|
|
123
|
+
await this.executePendingTasks(this.client);
|
|
124
|
+
await this.sync();
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
static queueTask = async <
|
|
128
|
+
StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
|
|
129
|
+
>({
|
|
130
|
+
client,
|
|
131
|
+
task,
|
|
132
|
+
}: {
|
|
133
|
+
client: StreamChat<StreamChatGenerics>;
|
|
134
|
+
task: PendingTask;
|
|
135
|
+
}) => {
|
|
136
|
+
const removeFromApi = addPendingTask(task);
|
|
137
|
+
|
|
138
|
+
let response;
|
|
139
|
+
try {
|
|
140
|
+
response = await this.executeTask<StreamChatGenerics>({ client, task });
|
|
141
|
+
} catch (e) {
|
|
142
|
+
if ((e as AxiosError<APIErrorResponse>)?.response?.data?.code === 4) {
|
|
143
|
+
// Error code 16 - message already exists
|
|
144
|
+
// ignore
|
|
145
|
+
} else {
|
|
146
|
+
throw e;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
removeFromApi();
|
|
151
|
+
|
|
152
|
+
return response;
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
static executeTask = async <
|
|
156
|
+
StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
|
|
157
|
+
>({
|
|
158
|
+
client,
|
|
159
|
+
task,
|
|
160
|
+
}: {
|
|
161
|
+
client: StreamChat<StreamChatGenerics>;
|
|
162
|
+
task: PendingTask;
|
|
163
|
+
}) => {
|
|
164
|
+
const channel = client.channel(task.channelType, task.channelId);
|
|
165
|
+
|
|
166
|
+
if (task.type === 'send-reaction') {
|
|
167
|
+
return await channel.sendReaction(...task.payload);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
if (task.type === 'delete-reaction') {
|
|
171
|
+
return await channel.deleteReaction(...task.payload);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
if (task.type === 'delete-message') {
|
|
175
|
+
return await client.deleteMessage(...task.payload);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
throw new Error('Invalid task type');
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
static executePendingTasks = async <
|
|
182
|
+
StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
|
|
183
|
+
>(
|
|
184
|
+
client: StreamChat<StreamChatGenerics>,
|
|
185
|
+
) => {
|
|
186
|
+
const queue = getPendingTasks();
|
|
187
|
+
for (const task of queue) {
|
|
188
|
+
if (!task.id) continue;
|
|
189
|
+
|
|
190
|
+
try {
|
|
191
|
+
await this.executeTask<StreamChatGenerics>({
|
|
192
|
+
client,
|
|
193
|
+
task,
|
|
194
|
+
});
|
|
195
|
+
} catch (e) {
|
|
196
|
+
if ((e as AxiosError<APIErrorResponse>)?.response?.data?.code === 4) {
|
|
197
|
+
// Error code 16 - message already exists
|
|
198
|
+
// ignore
|
|
199
|
+
} else {
|
|
200
|
+
throw e;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
deletePendingTask({
|
|
205
|
+
id: task.id,
|
|
206
|
+
});
|
|
207
|
+
await restBeforeNextTask();
|
|
208
|
+
}
|
|
209
|
+
};
|
|
210
|
+
|
|
211
|
+
dropPendingTasks = (conditions: { messageId: string }) => {
|
|
212
|
+
const tasks = getPendingTasks(conditions);
|
|
213
|
+
|
|
214
|
+
for (const task of tasks) {
|
|
215
|
+
if (!task.id) continue;
|
|
216
|
+
|
|
217
|
+
deletePendingTask({
|
|
218
|
+
id: task.id,
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
};
|
|
222
|
+
}
|