stream-chat-react-native-core 7.0.1 → 7.1.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/Channel/Channel.js +214 -237
- package/lib/commonjs/components/Channel/Channel.js.map +1 -1
- package/lib/commonjs/components/ChannelList/ChannelList.js +2 -19
- package/lib/commonjs/components/ChannelList/ChannelList.js.map +1 -1
- package/lib/commonjs/components/ChannelList/hooks/usePaginatedChannels.js +48 -176
- package/lib/commonjs/components/ChannelList/hooks/usePaginatedChannels.js.map +1 -1
- package/lib/commonjs/components/ChannelPreview/hooks/useIsChannelMuted.js +13 -2
- package/lib/commonjs/components/ChannelPreview/hooks/useIsChannelMuted.js.map +1 -1
- package/lib/commonjs/components/Chat/Chat.js +33 -46
- package/lib/commonjs/components/Chat/Chat.js.map +1 -1
- package/lib/commonjs/components/Chat/hooks/useAppSettings.js +47 -120
- package/lib/commonjs/components/Chat/hooks/useAppSettings.js.map +1 -1
- package/lib/commonjs/components/Chat/hooks/useSyncDatabase.js +0 -15
- package/lib/commonjs/components/Chat/hooks/useSyncDatabase.js.map +1 -1
- package/lib/commonjs/components/MessageMenu/MessageUserReactions.js +5 -0
- package/lib/commonjs/components/MessageMenu/MessageUserReactions.js.map +1 -1
- package/lib/commonjs/components/MessageMenu/hooks/useFetchReactions.js +92 -108
- package/lib/commonjs/components/MessageMenu/hooks/useFetchReactions.js.map +1 -1
- package/lib/commonjs/index.js +8 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/mock-builders/event/channelVisible.js +13 -0
- package/lib/commonjs/mock-builders/event/channelVisible.js.map +1 -0
- package/lib/commonjs/mock-builders/event/memberAdded.js +4 -2
- package/lib/commonjs/mock-builders/event/memberAdded.js.map +1 -1
- package/lib/commonjs/mock-builders/event/memberRemoved.js +2 -1
- package/lib/commonjs/mock-builders/event/memberRemoved.js.map +1 -1
- package/lib/commonjs/mock-builders/event/memberUpdated.js +2 -1
- package/lib/commonjs/mock-builders/event/memberUpdated.js.map +1 -1
- package/lib/commonjs/mock-builders/event/messageNew.js +4 -2
- package/lib/commonjs/mock-builders/event/messageNew.js.map +1 -1
- package/lib/commonjs/mock-builders/event/messageRead.js +6 -3
- package/lib/commonjs/mock-builders/event/messageRead.js.map +1 -1
- package/lib/commonjs/mock-builders/event/notificationMarkUnread.js +3 -0
- package/lib/commonjs/mock-builders/event/notificationMarkUnread.js.map +1 -1
- package/lib/commonjs/mock-builders/generator/channel.js +10 -3
- package/lib/commonjs/mock-builders/generator/channel.js.map +1 -1
- package/lib/commonjs/store/OfflineDB.js +108 -0
- package/lib/commonjs/store/OfflineDB.js.map +1 -0
- package/lib/commonjs/store/SqliteClient.js +11 -10
- package/lib/commonjs/store/SqliteClient.js.map +1 -1
- package/lib/commonjs/store/apis/addPendingTask.js.map +1 -1
- package/lib/commonjs/store/apis/channelExists.js +34 -0
- package/lib/commonjs/store/apis/channelExists.js.map +1 -0
- package/lib/commonjs/store/apis/deleteChannel.js +4 -4
- package/lib/commonjs/store/apis/deleteChannel.js.map +1 -1
- package/lib/commonjs/store/apis/deleteMember.js +4 -4
- package/lib/commonjs/store/apis/deleteMember.js.map +1 -1
- package/lib/commonjs/store/apis/deleteMessage.js +16 -12
- package/lib/commonjs/store/apis/deleteMessage.js.map +1 -1
- package/lib/commonjs/store/apis/deleteMessagesForChannel.js +11 -12
- package/lib/commonjs/store/apis/deleteMessagesForChannel.js.map +1 -1
- package/lib/commonjs/store/apis/deleteReaction.js +29 -17
- package/lib/commonjs/store/apis/deleteReaction.js.map +1 -1
- package/lib/commonjs/store/apis/deleteReactions.js +4 -4
- package/lib/commonjs/store/apis/deleteReactions.js.map +1 -1
- package/lib/commonjs/store/apis/dropPendingTasks.js +41 -0
- package/lib/commonjs/store/apis/dropPendingTasks.js.map +1 -0
- package/lib/commonjs/store/apis/getChannelMessages.js +1 -1
- package/lib/commonjs/store/apis/getChannelMessages.js.map +1 -1
- package/lib/commonjs/store/apis/getChannels.js +18 -21
- package/lib/commonjs/store/apis/getChannels.js.map +1 -1
- package/lib/commonjs/store/apis/getLastSyncedAt.js +3 -9
- package/lib/commonjs/store/apis/getLastSyncedAt.js.map +1 -1
- package/lib/commonjs/store/apis/getReactionsforFilterSort.js +5 -8
- package/lib/commonjs/store/apis/getReactionsforFilterSort.js.map +1 -1
- package/lib/commonjs/store/apis/index.js +103 -4
- package/lib/commonjs/store/apis/index.js.map +1 -1
- package/lib/commonjs/store/apis/insertReaction.js +4 -4
- package/lib/commonjs/store/apis/insertReaction.js.map +1 -1
- package/lib/commonjs/store/apis/queries/selectMessagesForChannels.js +1 -1
- package/lib/commonjs/store/apis/queries/selectMessagesForChannels.js.map +1 -1
- package/lib/commonjs/store/apis/queries/selectReactionsForMessages.js +25 -5
- package/lib/commonjs/store/apis/queries/selectReactionsForMessages.js.map +1 -1
- package/lib/commonjs/store/apis/softDeleteMessage.js +45 -0
- package/lib/commonjs/store/apis/softDeleteMessage.js.map +1 -0
- package/lib/commonjs/store/apis/updateMessage.js +7 -11
- package/lib/commonjs/store/apis/updateMessage.js.map +1 -1
- package/lib/commonjs/store/apis/updateReaction.js +11 -9
- package/lib/commonjs/store/apis/updateReaction.js.map +1 -1
- package/lib/commonjs/store/apis/upsertAppSettings.js +9 -7
- package/lib/commonjs/store/apis/upsertAppSettings.js.map +1 -1
- package/lib/commonjs/store/apis/upsertChannelData.js +4 -4
- package/lib/commonjs/store/apis/upsertChannelData.js.map +1 -1
- package/lib/commonjs/store/apis/upsertChannelDataFromChannel.js +3 -3
- package/lib/commonjs/store/apis/upsertChannelDataFromChannel.js.map +1 -1
- package/lib/commonjs/store/apis/upsertChannels.js +86 -83
- package/lib/commonjs/store/apis/upsertChannels.js.map +1 -1
- package/lib/commonjs/store/apis/upsertCidsForQuery.js +4 -4
- package/lib/commonjs/store/apis/upsertCidsForQuery.js.map +1 -1
- package/lib/commonjs/store/apis/upsertMembers.js +4 -4
- package/lib/commonjs/store/apis/upsertMembers.js.map +1 -1
- package/lib/commonjs/store/apis/upsertMessages.js +4 -4
- package/lib/commonjs/store/apis/upsertMessages.js.map +1 -1
- package/lib/commonjs/store/apis/upsertPoll.js +42 -0
- package/lib/commonjs/store/apis/upsertPoll.js.map +1 -0
- package/lib/commonjs/store/apis/upsertReads.js +4 -4
- package/lib/commonjs/store/apis/upsertReads.js.map +1 -1
- package/lib/commonjs/store/apis/upsertUserSyncStatus.js +13 -7
- package/lib/commonjs/store/apis/upsertUserSyncStatus.js.map +1 -1
- package/lib/commonjs/store/mappers/mapMemberToStorable.js +6 -2
- package/lib/commonjs/store/mappers/mapMemberToStorable.js.map +1 -1
- package/lib/commonjs/store/mappers/mapReadToStorable.js +3 -1
- package/lib/commonjs/store/mappers/mapReadToStorable.js.map +1 -1
- package/lib/commonjs/store/mappers/mapStorableToMember.js +5 -1
- package/lib/commonjs/store/mappers/mapStorableToMember.js.map +1 -1
- package/lib/commonjs/store/mappers/mapStorableToRead.js +3 -1
- package/lib/commonjs/store/mappers/mapStorableToRead.js.map +1 -1
- package/lib/commonjs/store/mappers/mapStorableToTask.js.map +1 -1
- package/lib/commonjs/store/schema.js +2 -0
- package/lib/commonjs/store/schema.js.map +1 -1
- package/lib/commonjs/utils/addReactionToLocalState.js +62 -81
- package/lib/commonjs/utils/addReactionToLocalState.js.map +1 -1
- package/lib/commonjs/utils/removeReactionFromLocalState.js +0 -6
- package/lib/commonjs/utils/removeReactionFromLocalState.js.map +1 -1
- package/lib/commonjs/version.json +1 -1
- package/lib/module/components/Channel/Channel.js +214 -237
- package/lib/module/components/Channel/Channel.js.map +1 -1
- package/lib/module/components/ChannelList/ChannelList.js +2 -19
- package/lib/module/components/ChannelList/ChannelList.js.map +1 -1
- package/lib/module/components/ChannelList/hooks/usePaginatedChannels.js +48 -176
- package/lib/module/components/ChannelList/hooks/usePaginatedChannels.js.map +1 -1
- package/lib/module/components/ChannelPreview/hooks/useIsChannelMuted.js +13 -2
- package/lib/module/components/ChannelPreview/hooks/useIsChannelMuted.js.map +1 -1
- package/lib/module/components/Chat/Chat.js +33 -46
- package/lib/module/components/Chat/Chat.js.map +1 -1
- package/lib/module/components/Chat/hooks/useAppSettings.js +47 -120
- package/lib/module/components/Chat/hooks/useAppSettings.js.map +1 -1
- package/lib/module/components/Chat/hooks/useSyncDatabase.js +0 -15
- package/lib/module/components/Chat/hooks/useSyncDatabase.js.map +1 -1
- package/lib/module/components/MessageMenu/MessageUserReactions.js +5 -0
- package/lib/module/components/MessageMenu/MessageUserReactions.js.map +1 -1
- package/lib/module/components/MessageMenu/hooks/useFetchReactions.js +92 -108
- package/lib/module/components/MessageMenu/hooks/useFetchReactions.js.map +1 -1
- package/lib/module/index.js +8 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/mock-builders/event/channelVisible.js +13 -0
- package/lib/module/mock-builders/event/channelVisible.js.map +1 -0
- package/lib/module/mock-builders/event/memberAdded.js +4 -2
- package/lib/module/mock-builders/event/memberAdded.js.map +1 -1
- package/lib/module/mock-builders/event/memberRemoved.js +2 -1
- package/lib/module/mock-builders/event/memberRemoved.js.map +1 -1
- package/lib/module/mock-builders/event/memberUpdated.js +2 -1
- package/lib/module/mock-builders/event/memberUpdated.js.map +1 -1
- package/lib/module/mock-builders/event/messageNew.js +4 -2
- package/lib/module/mock-builders/event/messageNew.js.map +1 -1
- package/lib/module/mock-builders/event/messageRead.js +6 -3
- package/lib/module/mock-builders/event/messageRead.js.map +1 -1
- package/lib/module/mock-builders/event/notificationMarkUnread.js +3 -0
- package/lib/module/mock-builders/event/notificationMarkUnread.js.map +1 -1
- package/lib/module/mock-builders/generator/channel.js +10 -3
- package/lib/module/mock-builders/generator/channel.js.map +1 -1
- package/lib/module/store/OfflineDB.js +108 -0
- package/lib/module/store/OfflineDB.js.map +1 -0
- package/lib/module/store/SqliteClient.js +11 -10
- package/lib/module/store/SqliteClient.js.map +1 -1
- package/lib/module/store/apis/addPendingTask.js.map +1 -1
- package/lib/module/store/apis/channelExists.js +34 -0
- package/lib/module/store/apis/channelExists.js.map +1 -0
- package/lib/module/store/apis/deleteChannel.js +4 -4
- package/lib/module/store/apis/deleteChannel.js.map +1 -1
- package/lib/module/store/apis/deleteMember.js +4 -4
- package/lib/module/store/apis/deleteMember.js.map +1 -1
- package/lib/module/store/apis/deleteMessage.js +16 -12
- package/lib/module/store/apis/deleteMessage.js.map +1 -1
- package/lib/module/store/apis/deleteMessagesForChannel.js +11 -12
- package/lib/module/store/apis/deleteMessagesForChannel.js.map +1 -1
- package/lib/module/store/apis/deleteReaction.js +29 -17
- package/lib/module/store/apis/deleteReaction.js.map +1 -1
- package/lib/module/store/apis/deleteReactions.js +4 -4
- package/lib/module/store/apis/deleteReactions.js.map +1 -1
- package/lib/module/store/apis/dropPendingTasks.js +41 -0
- package/lib/module/store/apis/dropPendingTasks.js.map +1 -0
- package/lib/module/store/apis/getChannelMessages.js +1 -1
- package/lib/module/store/apis/getChannelMessages.js.map +1 -1
- package/lib/module/store/apis/getChannels.js +18 -21
- package/lib/module/store/apis/getChannels.js.map +1 -1
- package/lib/module/store/apis/getLastSyncedAt.js +3 -9
- package/lib/module/store/apis/getLastSyncedAt.js.map +1 -1
- package/lib/module/store/apis/getReactionsforFilterSort.js +5 -8
- package/lib/module/store/apis/getReactionsforFilterSort.js.map +1 -1
- package/lib/module/store/apis/index.js +103 -4
- package/lib/module/store/apis/index.js.map +1 -1
- package/lib/module/store/apis/insertReaction.js +4 -4
- package/lib/module/store/apis/insertReaction.js.map +1 -1
- package/lib/module/store/apis/queries/selectMessagesForChannels.js +1 -1
- package/lib/module/store/apis/queries/selectMessagesForChannels.js.map +1 -1
- package/lib/module/store/apis/queries/selectReactionsForMessages.js +25 -5
- package/lib/module/store/apis/queries/selectReactionsForMessages.js.map +1 -1
- package/lib/module/store/apis/softDeleteMessage.js +45 -0
- package/lib/module/store/apis/softDeleteMessage.js.map +1 -0
- package/lib/module/store/apis/updateMessage.js +7 -11
- package/lib/module/store/apis/updateMessage.js.map +1 -1
- package/lib/module/store/apis/updateReaction.js +11 -9
- package/lib/module/store/apis/updateReaction.js.map +1 -1
- package/lib/module/store/apis/upsertAppSettings.js +9 -7
- package/lib/module/store/apis/upsertAppSettings.js.map +1 -1
- package/lib/module/store/apis/upsertChannelData.js +4 -4
- package/lib/module/store/apis/upsertChannelData.js.map +1 -1
- package/lib/module/store/apis/upsertChannelDataFromChannel.js +3 -3
- package/lib/module/store/apis/upsertChannelDataFromChannel.js.map +1 -1
- package/lib/module/store/apis/upsertChannels.js +86 -83
- package/lib/module/store/apis/upsertChannels.js.map +1 -1
- package/lib/module/store/apis/upsertCidsForQuery.js +4 -4
- package/lib/module/store/apis/upsertCidsForQuery.js.map +1 -1
- package/lib/module/store/apis/upsertMembers.js +4 -4
- package/lib/module/store/apis/upsertMembers.js.map +1 -1
- package/lib/module/store/apis/upsertMessages.js +4 -4
- package/lib/module/store/apis/upsertMessages.js.map +1 -1
- package/lib/module/store/apis/upsertPoll.js +42 -0
- package/lib/module/store/apis/upsertPoll.js.map +1 -0
- package/lib/module/store/apis/upsertReads.js +4 -4
- package/lib/module/store/apis/upsertReads.js.map +1 -1
- package/lib/module/store/apis/upsertUserSyncStatus.js +13 -7
- package/lib/module/store/apis/upsertUserSyncStatus.js.map +1 -1
- package/lib/module/store/mappers/mapMemberToStorable.js +6 -2
- package/lib/module/store/mappers/mapMemberToStorable.js.map +1 -1
- package/lib/module/store/mappers/mapReadToStorable.js +3 -1
- package/lib/module/store/mappers/mapReadToStorable.js.map +1 -1
- package/lib/module/store/mappers/mapStorableToMember.js +5 -1
- package/lib/module/store/mappers/mapStorableToMember.js.map +1 -1
- package/lib/module/store/mappers/mapStorableToRead.js +3 -1
- package/lib/module/store/mappers/mapStorableToRead.js.map +1 -1
- package/lib/module/store/mappers/mapStorableToTask.js.map +1 -1
- package/lib/module/store/schema.js +2 -0
- package/lib/module/store/schema.js.map +1 -1
- package/lib/module/utils/addReactionToLocalState.js +62 -81
- package/lib/module/utils/addReactionToLocalState.js.map +1 -1
- package/lib/module/utils/removeReactionFromLocalState.js +0 -6
- package/lib/module/utils/removeReactionFromLocalState.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/Channel.d.ts.map +1 -1
- package/lib/typescript/components/Channel/hooks/useCreateThreadContext.d.ts.map +1 -1
- package/lib/typescript/components/ChannelList/ChannelList.d.ts.map +1 -1
- package/lib/typescript/components/ChannelList/hooks/usePaginatedChannels.d.ts +1 -1
- package/lib/typescript/components/ChannelList/hooks/usePaginatedChannels.d.ts.map +1 -1
- package/lib/typescript/components/ChannelPreview/hooks/useIsChannelMuted.d.ts.map +1 -1
- package/lib/typescript/components/Chat/Chat.d.ts.map +1 -1
- package/lib/typescript/components/Chat/hooks/useAppSettings.d.ts.map +1 -1
- package/lib/typescript/components/Chat/hooks/useSyncDatabase.d.ts +9 -1
- package/lib/typescript/components/Chat/hooks/useSyncDatabase.d.ts.map +1 -1
- package/lib/typescript/components/MessageMenu/MessageUserReactions.d.ts.map +1 -1
- package/lib/typescript/components/MessageMenu/hooks/useFetchReactions.d.ts.map +1 -1
- package/lib/typescript/contexts/messagesContext/MessagesContext.d.ts +1 -1
- package/lib/typescript/contexts/messagesContext/MessagesContext.d.ts.map +1 -1
- package/lib/typescript/hooks/useTranslatedMessage.d.ts.map +1 -1
- package/lib/typescript/index.d.ts +1 -0
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/store/OfflineDB.d.ts +112 -0
- package/lib/typescript/store/OfflineDB.d.ts.map +1 -0
- package/lib/typescript/store/SqliteClient.d.ts +1 -1
- package/lib/typescript/store/SqliteClient.d.ts.map +1 -1
- package/lib/typescript/store/apis/addPendingTask.d.ts +1 -1
- package/lib/typescript/store/apis/addPendingTask.d.ts.map +1 -1
- package/lib/typescript/store/apis/channelExists.d.ts +4 -0
- package/lib/typescript/store/apis/channelExists.d.ts.map +1 -0
- package/lib/typescript/store/apis/deleteChannel.d.ts +2 -2
- package/lib/typescript/store/apis/deleteChannel.d.ts.map +1 -1
- package/lib/typescript/store/apis/deleteMember.d.ts +2 -2
- package/lib/typescript/store/apis/deleteMember.d.ts.map +1 -1
- package/lib/typescript/store/apis/deleteMessage.d.ts +3 -3
- package/lib/typescript/store/apis/deleteMessage.d.ts.map +1 -1
- package/lib/typescript/store/apis/deleteMessagesForChannel.d.ts +4 -3
- package/lib/typescript/store/apis/deleteMessagesForChannel.d.ts.map +1 -1
- package/lib/typescript/store/apis/deleteReaction.d.ts +7 -6
- package/lib/typescript/store/apis/deleteReaction.d.ts.map +1 -1
- package/lib/typescript/store/apis/deleteReactions.d.ts +2 -2
- package/lib/typescript/store/apis/deleteReactions.d.ts.map +1 -1
- package/lib/typescript/store/apis/dropPendingTasks.d.ts +16 -0
- package/lib/typescript/store/apis/dropPendingTasks.d.ts.map +1 -0
- package/lib/typescript/store/apis/getChannels.d.ts.map +1 -1
- package/lib/typescript/store/apis/getLastSyncedAt.d.ts +1 -1
- package/lib/typescript/store/apis/getLastSyncedAt.d.ts.map +1 -1
- package/lib/typescript/store/apis/getPendingTasks.d.ts +1 -1
- package/lib/typescript/store/apis/getPendingTasks.d.ts.map +1 -1
- package/lib/typescript/store/apis/getReactionsforFilterSort.d.ts +5 -3
- package/lib/typescript/store/apis/getReactionsforFilterSort.d.ts.map +1 -1
- package/lib/typescript/store/apis/index.d.ts +10 -1
- package/lib/typescript/store/apis/index.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/queries/selectReactionsForMessages.d.ts +5 -1
- package/lib/typescript/store/apis/queries/selectReactionsForMessages.d.ts.map +1 -1
- package/lib/typescript/store/apis/softDeleteMessage.d.ts +5 -0
- package/lib/typescript/store/apis/softDeleteMessage.d.ts.map +1 -0
- 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/apis/upsertAppSettings.d.ts +3 -3
- package/lib/typescript/store/apis/upsertAppSettings.d.ts.map +1 -1
- package/lib/typescript/store/apis/upsertChannelData.d.ts +2 -2
- package/lib/typescript/store/apis/upsertChannelData.d.ts.map +1 -1
- package/lib/typescript/store/apis/upsertChannelDataFromChannel.d.ts +2 -2
- package/lib/typescript/store/apis/upsertChannelDataFromChannel.d.ts.map +1 -1
- package/lib/typescript/store/apis/upsertChannels.d.ts +3 -5
- package/lib/typescript/store/apis/upsertChannels.d.ts.map +1 -1
- package/lib/typescript/store/apis/upsertCidsForQuery.d.ts +2 -2
- package/lib/typescript/store/apis/upsertCidsForQuery.d.ts.map +1 -1
- package/lib/typescript/store/apis/upsertMembers.d.ts +2 -2
- package/lib/typescript/store/apis/upsertMembers.d.ts.map +1 -1
- package/lib/typescript/store/apis/upsertMessages.d.ts +2 -2
- package/lib/typescript/store/apis/upsertMessages.d.ts.map +1 -1
- package/lib/typescript/store/apis/upsertPoll.d.ts +7 -0
- package/lib/typescript/store/apis/upsertPoll.d.ts.map +1 -0
- package/lib/typescript/store/apis/upsertReads.d.ts +2 -2
- package/lib/typescript/store/apis/upsertReads.d.ts.map +1 -1
- package/lib/typescript/store/apis/upsertUserSyncStatus.d.ts +3 -2
- package/lib/typescript/store/apis/upsertUserSyncStatus.d.ts.map +1 -1
- package/lib/typescript/store/mappers/mapMemberToStorable.d.ts.map +1 -1
- package/lib/typescript/store/mappers/mapReadToStorable.d.ts.map +1 -1
- package/lib/typescript/store/mappers/mapStorableToMember.d.ts.map +1 -1
- package/lib/typescript/store/mappers/mapStorableToRead.d.ts.map +1 -1
- package/lib/typescript/store/mappers/mapStorableToTask.d.ts +2 -1
- package/lib/typescript/store/mappers/mapStorableToTask.d.ts.map +1 -1
- package/lib/typescript/store/mappers/mapTaskToStorable.d.ts +18 -10
- package/lib/typescript/store/mappers/mapTaskToStorable.d.ts.map +1 -1
- package/lib/typescript/store/schema.d.ts +3 -2
- package/lib/typescript/store/schema.d.ts.map +1 -1
- package/lib/typescript/utils/addReactionToLocalState.d.ts +1 -1
- package/lib/typescript/utils/addReactionToLocalState.d.ts.map +1 -1
- package/lib/typescript/utils/removeReactionFromLocalState.d.ts.map +1 -1
- package/package.json +5 -4
- package/src/__tests__/offline-support/offline-feature.js +894 -21
- package/src/__tests__/offline-support/optimistic-update.js +154 -44
- package/src/components/Channel/Channel.tsx +95 -118
- package/src/components/ChannelList/ChannelList.tsx +1 -23
- package/src/components/ChannelList/hooks/usePaginatedChannels.ts +9 -93
- package/src/components/ChannelPreview/hooks/useIsChannelMuted.ts +20 -2
- package/src/components/Chat/Chat.tsx +21 -45
- package/src/components/Chat/__tests__/Chat.test.js +21 -13
- package/src/components/Chat/hooks/useAppSettings.ts +17 -54
- package/src/components/Chat/hooks/useSyncDatabase.ts +11 -17
- package/src/components/MessageMenu/MessageUserReactions.tsx +7 -1
- package/src/components/MessageMenu/hooks/useFetchReactions.ts +68 -35
- package/src/contexts/messagesContext/MessagesContext.tsx +1 -1
- package/src/index.ts +1 -0
- package/src/mock-builders/event/channelVisible.js +7 -0
- package/src/mock-builders/event/memberAdded.js +3 -1
- package/src/mock-builders/event/memberRemoved.js +1 -0
- package/src/mock-builders/event/memberUpdated.js +1 -0
- package/src/mock-builders/event/messageNew.js +1 -0
- package/src/mock-builders/event/messageRead.js +5 -2
- package/src/mock-builders/event/notificationMarkUnread.js +3 -0
- package/src/mock-builders/generator/channel.ts +15 -3
- package/src/store/OfflineDB.ts +93 -0
- package/src/store/SqliteClient.ts +7 -1
- package/src/store/apis/addPendingTask.ts +2 -1
- package/src/store/apis/channelExists.ts +14 -0
- package/src/store/apis/deleteChannel.ts +9 -3
- package/src/store/apis/deleteMember.ts +4 -4
- package/src/store/apis/deleteMessage.ts +18 -8
- package/src/store/apis/deleteMessagesForChannel.ts +12 -8
- package/src/store/apis/deleteReaction.ts +39 -19
- package/src/store/apis/deleteReactions.ts +4 -4
- package/src/store/apis/dropPendingTasks.ts +32 -0
- package/src/store/apis/getChannelMessages.ts +1 -1
- package/src/store/apis/getChannels.ts +10 -7
- package/src/store/apis/getLastSyncedAt.ts +2 -5
- package/src/store/apis/getReactionsforFilterSort.ts +8 -7
- package/src/store/apis/index.ts +10 -1
- package/src/store/apis/insertReaction.ts +4 -4
- package/src/store/apis/queries/selectMessagesForChannels.ts +2 -2
- package/src/store/apis/queries/selectReactionsForMessages.ts +21 -2
- package/src/store/apis/softDeleteMessage.ts +32 -0
- package/src/store/apis/updateMessage.ts +3 -10
- package/src/store/apis/updateReaction.ts +7 -5
- package/src/store/apis/upsertAppSettings.ts +13 -9
- package/src/store/apis/upsertChannelData.ts +4 -4
- package/src/store/apis/upsertChannelDataFromChannel.ts +3 -3
- package/src/store/apis/upsertChannels.ts +14 -24
- package/src/store/apis/upsertCidsForQuery.ts +4 -4
- package/src/store/apis/upsertMembers.ts +4 -4
- package/src/store/apis/upsertMessages.ts +4 -4
- package/src/store/apis/upsertPoll.ts +29 -0
- package/src/store/apis/upsertReads.ts +4 -4
- package/src/store/apis/upsertUserSyncStatus.ts +13 -5
- package/src/store/mappers/mapMemberToStorable.ts +4 -0
- package/src/store/mappers/mapReadToStorable.ts +2 -1
- package/src/store/mappers/mapStorableToMember.ts +4 -0
- package/src/store/mappers/mapStorableToRead.ts +2 -1
- package/src/store/mappers/mapStorableToTask.ts +3 -1
- package/src/store/mappers/mapTaskToStorable.ts +1 -1
- package/src/store/schema.ts +5 -3
- package/src/utils/addReactionToLocalState.ts +9 -63
- package/src/utils/removeReactionFromLocalState.ts +0 -8
- package/src/version.json +1 -1
- package/lib/commonjs/components/Chat/hooks/handleEventToSyncDB.js +0 -406
- package/lib/commonjs/components/Chat/hooks/handleEventToSyncDB.js.map +0 -1
- package/lib/commonjs/store/apis/updatePollMessage.js +0 -84
- package/lib/commonjs/store/apis/updatePollMessage.js.map +0 -1
- package/lib/commonjs/utils/DBSyncManager.js +0 -470
- package/lib/commonjs/utils/DBSyncManager.js.map +0 -1
- package/lib/module/components/Chat/hooks/handleEventToSyncDB.js +0 -406
- package/lib/module/components/Chat/hooks/handleEventToSyncDB.js.map +0 -1
- package/lib/module/store/apis/updatePollMessage.js +0 -84
- package/lib/module/store/apis/updatePollMessage.js.map +0 -1
- package/lib/module/utils/DBSyncManager.js +0 -470
- package/lib/module/utils/DBSyncManager.js.map +0 -1
- package/lib/typescript/components/Chat/hooks/handleEventToSyncDB.d.ts +0 -4
- package/lib/typescript/components/Chat/hooks/handleEventToSyncDB.d.ts.map +0 -1
- package/lib/typescript/store/apis/updatePollMessage.d.ts +0 -10
- package/lib/typescript/store/apis/updatePollMessage.d.ts.map +0 -1
- package/lib/typescript/utils/DBSyncManager.d.ts +0 -50
- package/lib/typescript/utils/DBSyncManager.d.ts.map +0 -1
- package/src/components/Chat/hooks/handleEventToSyncDB.ts +0 -290
- package/src/store/apis/updatePollMessage.ts +0 -71
- package/src/utils/DBSyncManager.ts +0 -242
|
@@ -7,11 +7,12 @@ import { v4 as uuidv4 } from 'uuid';
|
|
|
7
7
|
|
|
8
8
|
import { Channel } from '../../components/Channel/Channel';
|
|
9
9
|
import { Chat } from '../../components/Chat/Chat';
|
|
10
|
-
import { MessagesContext } from '../../contexts';
|
|
10
|
+
import { MessageInputContext, MessagesContext } from '../../contexts';
|
|
11
11
|
import { deleteMessageApi } from '../../mock-builders/api/deleteMessage';
|
|
12
12
|
import { deleteReactionApi } from '../../mock-builders/api/deleteReaction';
|
|
13
13
|
import { erroredDeleteApi, erroredPostApi } from '../../mock-builders/api/error';
|
|
14
14
|
import { getOrCreateChannelApi } from '../../mock-builders/api/getOrCreateChannel';
|
|
15
|
+
import { sendMessageApi } from '../../mock-builders/api/sendMessage';
|
|
15
16
|
import { sendReactionApi } from '../../mock-builders/api/sendReaction';
|
|
16
17
|
import { useMockedApis } from '../../mock-builders/api/useMockedApis';
|
|
17
18
|
import dispatchConnectionChangedEvent from '../../mock-builders/event/connectionChanged';
|
|
@@ -112,6 +113,7 @@ export const OptimisticUpdates = () => {
|
|
|
112
113
|
channels: [channelResponse],
|
|
113
114
|
isLatestMessagesSet: true,
|
|
114
115
|
});
|
|
116
|
+
chatClient.wsConnection = { isHealthy: true, onlineStatusChanged: jest.fn() };
|
|
115
117
|
});
|
|
116
118
|
|
|
117
119
|
afterEach(() => {
|
|
@@ -177,7 +179,7 @@ export const OptimisticUpdates = () => {
|
|
|
177
179
|
});
|
|
178
180
|
});
|
|
179
181
|
|
|
180
|
-
it('pending task should be cleared if deleteMessage request is
|
|
182
|
+
it('pending task should be cleared if deleteMessage request is successful', async () => {
|
|
181
183
|
const message = generateMessage();
|
|
182
184
|
render(
|
|
183
185
|
<Chat client={chatClient} enableOfflineSupport>
|
|
@@ -237,7 +239,7 @@ export const OptimisticUpdates = () => {
|
|
|
237
239
|
});
|
|
238
240
|
});
|
|
239
241
|
|
|
240
|
-
it('pending task should be cleared if sendReaction request is
|
|
242
|
+
it('pending task should be cleared if sendReaction request is successful', async () => {
|
|
241
243
|
const reaction = generateReaction();
|
|
242
244
|
const targetMessage = channel.state.messages[0];
|
|
243
245
|
|
|
@@ -264,6 +266,69 @@ export const OptimisticUpdates = () => {
|
|
|
264
266
|
});
|
|
265
267
|
});
|
|
266
268
|
|
|
269
|
+
describe('send message', () => {
|
|
270
|
+
it('pending task should exist if sendMessage request fails', async () => {
|
|
271
|
+
const newMessage = generateMessage();
|
|
272
|
+
|
|
273
|
+
render(
|
|
274
|
+
<Chat client={chatClient} enableOfflineSupport>
|
|
275
|
+
<Channel channel={channel} initialValue={newMessage.text}>
|
|
276
|
+
<CallbackEffectWithContext
|
|
277
|
+
callback={async ({ sendMessage }) => {
|
|
278
|
+
useMockedApis(chatClient, [erroredPostApi()]);
|
|
279
|
+
try {
|
|
280
|
+
await sendMessage({ customMessageData: newMessage });
|
|
281
|
+
} catch (e) {
|
|
282
|
+
// do nothing
|
|
283
|
+
}
|
|
284
|
+
}}
|
|
285
|
+
context={MessageInputContext}
|
|
286
|
+
>
|
|
287
|
+
<View testID='children' />
|
|
288
|
+
</CallbackEffectWithContext>
|
|
289
|
+
</Channel>
|
|
290
|
+
</Chat>,
|
|
291
|
+
);
|
|
292
|
+
await waitFor(() => expect(screen.getByTestId('children')).toBeTruthy());
|
|
293
|
+
await waitFor(async () => {
|
|
294
|
+
const pendingTasksRows = await BetterSqlite.selectFromTable('pendingTasks');
|
|
295
|
+
const pendingTaskType = pendingTasksRows?.[0]?.type;
|
|
296
|
+
const pendingTaskPayload = JSON.parse(pendingTasksRows?.[0]?.payload || '{}');
|
|
297
|
+
expect(pendingTaskType).toBe('send-message');
|
|
298
|
+
expect(pendingTaskPayload[0].id).toEqual(newMessage.id);
|
|
299
|
+
expect(pendingTaskPayload[0].text).toEqual(newMessage.text);
|
|
300
|
+
});
|
|
301
|
+
});
|
|
302
|
+
|
|
303
|
+
it('pending task should be cleared if sendMessage request is successful', async () => {
|
|
304
|
+
const newMessage = generateMessage();
|
|
305
|
+
|
|
306
|
+
// initialValue is needed as a prop to trick the message input ctx into thinking
|
|
307
|
+
// we are sending a message.
|
|
308
|
+
render(
|
|
309
|
+
<Chat client={chatClient} enableOfflineSupport>
|
|
310
|
+
<Channel channel={channel} initialValue={newMessage.text}>
|
|
311
|
+
<CallbackEffectWithContext
|
|
312
|
+
callback={async ({ sendMessage }) => {
|
|
313
|
+
useMockedApis(chatClient, [sendMessageApi(newMessage)]);
|
|
314
|
+
await sendMessage({ customMessageData: newMessage });
|
|
315
|
+
}}
|
|
316
|
+
context={MessageInputContext}
|
|
317
|
+
>
|
|
318
|
+
<View testID='children' />
|
|
319
|
+
</CallbackEffectWithContext>
|
|
320
|
+
</Channel>
|
|
321
|
+
</Chat>,
|
|
322
|
+
);
|
|
323
|
+
await waitFor(() => expect(screen.getByTestId('children')).toBeTruthy());
|
|
324
|
+
|
|
325
|
+
await waitFor(async () => {
|
|
326
|
+
const pendingTasksRows = await BetterSqlite.selectFromTable('pendingTasks');
|
|
327
|
+
expect(pendingTasksRows.length).toBe(0);
|
|
328
|
+
});
|
|
329
|
+
});
|
|
330
|
+
});
|
|
331
|
+
|
|
267
332
|
describe('delete reaction', () => {
|
|
268
333
|
it('pending task should exist if deleteReaction request fails', async () => {
|
|
269
334
|
const reaction = generateReaction();
|
|
@@ -298,7 +363,7 @@ export const OptimisticUpdates = () => {
|
|
|
298
363
|
});
|
|
299
364
|
});
|
|
300
365
|
|
|
301
|
-
it('pending task should be cleared if deleteReaction request is
|
|
366
|
+
it('pending task should be cleared if deleteReaction request is successful', async () => {
|
|
302
367
|
const reaction = generateReaction();
|
|
303
368
|
const targetMessage = channel.state.messages[0];
|
|
304
369
|
|
|
@@ -326,52 +391,97 @@ export const OptimisticUpdates = () => {
|
|
|
326
391
|
});
|
|
327
392
|
});
|
|
328
393
|
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
<
|
|
336
|
-
<
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
394
|
+
describe('pending task execution', () => {
|
|
395
|
+
it('pending task should be executed after connection is recovered', async () => {
|
|
396
|
+
const message = channel.state.messages[0];
|
|
397
|
+
const reaction = generateReaction();
|
|
398
|
+
|
|
399
|
+
render(
|
|
400
|
+
<Chat client={chatClient} enableOfflineSupport>
|
|
401
|
+
<Channel channel={channel} initialValue={message.text}>
|
|
402
|
+
<CallbackEffectWithContext
|
|
403
|
+
callback={async ({ deleteMessage, sendReaction }) => {
|
|
404
|
+
useMockedApis(chatClient, [erroredDeleteApi()]);
|
|
405
|
+
try {
|
|
406
|
+
await deleteMessage(message);
|
|
407
|
+
} catch (e) {
|
|
408
|
+
// do nothing
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
useMockedApis(chatClient, [erroredPostApi()]);
|
|
412
|
+
try {
|
|
413
|
+
await sendReaction(reaction.type, message.id);
|
|
414
|
+
} catch (e) {
|
|
415
|
+
// do nothing
|
|
416
|
+
}
|
|
417
|
+
}}
|
|
418
|
+
context={MessagesContext}
|
|
419
|
+
>
|
|
420
|
+
<View testID='children' />
|
|
421
|
+
</CallbackEffectWithContext>
|
|
422
|
+
</Channel>
|
|
423
|
+
</Chat>,
|
|
424
|
+
);
|
|
425
|
+
await waitFor(() => expect(screen.getByTestId('children')).toBeTruthy());
|
|
426
|
+
|
|
427
|
+
await waitFor(async () => {
|
|
428
|
+
const pendingTasksRows = await BetterSqlite.selectFromTable('pendingTasks');
|
|
429
|
+
|
|
430
|
+
expect(pendingTasksRows.length).toBe(2);
|
|
431
|
+
});
|
|
432
|
+
|
|
433
|
+
const deleteMessageSpy = jest.spyOn(chatClient, '_deleteMessage').mockImplementation();
|
|
434
|
+
const sendReactionSpy = jest.spyOn(channel, '_sendReaction').mockImplementation();
|
|
360
435
|
|
|
361
|
-
|
|
362
|
-
const pendingTasksRows = await BetterSqlite.selectFromTable('pendingTasks');
|
|
436
|
+
act(() => dispatchConnectionChangedEvent(chatClient, true));
|
|
363
437
|
|
|
364
|
-
|
|
438
|
+
await waitFor(() => {
|
|
439
|
+
expect(deleteMessageSpy).toHaveBeenCalled();
|
|
440
|
+
expect(sendReactionSpy).toHaveBeenCalled();
|
|
441
|
+
});
|
|
365
442
|
});
|
|
366
443
|
|
|
367
|
-
|
|
368
|
-
|
|
444
|
+
// This is a separate test so CallbackEffectWithContext does not need to be modified in order
|
|
445
|
+
// to accept multiple contexts. It can be improved in the future.
|
|
446
|
+
it('send message pending task should be executed after connection is recovered', async () => {
|
|
447
|
+
const newMessage = generateMessage();
|
|
369
448
|
|
|
370
|
-
|
|
449
|
+
// initialValue is needed as a prop to trick the message input ctx into thinking
|
|
450
|
+
// we are sending a message.
|
|
451
|
+
render(
|
|
452
|
+
<Chat client={chatClient} enableOfflineSupport>
|
|
453
|
+
<Channel channel={channel} initialValue={newMessage.text}>
|
|
454
|
+
<CallbackEffectWithContext
|
|
455
|
+
callback={async ({ sendMessage }) => {
|
|
456
|
+
useMockedApis(chatClient, [erroredPostApi()]);
|
|
457
|
+
try {
|
|
458
|
+
await sendMessage({ customMessageData: newMessage });
|
|
459
|
+
} catch (e) {
|
|
460
|
+
// do nothing
|
|
461
|
+
}
|
|
462
|
+
}}
|
|
463
|
+
context={MessageInputContext}
|
|
464
|
+
>
|
|
465
|
+
<View testID='children' />
|
|
466
|
+
</CallbackEffectWithContext>
|
|
467
|
+
</Channel>
|
|
468
|
+
</Chat>,
|
|
469
|
+
);
|
|
470
|
+
await waitFor(() => expect(screen.getByTestId('children')).toBeTruthy());
|
|
471
|
+
|
|
472
|
+
await waitFor(async () => {
|
|
473
|
+
const pendingTasksRows = await BetterSqlite.selectFromTable('pendingTasks');
|
|
474
|
+
|
|
475
|
+
expect(pendingTasksRows.length).toBe(1);
|
|
476
|
+
});
|
|
371
477
|
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
478
|
+
const sendMessageSpy = jest.spyOn(channel, '_sendMessage').mockImplementation();
|
|
479
|
+
|
|
480
|
+
act(() => dispatchConnectionChangedEvent(chatClient, true));
|
|
481
|
+
|
|
482
|
+
await waitFor(() => {
|
|
483
|
+
expect(sendMessageSpy).toHaveBeenCalled();
|
|
484
|
+
});
|
|
375
485
|
});
|
|
376
486
|
});
|
|
377
487
|
});
|
|
@@ -95,9 +95,7 @@ import * as dbApi from '../../store/apis';
|
|
|
95
95
|
import { ChannelUnreadState, FileTypes } from '../../types/types';
|
|
96
96
|
import { addReactionToLocalState } from '../../utils/addReactionToLocalState';
|
|
97
97
|
import { compressedImageURI } from '../../utils/compressImage';
|
|
98
|
-
import { DBSyncManager } from '../../utils/DBSyncManager';
|
|
99
98
|
import { patchMessageTextCommand } from '../../utils/patchMessageTextCommand';
|
|
100
|
-
import { removeReactionFromLocalState } from '../../utils/removeReactionFromLocalState';
|
|
101
99
|
import { removeReservedFields } from '../../utils/removeReservedFields';
|
|
102
100
|
import {
|
|
103
101
|
defaultEmojiSearchIndex,
|
|
@@ -260,7 +258,7 @@ export type ChannelPropsWithContext = Pick<ChannelContextValue, 'channel'> &
|
|
|
260
258
|
| 'StickyHeader'
|
|
261
259
|
>
|
|
262
260
|
> &
|
|
263
|
-
Pick<ChatContextValue, 'client' | 'enableOfflineSupport'> &
|
|
261
|
+
Pick<ChatContextValue, 'client' | 'enableOfflineSupport' | 'isOnline'> &
|
|
264
262
|
Partial<
|
|
265
263
|
Omit<
|
|
266
264
|
InputMessageInputContextValue,
|
|
@@ -672,6 +670,7 @@ const ChannelWithContext = (props: PropsWithChildren<ChannelPropsWithContext>) =
|
|
|
672
670
|
UploadProgressIndicator = UploadProgressIndicatorDefault,
|
|
673
671
|
UrlPreview = CardDefault,
|
|
674
672
|
VideoThumbnail = VideoThumbnailDefault,
|
|
673
|
+
isOnline,
|
|
675
674
|
} = props;
|
|
676
675
|
|
|
677
676
|
const { thread: threadProps, threadInstance } = threadFromProps;
|
|
@@ -1039,14 +1038,6 @@ const ChannelWithContext = (props: PropsWithChildren<ChannelPropsWithContext>) =
|
|
|
1039
1038
|
syncingChannelRef.current = true;
|
|
1040
1039
|
setError(false);
|
|
1041
1040
|
|
|
1042
|
-
if (channelMessagesState?.messages) {
|
|
1043
|
-
await channel?.watch({
|
|
1044
|
-
messages: {
|
|
1045
|
-
limit: channelMessagesState.messages.length + 30,
|
|
1046
|
-
},
|
|
1047
|
-
});
|
|
1048
|
-
}
|
|
1049
|
-
|
|
1050
1041
|
const parseMessage = (message: LocalMessage) =>
|
|
1051
1042
|
({
|
|
1052
1043
|
...message,
|
|
@@ -1056,6 +1047,14 @@ const ChannelWithContext = (props: PropsWithChildren<ChannelPropsWithContext>) =
|
|
|
1056
1047
|
}) as unknown as MessageResponse;
|
|
1057
1048
|
|
|
1058
1049
|
try {
|
|
1050
|
+
if (channelMessagesState?.messages) {
|
|
1051
|
+
await channel?.watch({
|
|
1052
|
+
messages: {
|
|
1053
|
+
limit: channelMessagesState.messages.length + 30,
|
|
1054
|
+
},
|
|
1055
|
+
});
|
|
1056
|
+
}
|
|
1057
|
+
|
|
1059
1058
|
if (!thread) {
|
|
1060
1059
|
copyChannelState();
|
|
1061
1060
|
|
|
@@ -1102,12 +1101,14 @@ const ChannelWithContext = (props: PropsWithChildren<ChannelPropsWithContext>) =
|
|
|
1102
1101
|
};
|
|
1103
1102
|
let connectionChangedSubscription: ReturnType<ChannelType['on']>;
|
|
1104
1103
|
|
|
1105
|
-
if (enableOfflineSupport) {
|
|
1106
|
-
connectionChangedSubscription =
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1104
|
+
if (enableOfflineSupport && client.offlineDb) {
|
|
1105
|
+
connectionChangedSubscription = client.offlineDb.syncManager.onSyncStatusChange(
|
|
1106
|
+
(statusChanged) => {
|
|
1107
|
+
if (statusChanged) {
|
|
1108
|
+
connectionChangedHandler();
|
|
1109
|
+
}
|
|
1110
|
+
},
|
|
1111
|
+
);
|
|
1111
1112
|
} else {
|
|
1112
1113
|
connectionChangedSubscription = client.on('connection.changed', (event) => {
|
|
1113
1114
|
if (event.online) {
|
|
@@ -1118,8 +1119,7 @@ const ChannelWithContext = (props: PropsWithChildren<ChannelPropsWithContext>) =
|
|
|
1118
1119
|
return () => {
|
|
1119
1120
|
connectionChangedSubscription.unsubscribe();
|
|
1120
1121
|
};
|
|
1121
|
-
|
|
1122
|
-
}, [enableOfflineSupport, shouldSyncChannel]);
|
|
1122
|
+
}, [enableOfflineSupport, client, shouldSyncChannel]);
|
|
1123
1123
|
|
|
1124
1124
|
// In case the channel is disconnected which may happen when channel is deleted,
|
|
1125
1125
|
// underlying js client throws an error. Following function ensures that Channel component
|
|
@@ -1346,7 +1346,33 @@ const ChannelWithContext = (props: PropsWithChildren<ChannelPropsWithContext>) =
|
|
|
1346
1346
|
|
|
1347
1347
|
const sendMessageRequest = useStableCallback(
|
|
1348
1348
|
async (message: MessageResponse, retrying?: boolean) => {
|
|
1349
|
+
let failedMessageUpdated = false;
|
|
1350
|
+
const handleFailedMessage = async () => {
|
|
1351
|
+
if (!failedMessageUpdated) {
|
|
1352
|
+
const updatedMessage = {
|
|
1353
|
+
...message,
|
|
1354
|
+
cid: channel.cid,
|
|
1355
|
+
status: MessageStatusTypes.FAILED,
|
|
1356
|
+
};
|
|
1357
|
+
updateMessage(updatedMessage);
|
|
1358
|
+
threadInstance?.upsertReplyLocally?.({ message: updatedMessage });
|
|
1359
|
+
optimisticallyUpdatedNewMessages.delete(message.id);
|
|
1360
|
+
|
|
1361
|
+
if (enableOfflineSupport) {
|
|
1362
|
+
await dbApi.updateMessage({
|
|
1363
|
+
message: updatedMessage,
|
|
1364
|
+
});
|
|
1365
|
+
}
|
|
1366
|
+
|
|
1367
|
+
failedMessageUpdated = true;
|
|
1368
|
+
}
|
|
1369
|
+
};
|
|
1370
|
+
|
|
1349
1371
|
try {
|
|
1372
|
+
if (!isOnline) {
|
|
1373
|
+
await handleFailedMessage();
|
|
1374
|
+
}
|
|
1375
|
+
|
|
1350
1376
|
const updatedMessage = await uploadPendingAttachments(message);
|
|
1351
1377
|
const extraFields = omit(updatedMessage, [
|
|
1352
1378
|
'__html',
|
|
@@ -1386,39 +1412,33 @@ const ChannelWithContext = (props: PropsWithChildren<ChannelPropsWithContext>) =
|
|
|
1386
1412
|
} as StreamMessage;
|
|
1387
1413
|
|
|
1388
1414
|
let messageResponse = {} as SendMessageAPIResponse;
|
|
1415
|
+
|
|
1389
1416
|
if (doSendMessageRequest) {
|
|
1390
1417
|
messageResponse = await doSendMessageRequest(channel?.cid || '', messageData);
|
|
1391
1418
|
} else if (channel) {
|
|
1392
1419
|
messageResponse = await channel.sendMessage(messageData);
|
|
1393
1420
|
}
|
|
1394
1421
|
|
|
1395
|
-
if (messageResponse
|
|
1396
|
-
|
|
1422
|
+
if (messageResponse?.message) {
|
|
1423
|
+
const newMessageResponse = {
|
|
1424
|
+
...messageResponse.message,
|
|
1425
|
+
status: MessageStatusTypes.RECEIVED,
|
|
1426
|
+
};
|
|
1397
1427
|
|
|
1398
1428
|
if (enableOfflineSupport) {
|
|
1399
1429
|
await dbApi.updateMessage({
|
|
1400
|
-
message: { ...
|
|
1430
|
+
message: { ...newMessageResponse, cid: channel.cid },
|
|
1401
1431
|
});
|
|
1402
1432
|
}
|
|
1403
1433
|
if (retrying) {
|
|
1404
|
-
replaceMessage(message,
|
|
1434
|
+
replaceMessage(message, newMessageResponse);
|
|
1405
1435
|
} else {
|
|
1406
|
-
updateMessage(
|
|
1436
|
+
updateMessage(newMessageResponse, {}, true);
|
|
1407
1437
|
}
|
|
1408
1438
|
}
|
|
1409
1439
|
} catch (err) {
|
|
1410
1440
|
console.log(err);
|
|
1411
|
-
|
|
1412
|
-
const updatedMessage = { ...message, cid: channel.cid };
|
|
1413
|
-
updateMessage(updatedMessage);
|
|
1414
|
-
threadInstance?.upsertReplyLocally?.({ message: updatedMessage });
|
|
1415
|
-
optimisticallyUpdatedNewMessages.delete(message.id);
|
|
1416
|
-
|
|
1417
|
-
if (enableOfflineSupport) {
|
|
1418
|
-
await dbApi.updateMessage({
|
|
1419
|
-
message: { ...message, cid: channel.cid },
|
|
1420
|
-
});
|
|
1421
|
-
}
|
|
1441
|
+
await handleFailedMessage();
|
|
1422
1442
|
}
|
|
1423
1443
|
},
|
|
1424
1444
|
);
|
|
@@ -1512,10 +1532,8 @@ const ChannelWithContext = (props: PropsWithChildren<ChannelPropsWithContext>) =
|
|
|
1512
1532
|
}
|
|
1513
1533
|
}
|
|
1514
1534
|
|
|
1515
|
-
if (
|
|
1516
|
-
await
|
|
1517
|
-
id: message.id,
|
|
1518
|
-
});
|
|
1535
|
+
if (client.offlineDb) {
|
|
1536
|
+
await client.offlineDb.handleRemoveMessage({ messageId: message.id });
|
|
1519
1537
|
}
|
|
1520
1538
|
},
|
|
1521
1539
|
);
|
|
@@ -1533,79 +1551,49 @@ const ChannelWithContext = (props: PropsWithChildren<ChannelPropsWithContext>) =
|
|
|
1533
1551
|
{ enforce_unique: enforceUniqueReaction },
|
|
1534
1552
|
];
|
|
1535
1553
|
|
|
1536
|
-
if (
|
|
1537
|
-
await
|
|
1538
|
-
|
|
1539
|
-
|
|
1554
|
+
if (enableOfflineSupport) {
|
|
1555
|
+
await addReactionToLocalState({
|
|
1556
|
+
channel,
|
|
1557
|
+
enforceUniqueReaction,
|
|
1558
|
+
messageId,
|
|
1559
|
+
reactionType: type,
|
|
1560
|
+
user: client.user,
|
|
1561
|
+
});
|
|
1540
1562
|
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
enforceUniqueReaction,
|
|
1544
|
-
messageId,
|
|
1545
|
-
reactionType: type,
|
|
1546
|
-
user: client.user,
|
|
1547
|
-
});
|
|
1563
|
+
copyMessagesStateFromChannel(channel);
|
|
1564
|
+
}
|
|
1548
1565
|
|
|
1549
|
-
|
|
1566
|
+
const sendReactionResponse = await channel.sendReaction(...payload);
|
|
1550
1567
|
|
|
1551
|
-
const sendReactionResponse = await DBSyncManager.queueTask({
|
|
1552
|
-
client,
|
|
1553
|
-
task: {
|
|
1554
|
-
channelId: channel.id,
|
|
1555
|
-
channelType: channel.type,
|
|
1556
|
-
messageId,
|
|
1557
|
-
payload,
|
|
1558
|
-
type: 'send-reaction',
|
|
1559
|
-
},
|
|
1560
|
-
});
|
|
1561
1568
|
if (sendReactionResponse?.message) {
|
|
1562
1569
|
threadInstance?.upsertReplyLocally?.({ message: sendReactionResponse.message });
|
|
1563
1570
|
}
|
|
1564
1571
|
});
|
|
1565
1572
|
|
|
1566
1573
|
const deleteMessage: MessagesContextValue['deleteMessage'] = useStableCallback(
|
|
1567
|
-
async (message) => {
|
|
1574
|
+
async (message, hardDelete = false) => {
|
|
1568
1575
|
if (!channel.id) {
|
|
1569
1576
|
throw new Error('Channel has not been initialized yet');
|
|
1570
1577
|
}
|
|
1571
1578
|
|
|
1572
|
-
if (
|
|
1573
|
-
|
|
1574
|
-
await removeMessage(message);
|
|
1575
|
-
return;
|
|
1576
|
-
}
|
|
1577
|
-
await client.deleteMessage(message.id);
|
|
1579
|
+
if (message.status === MessageStatusTypes.FAILED) {
|
|
1580
|
+
await removeMessage(message);
|
|
1578
1581
|
return;
|
|
1579
1582
|
}
|
|
1583
|
+
const updatedMessage = {
|
|
1584
|
+
...message,
|
|
1585
|
+
cid: channel.cid,
|
|
1586
|
+
deleted_at: new Date(),
|
|
1587
|
+
type: 'deleted' as MessageLabel,
|
|
1588
|
+
};
|
|
1589
|
+
updateMessage(updatedMessage);
|
|
1580
1590
|
|
|
1581
|
-
|
|
1582
|
-
await DBSyncManager.dropPendingTasks({ messageId: message.id });
|
|
1583
|
-
await removeMessage(message);
|
|
1584
|
-
} else {
|
|
1585
|
-
const updatedMessage = {
|
|
1586
|
-
...message,
|
|
1587
|
-
cid: channel.cid,
|
|
1588
|
-
deleted_at: new Date(),
|
|
1589
|
-
type: 'deleted' as MessageLabel,
|
|
1590
|
-
};
|
|
1591
|
-
updateMessage(updatedMessage);
|
|
1592
|
-
|
|
1593
|
-
threadInstance?.upsertReplyLocally({ message: updatedMessage });
|
|
1594
|
-
|
|
1595
|
-
const data = await DBSyncManager.queueTask({
|
|
1596
|
-
client,
|
|
1597
|
-
task: {
|
|
1598
|
-
channelId: channel.id,
|
|
1599
|
-
channelType: channel.type,
|
|
1600
|
-
messageId: message.id,
|
|
1601
|
-
payload: [message.id],
|
|
1602
|
-
type: 'delete-message',
|
|
1603
|
-
},
|
|
1604
|
-
});
|
|
1591
|
+
threadInstance?.upsertReplyLocally({ message: updatedMessage });
|
|
1605
1592
|
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1593
|
+
const data = await client.deleteMessage(message.id, hardDelete);
|
|
1594
|
+
|
|
1595
|
+
if (data?.message) {
|
|
1596
|
+
updateMessage({ ...data.message });
|
|
1609
1597
|
}
|
|
1610
1598
|
},
|
|
1611
1599
|
);
|
|
@@ -1618,30 +1606,18 @@ const ChannelWithContext = (props: PropsWithChildren<ChannelPropsWithContext>) =
|
|
|
1618
1606
|
|
|
1619
1607
|
const payload: Parameters<ChannelClass['deleteReaction']> = [messageId, type];
|
|
1620
1608
|
|
|
1621
|
-
if (
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
messageId,
|
|
1629
|
-
reactionType: type,
|
|
1630
|
-
user: client.user,
|
|
1631
|
-
});
|
|
1609
|
+
if (enableOfflineSupport) {
|
|
1610
|
+
channel.state.removeReaction({
|
|
1611
|
+
created_at: '',
|
|
1612
|
+
message_id: messageId,
|
|
1613
|
+
type,
|
|
1614
|
+
updated_at: '',
|
|
1615
|
+
});
|
|
1632
1616
|
|
|
1633
|
-
|
|
1617
|
+
copyMessagesStateFromChannel(channel);
|
|
1618
|
+
}
|
|
1634
1619
|
|
|
1635
|
-
await
|
|
1636
|
-
client,
|
|
1637
|
-
task: {
|
|
1638
|
-
channelId: channel.id,
|
|
1639
|
-
channelType: channel.type,
|
|
1640
|
-
messageId,
|
|
1641
|
-
payload,
|
|
1642
|
-
type: 'delete-reaction',
|
|
1643
|
-
},
|
|
1644
|
-
});
|
|
1620
|
+
await channel.deleteReaction(...payload);
|
|
1645
1621
|
},
|
|
1646
1622
|
);
|
|
1647
1623
|
|
|
@@ -2050,7 +2026,7 @@ export type ChannelProps = Partial<Omit<ChannelPropsWithContext, 'channel' | 'th
|
|
|
2050
2026
|
* @example ./Channel.md
|
|
2051
2027
|
*/
|
|
2052
2028
|
export const Channel = (props: PropsWithChildren<ChannelProps>) => {
|
|
2053
|
-
const { client, enableOfflineSupport, isMessageAIGenerated } = useChatContext();
|
|
2029
|
+
const { client, enableOfflineSupport, isOnline, isMessageAIGenerated } = useChatContext();
|
|
2054
2030
|
const { t } = useTranslationContext();
|
|
2055
2031
|
|
|
2056
2032
|
const threadFromProps = props?.thread;
|
|
@@ -2082,6 +2058,7 @@ export const Channel = (props: PropsWithChildren<ChannelProps>) => {
|
|
|
2082
2058
|
shouldSyncChannel={shouldSyncChannel}
|
|
2083
2059
|
{...{
|
|
2084
2060
|
isMessageAIGenerated,
|
|
2061
|
+
isOnline,
|
|
2085
2062
|
setThreadMessages,
|
|
2086
2063
|
thread,
|
|
2087
2064
|
threadMessages,
|
|
@@ -19,7 +19,6 @@ import {
|
|
|
19
19
|
ChannelsProvider,
|
|
20
20
|
} from '../../contexts/channelsContext/ChannelsContext';
|
|
21
21
|
import { useChatContext } from '../../contexts/chatContext/ChatContext';
|
|
22
|
-
import { upsertCidsForQuery } from '../../store/apis/upsertCidsForQuery';
|
|
23
22
|
import type { ChannelListEventListenerOptions } from '../../types/types';
|
|
24
23
|
import { ChannelPreviewMessenger } from '../ChannelPreview/ChannelPreviewMessenger';
|
|
25
24
|
import { EmptyStateIndicator as EmptyStateIndicatorDefault } from '../Indicators/EmptyStateIndicator';
|
|
@@ -321,7 +320,7 @@ export const ChannelList = (props: ChannelListProps) => {
|
|
|
321
320
|
]);
|
|
322
321
|
|
|
323
322
|
useEffect(() => {
|
|
324
|
-
channelManager.setOptions({ abortInFlightQuery:
|
|
323
|
+
channelManager.setOptions({ abortInFlightQuery: false, lockChannelOrder });
|
|
325
324
|
}, [channelManager, lockChannelOrder]);
|
|
326
325
|
|
|
327
326
|
useEffect(() => {
|
|
@@ -343,7 +342,6 @@ export const ChannelList = (props: ChannelListProps) => {
|
|
|
343
342
|
refreshing,
|
|
344
343
|
refreshList,
|
|
345
344
|
reloadList,
|
|
346
|
-
staticChannelsActive,
|
|
347
345
|
} = usePaginatedChannels({
|
|
348
346
|
channelManager,
|
|
349
347
|
enableOfflineSupport,
|
|
@@ -358,26 +356,6 @@ export const ChannelList = (props: ChannelListProps) => {
|
|
|
358
356
|
setChannels: channelManager.setChannels,
|
|
359
357
|
});
|
|
360
358
|
|
|
361
|
-
const channelIdsStr = channels?.reduce((acc, channel) => `${acc}${channel.cid}`, '');
|
|
362
|
-
|
|
363
|
-
useEffect(() => {
|
|
364
|
-
if (
|
|
365
|
-
channels == null ||
|
|
366
|
-
!channelListInitialized ||
|
|
367
|
-
staticChannelsActive ||
|
|
368
|
-
!enableOfflineSupport
|
|
369
|
-
) {
|
|
370
|
-
return;
|
|
371
|
-
}
|
|
372
|
-
|
|
373
|
-
upsertCidsForQuery({
|
|
374
|
-
cids: channels.map((c) => c.cid),
|
|
375
|
-
filters,
|
|
376
|
-
sort,
|
|
377
|
-
});
|
|
378
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
379
|
-
}, [channelIdsStr, staticChannelsActive]);
|
|
380
|
-
|
|
381
359
|
const channelsContext = useCreateChannelsContext({
|
|
382
360
|
additionalFlatListProps,
|
|
383
361
|
channelListInitialized,
|