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
|
@@ -3,7 +3,6 @@ import { useCallback, useEffect, useMemo, useState } from 'react';
|
|
|
3
3
|
import { LocalMessage, ReactionResponse, ReactionSort } from 'stream-chat';
|
|
4
4
|
|
|
5
5
|
import { useChatContext } from '../../../contexts/chatContext/ChatContext';
|
|
6
|
-
import { getReactionsForFilterSort } from '../../../store/apis/getReactionsforFilterSort';
|
|
7
6
|
|
|
8
7
|
export type UseFetchReactionParams = {
|
|
9
8
|
limit?: number;
|
|
@@ -28,25 +27,10 @@ export const useFetchReactions = ({
|
|
|
28
27
|
const sortString = useMemo(() => JSON.stringify(sort), [sort]);
|
|
29
28
|
|
|
30
29
|
const fetchReactions = useCallback(async () => {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
const reactionsFromDB = await getReactionsForFilterSort({
|
|
36
|
-
currentMessageId: messageId,
|
|
37
|
-
filters: reactionType ? { type: reactionType } : {},
|
|
38
|
-
sort,
|
|
39
|
-
});
|
|
40
|
-
if (reactionsFromDB) {
|
|
41
|
-
setReactions(reactionsFromDB);
|
|
42
|
-
setLoading(false);
|
|
43
|
-
}
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
const loadOnlineReactions = async () => {
|
|
47
|
-
if (!messageId) {
|
|
48
|
-
return;
|
|
49
|
-
}
|
|
30
|
+
if (!messageId) {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
try {
|
|
50
34
|
const response = await client.queryReactions(
|
|
51
35
|
messageId,
|
|
52
36
|
reactionType ? { type: reactionType } : {},
|
|
@@ -54,38 +38,87 @@ export const useFetchReactions = ({
|
|
|
54
38
|
{ limit, next },
|
|
55
39
|
);
|
|
56
40
|
if (response) {
|
|
41
|
+
setReactions((prevReactions) =>
|
|
42
|
+
next ? [...prevReactions, ...response.reactions] : response.reactions,
|
|
43
|
+
);
|
|
57
44
|
setNext(response.next);
|
|
58
|
-
setReactions((prevReactions) => [...prevReactions, ...response.reactions]);
|
|
59
45
|
setLoading(false);
|
|
60
46
|
}
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
try {
|
|
64
|
-
// TODO: Threads are not supported for the offline use case as we don't store the thread messages currently, and this will change in the future.
|
|
65
|
-
if (enableOfflineSupport && !message?.parent_id) {
|
|
66
|
-
await loadOfflineReactions();
|
|
67
|
-
} else {
|
|
68
|
-
await loadOnlineReactions();
|
|
69
|
-
}
|
|
70
47
|
} catch (error) {
|
|
71
48
|
console.log('Error fetching reactions: ', error);
|
|
72
49
|
}
|
|
73
50
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
74
|
-
}, [client, messageId, reactionType, sortString, next, enableOfflineSupport]);
|
|
51
|
+
}, [client, messageId, reactionType, sortString, next, limit, enableOfflineSupport]);
|
|
75
52
|
|
|
76
53
|
const loadNextPage = useCallback(async () => {
|
|
77
54
|
if (next) {
|
|
78
55
|
await fetchReactions();
|
|
79
56
|
}
|
|
80
|
-
|
|
81
|
-
}, [fetchReactions]);
|
|
57
|
+
}, [fetchReactions, next]);
|
|
82
58
|
|
|
83
59
|
useEffect(() => {
|
|
84
60
|
setReactions([]);
|
|
85
61
|
setNext(undefined);
|
|
86
62
|
fetchReactions();
|
|
87
|
-
|
|
88
|
-
|
|
63
|
+
}, [fetchReactions, messageId, reactionType, sortString]);
|
|
64
|
+
|
|
65
|
+
useEffect(() => {
|
|
66
|
+
const listeners: ReturnType<typeof client.on>[] = [];
|
|
67
|
+
listeners.push(
|
|
68
|
+
client.on('offline_reactions.queried', (event) => {
|
|
69
|
+
const { offlineReactions } = event;
|
|
70
|
+
if (offlineReactions) {
|
|
71
|
+
setReactions(offlineReactions);
|
|
72
|
+
setLoading(false);
|
|
73
|
+
setNext(undefined);
|
|
74
|
+
}
|
|
75
|
+
}),
|
|
76
|
+
);
|
|
77
|
+
|
|
78
|
+
listeners.push(
|
|
79
|
+
client.on('reaction.new', (event) => {
|
|
80
|
+
const { reaction } = event;
|
|
81
|
+
|
|
82
|
+
if (reaction && reaction.type === reactionType) {
|
|
83
|
+
setReactions((prevReactions) => [reaction, ...prevReactions]);
|
|
84
|
+
}
|
|
85
|
+
}),
|
|
86
|
+
);
|
|
87
|
+
|
|
88
|
+
listeners.push(
|
|
89
|
+
client.on('reaction.updated', (event) => {
|
|
90
|
+
const { reaction } = event;
|
|
91
|
+
|
|
92
|
+
if (reaction) {
|
|
93
|
+
if (reaction.type === reactionType) {
|
|
94
|
+
setReactions((prevReactions) => [reaction, ...prevReactions]);
|
|
95
|
+
} else {
|
|
96
|
+
setReactions((prevReactions) =>
|
|
97
|
+
prevReactions.filter((r) => r.user_id !== reaction.user_id),
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}),
|
|
102
|
+
);
|
|
103
|
+
|
|
104
|
+
listeners.push(
|
|
105
|
+
client.on('reaction.deleted', (event) => {
|
|
106
|
+
const { reaction } = event;
|
|
107
|
+
|
|
108
|
+
if (reaction && reaction.type === reactionType) {
|
|
109
|
+
setReactions((prevReactions) =>
|
|
110
|
+
prevReactions.filter((r) => r.user_id !== reaction.user_id),
|
|
111
|
+
);
|
|
112
|
+
}
|
|
113
|
+
}),
|
|
114
|
+
);
|
|
115
|
+
|
|
116
|
+
return () => {
|
|
117
|
+
listeners.forEach((listener) => {
|
|
118
|
+
listener?.unsubscribe();
|
|
119
|
+
});
|
|
120
|
+
};
|
|
121
|
+
}, [client, reactionType]);
|
|
89
122
|
|
|
90
123
|
return { loading, loadNextPage, reactions };
|
|
91
124
|
};
|
|
@@ -107,7 +107,7 @@ export type MessagesContextValue = Pick<MessageContextValue, 'isMessageAIGenerat
|
|
|
107
107
|
* Defaults to: [DateHeader](https://github.com/GetStream/stream-chat-react-native/blob/main/package/src/components/MessageList/DateHeader.tsx)
|
|
108
108
|
**/
|
|
109
109
|
DateHeader: React.ComponentType<DateHeaderProps>;
|
|
110
|
-
deleteMessage: (message: LocalMessage) => Promise<void>;
|
|
110
|
+
deleteMessage: (message: LocalMessage, hardDelete?: boolean) => Promise<void>;
|
|
111
111
|
deleteReaction: (type: string, messageId: string) => Promise<void>;
|
|
112
112
|
|
|
113
113
|
/** Should keyboard be dismissed when messaged is touched */
|
package/src/index.ts
CHANGED
|
@@ -29,6 +29,7 @@ export { default as trTranslations } from './i18n/tr.json';
|
|
|
29
29
|
export { default as heTranslations } from './i18n/he.json';
|
|
30
30
|
|
|
31
31
|
export { SqliteClient } from './store/SqliteClient';
|
|
32
|
+
export { OfflineDB } from './store/OfflineDB';
|
|
32
33
|
export { version } from './version.json';
|
|
33
34
|
|
|
34
35
|
import { NativeHandlers } from './native';
|
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
export default (client, user, channel = {}) => {
|
|
1
|
+
export default (client, user, channel = {}, payload = {}) => {
|
|
2
|
+
const newDate = new Date();
|
|
2
3
|
const event = {
|
|
3
4
|
channel,
|
|
4
5
|
cid: channel.cid,
|
|
5
|
-
|
|
6
|
+
created_at: newDate,
|
|
7
|
+
received_at: newDate,
|
|
6
8
|
type: 'message.read',
|
|
7
9
|
user,
|
|
10
|
+
...payload,
|
|
8
11
|
};
|
|
9
12
|
client.dispatchEvent(event);
|
|
10
13
|
|
|
@@ -97,10 +97,20 @@ export const generateChannelResponse = (
|
|
|
97
97
|
channel?: Record<string, any>;
|
|
98
98
|
id?: string;
|
|
99
99
|
messages?: Record<string, any>[];
|
|
100
|
+
members?: Record<string, any>[];
|
|
101
|
+
read?: Record<string, any>[];
|
|
100
102
|
type?: string;
|
|
101
|
-
} = { channel: {}, id: uuidv4(), messages: [], type: 'messaging' },
|
|
103
|
+
} = { channel: {}, id: uuidv4(), members: [], messages: [], read: [], type: 'messaging' },
|
|
102
104
|
) => {
|
|
103
|
-
const {
|
|
105
|
+
const {
|
|
106
|
+
channel = {},
|
|
107
|
+
id = uuidv4(),
|
|
108
|
+
messages = [],
|
|
109
|
+
members = [],
|
|
110
|
+
read,
|
|
111
|
+
type = 'messaging',
|
|
112
|
+
...rest
|
|
113
|
+
} = customValues;
|
|
104
114
|
|
|
105
115
|
const defaults = getChannelDefaults();
|
|
106
116
|
return {
|
|
@@ -110,12 +120,14 @@ export const generateChannelResponse = (
|
|
|
110
120
|
cid: `${type}:${id}`,
|
|
111
121
|
...channel,
|
|
112
122
|
id,
|
|
123
|
+
member_count: members.length,
|
|
113
124
|
type,
|
|
114
125
|
user: generateUser(),
|
|
115
126
|
},
|
|
116
127
|
},
|
|
117
|
-
members
|
|
128
|
+
members,
|
|
118
129
|
messages,
|
|
130
|
+
read,
|
|
119
131
|
...rest,
|
|
120
132
|
};
|
|
121
133
|
};
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { AbstractOfflineDB, StreamChat } from 'stream-chat';
|
|
2
|
+
import type {
|
|
3
|
+
DBGetAppSettingsType,
|
|
4
|
+
DBGetChannelsForQueryType,
|
|
5
|
+
DBGetChannelsType,
|
|
6
|
+
DBGetLastSyncedAtType,
|
|
7
|
+
DBUpsertAppSettingsType,
|
|
8
|
+
DBUpsertUserSyncStatusType,
|
|
9
|
+
} from 'stream-chat';
|
|
10
|
+
|
|
11
|
+
import * as api from './apis';
|
|
12
|
+
import { SqliteClient } from './SqliteClient';
|
|
13
|
+
|
|
14
|
+
export class OfflineDB extends AbstractOfflineDB {
|
|
15
|
+
constructor({ client }: { client: StreamChat }) {
|
|
16
|
+
super({ client });
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
upsertCidsForQuery = api.upsertCidsForQuery;
|
|
20
|
+
|
|
21
|
+
upsertChannels = api.upsertChannels;
|
|
22
|
+
|
|
23
|
+
// TODO: Rename currentUserId -> userId in the next major version as it is technically breaking.
|
|
24
|
+
upsertUserSyncStatus = ({ userId, lastSyncedAt, execute }: DBUpsertUserSyncStatusType) =>
|
|
25
|
+
api.upsertUserSyncStatus({ currentUserId: userId, execute, lastSyncedAt });
|
|
26
|
+
|
|
27
|
+
// TODO: Rename currentUserId -> userId in the next major version as it is technically breaking.
|
|
28
|
+
upsertAppSettings = ({ appSettings, userId, execute }: DBUpsertAppSettingsType) =>
|
|
29
|
+
api.upsertAppSettings({ appSettings, currentUserId: userId, execute });
|
|
30
|
+
|
|
31
|
+
upsertPoll = api.upsertPoll;
|
|
32
|
+
|
|
33
|
+
upsertChannelData = api.upsertChannelData;
|
|
34
|
+
|
|
35
|
+
upsertReads = api.upsertReads;
|
|
36
|
+
|
|
37
|
+
upsertMessages = api.upsertMessages;
|
|
38
|
+
|
|
39
|
+
upsertMembers = api.upsertMembers;
|
|
40
|
+
|
|
41
|
+
updateMessage = api.updateMessage;
|
|
42
|
+
|
|
43
|
+
// TODO: Rename currentUserId -> userId in the next major version as it is technically breaking.
|
|
44
|
+
getChannels = ({ cids, userId }: DBGetChannelsType) =>
|
|
45
|
+
api.getChannels({ channelIds: cids, currentUserId: userId });
|
|
46
|
+
|
|
47
|
+
// TODO: Rename currentUserId -> userId in the next major version as it is technically breaking.
|
|
48
|
+
getChannelsForQuery = ({ userId, filters, sort }: DBGetChannelsForQueryType) =>
|
|
49
|
+
api.getChannelsForFilterSort({ currentUserId: userId, filters, sort });
|
|
50
|
+
|
|
51
|
+
getAllChannelCids = api.getAllChannelIds;
|
|
52
|
+
|
|
53
|
+
// TODO: Rename currentUserId -> userId in the next major version as it is technically breaking.
|
|
54
|
+
getLastSyncedAt = ({ userId }: DBGetLastSyncedAtType) =>
|
|
55
|
+
api.getLastSyncedAt({ currentUserId: userId });
|
|
56
|
+
|
|
57
|
+
getAppSettings = ({ userId }: DBGetAppSettingsType) =>
|
|
58
|
+
api.getAppSettings({ currentUserId: userId });
|
|
59
|
+
|
|
60
|
+
getReactions = api.getReactionsForFilterSort;
|
|
61
|
+
|
|
62
|
+
addPendingTask = api.addPendingTask;
|
|
63
|
+
|
|
64
|
+
deletePendingTask = api.deletePendingTask;
|
|
65
|
+
|
|
66
|
+
deleteReaction = api.deleteReaction;
|
|
67
|
+
|
|
68
|
+
deleteMember = api.deleteMember;
|
|
69
|
+
|
|
70
|
+
deleteChannel = api.deleteChannel;
|
|
71
|
+
|
|
72
|
+
deleteMessagesForChannel = api.deleteMessagesForChannel;
|
|
73
|
+
|
|
74
|
+
dropPendingTasks = api.dropPendingTasks;
|
|
75
|
+
|
|
76
|
+
hardDeleteMessage = api.deleteMessage;
|
|
77
|
+
|
|
78
|
+
softDeleteMessage = api.softDeleteMessage;
|
|
79
|
+
|
|
80
|
+
getPendingTasks = api.getPendingTasks;
|
|
81
|
+
|
|
82
|
+
updateReaction = api.updateReaction;
|
|
83
|
+
|
|
84
|
+
insertReaction = api.insertReaction;
|
|
85
|
+
|
|
86
|
+
channelExists = api.channelExists;
|
|
87
|
+
|
|
88
|
+
resetDB = SqliteClient.resetDB;
|
|
89
|
+
|
|
90
|
+
executeSqlBatch = SqliteClient.executeSqlBatch;
|
|
91
|
+
|
|
92
|
+
initializeDB = SqliteClient.initializeDatabase;
|
|
93
|
+
}
|
|
@@ -28,7 +28,7 @@ import type { PreparedBatchQueries, PreparedQueries, Scalar, Table } from './typ
|
|
|
28
28
|
* This way usage @op-engineering/op-sqlite package is scoped to a single class/file.
|
|
29
29
|
*/
|
|
30
30
|
export class SqliteClient {
|
|
31
|
-
static dbVersion =
|
|
31
|
+
static dbVersion = 9;
|
|
32
32
|
|
|
33
33
|
static dbName = DB_NAME;
|
|
34
34
|
static dbLocation = DB_LOCATION;
|
|
@@ -96,6 +96,7 @@ export class SqliteClient {
|
|
|
96
96
|
});
|
|
97
97
|
await this.db.executeBatch(finalQueries);
|
|
98
98
|
} catch (e) {
|
|
99
|
+
this.db?.execute('ROLLBACK');
|
|
99
100
|
this.logger?.('error', 'SqlBatch queries failed', {
|
|
100
101
|
error: e,
|
|
101
102
|
queries,
|
|
@@ -164,6 +165,7 @@ export class SqliteClient {
|
|
|
164
165
|
await SqliteClient.dropTables();
|
|
165
166
|
await SqliteClient.updateUserPragmaVersion(SqliteClient.dbVersion);
|
|
166
167
|
}
|
|
168
|
+
|
|
167
169
|
SqliteClient.logger?.('info', 'create tables if not exists', {
|
|
168
170
|
tables: Object.keys(tables),
|
|
169
171
|
});
|
|
@@ -176,6 +178,8 @@ export class SqliteClient {
|
|
|
176
178
|
);
|
|
177
179
|
|
|
178
180
|
await SqliteClient.executeSqlBatch(q);
|
|
181
|
+
|
|
182
|
+
return true;
|
|
179
183
|
} catch (e) {
|
|
180
184
|
console.log('Error initializing DB', e);
|
|
181
185
|
this.logger?.('error', 'Error initializing DB', {
|
|
@@ -183,6 +187,8 @@ export class SqliteClient {
|
|
|
183
187
|
dbname: SqliteClient.dbName,
|
|
184
188
|
error: e,
|
|
185
189
|
});
|
|
190
|
+
|
|
191
|
+
return false;
|
|
186
192
|
}
|
|
187
193
|
};
|
|
188
194
|
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import type { PendingTask } from 'stream-chat';
|
|
2
|
+
|
|
1
3
|
import { mapTaskToStorable } from '../mappers/mapTaskToStorable';
|
|
2
4
|
import { createDeleteQuery } from '../sqlite-utils/createDeleteQuery';
|
|
3
5
|
import { createUpsertQuery } from '../sqlite-utils/createUpsertQuery';
|
|
4
6
|
import { SqliteClient } from '../SqliteClient';
|
|
5
|
-
import type { PendingTask } from '../types';
|
|
6
7
|
|
|
7
8
|
/*
|
|
8
9
|
* addPendingTask - Adds a pending task to the database
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { SqliteClient } from '../SqliteClient';
|
|
2
|
+
|
|
3
|
+
export const channelExists = async ({ cid }: { cid: string }) => {
|
|
4
|
+
const channels = await SqliteClient.executeSql(
|
|
5
|
+
'SELECT EXISTS(SELECT 1 FROM channels WHERE cid = ?)',
|
|
6
|
+
[cid],
|
|
7
|
+
);
|
|
8
|
+
|
|
9
|
+
SqliteClient.logger?.('info', 'channelExists', {
|
|
10
|
+
cid,
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
return channels.length > 0;
|
|
14
|
+
};
|
|
@@ -1,17 +1,23 @@
|
|
|
1
1
|
import { createDeleteQuery } from '../sqlite-utils/createDeleteQuery';
|
|
2
2
|
import { SqliteClient } from '../SqliteClient';
|
|
3
3
|
|
|
4
|
-
export const deleteChannel = async ({
|
|
4
|
+
export const deleteChannel = async ({
|
|
5
|
+
cid,
|
|
6
|
+
execute = true,
|
|
7
|
+
}: {
|
|
8
|
+
cid: string;
|
|
9
|
+
execute?: boolean;
|
|
10
|
+
}) => {
|
|
5
11
|
const query = createDeleteQuery('channels', {
|
|
6
12
|
cid,
|
|
7
13
|
});
|
|
8
14
|
|
|
9
15
|
SqliteClient.logger?.('info', 'deleteChannel', {
|
|
10
16
|
cid,
|
|
11
|
-
|
|
17
|
+
execute,
|
|
12
18
|
});
|
|
13
19
|
|
|
14
|
-
if (
|
|
20
|
+
if (execute) {
|
|
15
21
|
await SqliteClient.executeSql.apply(null, query);
|
|
16
22
|
}
|
|
17
23
|
|
|
@@ -5,12 +5,12 @@ import { SqliteClient } from '../SqliteClient';
|
|
|
5
5
|
|
|
6
6
|
export const deleteMember = async ({
|
|
7
7
|
cid,
|
|
8
|
-
|
|
8
|
+
execute = true,
|
|
9
9
|
member,
|
|
10
10
|
}: {
|
|
11
11
|
cid: string;
|
|
12
12
|
member: ChannelMemberResponse;
|
|
13
|
-
|
|
13
|
+
execute?: boolean;
|
|
14
14
|
}) => {
|
|
15
15
|
const query = createDeleteQuery('members', {
|
|
16
16
|
cid,
|
|
@@ -19,11 +19,11 @@ export const deleteMember = async ({
|
|
|
19
19
|
|
|
20
20
|
SqliteClient.logger?.('info', 'deleteMember', {
|
|
21
21
|
cid,
|
|
22
|
-
|
|
22
|
+
execute,
|
|
23
23
|
userId: member.user_id,
|
|
24
24
|
});
|
|
25
25
|
|
|
26
|
-
if (
|
|
26
|
+
if (execute) {
|
|
27
27
|
await SqliteClient.executeSql.apply(null, query);
|
|
28
28
|
}
|
|
29
29
|
|
|
@@ -1,19 +1,29 @@
|
|
|
1
1
|
import { createDeleteQuery } from '../sqlite-utils/createDeleteQuery';
|
|
2
2
|
import { SqliteClient } from '../SqliteClient';
|
|
3
3
|
|
|
4
|
-
export const deleteMessage = async ({
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
export const deleteMessage = async ({ execute = true, id }: { id: string; execute?: boolean }) => {
|
|
5
|
+
const queries = [];
|
|
6
|
+
|
|
7
|
+
queries.push(
|
|
8
|
+
createDeleteQuery('reactions', {
|
|
9
|
+
messageId: id,
|
|
10
|
+
}),
|
|
11
|
+
);
|
|
12
|
+
|
|
13
|
+
queries.push(
|
|
14
|
+
createDeleteQuery('messages', {
|
|
15
|
+
id,
|
|
16
|
+
}),
|
|
17
|
+
);
|
|
8
18
|
|
|
9
19
|
SqliteClient.logger?.('info', 'deleteMessage', {
|
|
10
|
-
|
|
20
|
+
execute,
|
|
11
21
|
id,
|
|
12
22
|
});
|
|
13
23
|
|
|
14
|
-
if (
|
|
15
|
-
await SqliteClient.
|
|
24
|
+
if (execute) {
|
|
25
|
+
await SqliteClient.executeSqlBatch(queries);
|
|
16
26
|
}
|
|
17
27
|
|
|
18
|
-
return
|
|
28
|
+
return queries;
|
|
19
29
|
};
|
|
@@ -1,23 +1,27 @@
|
|
|
1
|
-
import { createDeleteQuery } from '../sqlite-utils/createDeleteQuery';
|
|
2
1
|
import { SqliteClient } from '../SqliteClient';
|
|
3
2
|
|
|
4
3
|
export const deleteMessagesForChannel = async ({
|
|
5
4
|
cid,
|
|
6
|
-
|
|
5
|
+
truncated_at,
|
|
6
|
+
execute = true,
|
|
7
7
|
}: {
|
|
8
8
|
cid: string;
|
|
9
|
-
|
|
9
|
+
truncated_at?: string;
|
|
10
|
+
execute?: boolean;
|
|
10
11
|
}) => {
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
const timestamp = truncated_at ? new Date(truncated_at).toISOString() : new Date().toISOString();
|
|
13
|
+
const query: [string, (string | number)[]] = [
|
|
14
|
+
`DELETE FROM messages WHERE cid = ? AND createdAt <= ?`,
|
|
15
|
+
[cid, timestamp],
|
|
16
|
+
];
|
|
14
17
|
|
|
15
18
|
SqliteClient.logger?.('info', 'deleteMessagesForChannel', {
|
|
16
19
|
cid,
|
|
17
|
-
|
|
20
|
+
execute,
|
|
21
|
+
truncated_at,
|
|
18
22
|
});
|
|
19
23
|
|
|
20
|
-
if (
|
|
24
|
+
if (execute) {
|
|
21
25
|
await SqliteClient.executeSql.apply(null, query);
|
|
22
26
|
}
|
|
23
27
|
|
|
@@ -1,32 +1,52 @@
|
|
|
1
|
+
import { FormatMessageResponse, MessageResponse, ReactionResponse } from 'stream-chat';
|
|
2
|
+
|
|
1
3
|
import { createDeleteQuery } from '../sqlite-utils/createDeleteQuery';
|
|
4
|
+
import { createUpdateQuery } from '../sqlite-utils/createUpdateQuery';
|
|
2
5
|
import { SqliteClient } from '../SqliteClient';
|
|
6
|
+
import { PreparedQueries } from '../types';
|
|
3
7
|
|
|
4
8
|
export const deleteReaction = async ({
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
userId,
|
|
9
|
+
execute = true,
|
|
10
|
+
message,
|
|
11
|
+
reaction,
|
|
9
12
|
}: {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
flush?: boolean;
|
|
13
|
+
reaction: ReactionResponse;
|
|
14
|
+
message?: MessageResponse | FormatMessageResponse;
|
|
15
|
+
execute?: boolean;
|
|
14
16
|
}) => {
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
17
|
+
const queries: PreparedQueries[] = [];
|
|
18
|
+
|
|
19
|
+
if (!message) {
|
|
20
|
+
return [];
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
queries.push(
|
|
24
|
+
createDeleteQuery('reactions', {
|
|
25
|
+
messageId: reaction.message_id,
|
|
26
|
+
type: reaction.type,
|
|
27
|
+
userId: reaction.user_id,
|
|
28
|
+
}),
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
const stringifiedNewReactionGroups = JSON.stringify(message.reaction_groups);
|
|
32
|
+
|
|
33
|
+
queries.push(
|
|
34
|
+
createUpdateQuery(
|
|
35
|
+
'messages',
|
|
36
|
+
{
|
|
37
|
+
reactionGroups: stringifiedNewReactionGroups,
|
|
38
|
+
},
|
|
39
|
+
{ id: message.id },
|
|
40
|
+
),
|
|
41
|
+
);
|
|
20
42
|
|
|
21
43
|
SqliteClient.logger?.('info', 'deleteReaction', {
|
|
22
|
-
|
|
23
|
-
type: reactionType,
|
|
24
|
-
userId,
|
|
44
|
+
reaction,
|
|
25
45
|
});
|
|
26
46
|
|
|
27
|
-
if (
|
|
28
|
-
await SqliteClient.
|
|
47
|
+
if (execute) {
|
|
48
|
+
await SqliteClient.executeSqlBatch(queries);
|
|
29
49
|
}
|
|
30
50
|
|
|
31
|
-
return
|
|
51
|
+
return queries;
|
|
32
52
|
};
|
|
@@ -2,20 +2,20 @@ import { createDeleteQuery } from '../sqlite-utils/createDeleteQuery';
|
|
|
2
2
|
import { SqliteClient } from '../SqliteClient';
|
|
3
3
|
|
|
4
4
|
export const deleteReactionsForMessage = async ({
|
|
5
|
-
|
|
5
|
+
execute = true,
|
|
6
6
|
messageId,
|
|
7
7
|
}: {
|
|
8
8
|
messageId: string;
|
|
9
|
-
|
|
9
|
+
execute?: boolean;
|
|
10
10
|
}) => {
|
|
11
11
|
const query = createDeleteQuery('reactions', {
|
|
12
12
|
messageId,
|
|
13
13
|
});
|
|
14
14
|
console.log('deleteReactionsForMessage', {
|
|
15
|
-
|
|
15
|
+
execute,
|
|
16
16
|
messageId,
|
|
17
17
|
});
|
|
18
|
-
if (
|
|
18
|
+
if (execute) {
|
|
19
19
|
await SqliteClient.executeSql.apply(null, query);
|
|
20
20
|
}
|
|
21
21
|
|