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.
Files changed (409) hide show
  1. package/README.md +1 -1
  2. package/lib/commonjs/components/Channel/Channel.js +214 -237
  3. package/lib/commonjs/components/Channel/Channel.js.map +1 -1
  4. package/lib/commonjs/components/ChannelList/ChannelList.js +2 -19
  5. package/lib/commonjs/components/ChannelList/ChannelList.js.map +1 -1
  6. package/lib/commonjs/components/ChannelList/hooks/usePaginatedChannels.js +48 -176
  7. package/lib/commonjs/components/ChannelList/hooks/usePaginatedChannels.js.map +1 -1
  8. package/lib/commonjs/components/ChannelPreview/hooks/useIsChannelMuted.js +13 -2
  9. package/lib/commonjs/components/ChannelPreview/hooks/useIsChannelMuted.js.map +1 -1
  10. package/lib/commonjs/components/Chat/Chat.js +33 -46
  11. package/lib/commonjs/components/Chat/Chat.js.map +1 -1
  12. package/lib/commonjs/components/Chat/hooks/useAppSettings.js +47 -120
  13. package/lib/commonjs/components/Chat/hooks/useAppSettings.js.map +1 -1
  14. package/lib/commonjs/components/Chat/hooks/useSyncDatabase.js +0 -15
  15. package/lib/commonjs/components/Chat/hooks/useSyncDatabase.js.map +1 -1
  16. package/lib/commonjs/components/MessageMenu/MessageUserReactions.js +5 -0
  17. package/lib/commonjs/components/MessageMenu/MessageUserReactions.js.map +1 -1
  18. package/lib/commonjs/components/MessageMenu/hooks/useFetchReactions.js +92 -108
  19. package/lib/commonjs/components/MessageMenu/hooks/useFetchReactions.js.map +1 -1
  20. package/lib/commonjs/index.js +8 -0
  21. package/lib/commonjs/index.js.map +1 -1
  22. package/lib/commonjs/mock-builders/event/channelVisible.js +13 -0
  23. package/lib/commonjs/mock-builders/event/channelVisible.js.map +1 -0
  24. package/lib/commonjs/mock-builders/event/memberAdded.js +4 -2
  25. package/lib/commonjs/mock-builders/event/memberAdded.js.map +1 -1
  26. package/lib/commonjs/mock-builders/event/memberRemoved.js +2 -1
  27. package/lib/commonjs/mock-builders/event/memberRemoved.js.map +1 -1
  28. package/lib/commonjs/mock-builders/event/memberUpdated.js +2 -1
  29. package/lib/commonjs/mock-builders/event/memberUpdated.js.map +1 -1
  30. package/lib/commonjs/mock-builders/event/messageNew.js +4 -2
  31. package/lib/commonjs/mock-builders/event/messageNew.js.map +1 -1
  32. package/lib/commonjs/mock-builders/event/messageRead.js +6 -3
  33. package/lib/commonjs/mock-builders/event/messageRead.js.map +1 -1
  34. package/lib/commonjs/mock-builders/event/notificationMarkUnread.js +3 -0
  35. package/lib/commonjs/mock-builders/event/notificationMarkUnread.js.map +1 -1
  36. package/lib/commonjs/mock-builders/generator/channel.js +10 -3
  37. package/lib/commonjs/mock-builders/generator/channel.js.map +1 -1
  38. package/lib/commonjs/store/OfflineDB.js +108 -0
  39. package/lib/commonjs/store/OfflineDB.js.map +1 -0
  40. package/lib/commonjs/store/SqliteClient.js +11 -10
  41. package/lib/commonjs/store/SqliteClient.js.map +1 -1
  42. package/lib/commonjs/store/apis/addPendingTask.js.map +1 -1
  43. package/lib/commonjs/store/apis/channelExists.js +34 -0
  44. package/lib/commonjs/store/apis/channelExists.js.map +1 -0
  45. package/lib/commonjs/store/apis/deleteChannel.js +4 -4
  46. package/lib/commonjs/store/apis/deleteChannel.js.map +1 -1
  47. package/lib/commonjs/store/apis/deleteMember.js +4 -4
  48. package/lib/commonjs/store/apis/deleteMember.js.map +1 -1
  49. package/lib/commonjs/store/apis/deleteMessage.js +16 -12
  50. package/lib/commonjs/store/apis/deleteMessage.js.map +1 -1
  51. package/lib/commonjs/store/apis/deleteMessagesForChannel.js +11 -12
  52. package/lib/commonjs/store/apis/deleteMessagesForChannel.js.map +1 -1
  53. package/lib/commonjs/store/apis/deleteReaction.js +29 -17
  54. package/lib/commonjs/store/apis/deleteReaction.js.map +1 -1
  55. package/lib/commonjs/store/apis/deleteReactions.js +4 -4
  56. package/lib/commonjs/store/apis/deleteReactions.js.map +1 -1
  57. package/lib/commonjs/store/apis/dropPendingTasks.js +41 -0
  58. package/lib/commonjs/store/apis/dropPendingTasks.js.map +1 -0
  59. package/lib/commonjs/store/apis/getChannelMessages.js +1 -1
  60. package/lib/commonjs/store/apis/getChannelMessages.js.map +1 -1
  61. package/lib/commonjs/store/apis/getChannels.js +18 -21
  62. package/lib/commonjs/store/apis/getChannels.js.map +1 -1
  63. package/lib/commonjs/store/apis/getLastSyncedAt.js +3 -9
  64. package/lib/commonjs/store/apis/getLastSyncedAt.js.map +1 -1
  65. package/lib/commonjs/store/apis/getReactionsforFilterSort.js +5 -8
  66. package/lib/commonjs/store/apis/getReactionsforFilterSort.js.map +1 -1
  67. package/lib/commonjs/store/apis/index.js +103 -4
  68. package/lib/commonjs/store/apis/index.js.map +1 -1
  69. package/lib/commonjs/store/apis/insertReaction.js +4 -4
  70. package/lib/commonjs/store/apis/insertReaction.js.map +1 -1
  71. package/lib/commonjs/store/apis/queries/selectMessagesForChannels.js +1 -1
  72. package/lib/commonjs/store/apis/queries/selectMessagesForChannels.js.map +1 -1
  73. package/lib/commonjs/store/apis/queries/selectReactionsForMessages.js +25 -5
  74. package/lib/commonjs/store/apis/queries/selectReactionsForMessages.js.map +1 -1
  75. package/lib/commonjs/store/apis/softDeleteMessage.js +45 -0
  76. package/lib/commonjs/store/apis/softDeleteMessage.js.map +1 -0
  77. package/lib/commonjs/store/apis/updateMessage.js +7 -11
  78. package/lib/commonjs/store/apis/updateMessage.js.map +1 -1
  79. package/lib/commonjs/store/apis/updateReaction.js +11 -9
  80. package/lib/commonjs/store/apis/updateReaction.js.map +1 -1
  81. package/lib/commonjs/store/apis/upsertAppSettings.js +9 -7
  82. package/lib/commonjs/store/apis/upsertAppSettings.js.map +1 -1
  83. package/lib/commonjs/store/apis/upsertChannelData.js +4 -4
  84. package/lib/commonjs/store/apis/upsertChannelData.js.map +1 -1
  85. package/lib/commonjs/store/apis/upsertChannelDataFromChannel.js +3 -3
  86. package/lib/commonjs/store/apis/upsertChannelDataFromChannel.js.map +1 -1
  87. package/lib/commonjs/store/apis/upsertChannels.js +86 -83
  88. package/lib/commonjs/store/apis/upsertChannels.js.map +1 -1
  89. package/lib/commonjs/store/apis/upsertCidsForQuery.js +4 -4
  90. package/lib/commonjs/store/apis/upsertCidsForQuery.js.map +1 -1
  91. package/lib/commonjs/store/apis/upsertMembers.js +4 -4
  92. package/lib/commonjs/store/apis/upsertMembers.js.map +1 -1
  93. package/lib/commonjs/store/apis/upsertMessages.js +4 -4
  94. package/lib/commonjs/store/apis/upsertMessages.js.map +1 -1
  95. package/lib/commonjs/store/apis/upsertPoll.js +42 -0
  96. package/lib/commonjs/store/apis/upsertPoll.js.map +1 -0
  97. package/lib/commonjs/store/apis/upsertReads.js +4 -4
  98. package/lib/commonjs/store/apis/upsertReads.js.map +1 -1
  99. package/lib/commonjs/store/apis/upsertUserSyncStatus.js +13 -7
  100. package/lib/commonjs/store/apis/upsertUserSyncStatus.js.map +1 -1
  101. package/lib/commonjs/store/mappers/mapMemberToStorable.js +6 -2
  102. package/lib/commonjs/store/mappers/mapMemberToStorable.js.map +1 -1
  103. package/lib/commonjs/store/mappers/mapReadToStorable.js +3 -1
  104. package/lib/commonjs/store/mappers/mapReadToStorable.js.map +1 -1
  105. package/lib/commonjs/store/mappers/mapStorableToMember.js +5 -1
  106. package/lib/commonjs/store/mappers/mapStorableToMember.js.map +1 -1
  107. package/lib/commonjs/store/mappers/mapStorableToRead.js +3 -1
  108. package/lib/commonjs/store/mappers/mapStorableToRead.js.map +1 -1
  109. package/lib/commonjs/store/mappers/mapStorableToTask.js.map +1 -1
  110. package/lib/commonjs/store/schema.js +2 -0
  111. package/lib/commonjs/store/schema.js.map +1 -1
  112. package/lib/commonjs/utils/addReactionToLocalState.js +62 -81
  113. package/lib/commonjs/utils/addReactionToLocalState.js.map +1 -1
  114. package/lib/commonjs/utils/removeReactionFromLocalState.js +0 -6
  115. package/lib/commonjs/utils/removeReactionFromLocalState.js.map +1 -1
  116. package/lib/commonjs/version.json +1 -1
  117. package/lib/module/components/Channel/Channel.js +214 -237
  118. package/lib/module/components/Channel/Channel.js.map +1 -1
  119. package/lib/module/components/ChannelList/ChannelList.js +2 -19
  120. package/lib/module/components/ChannelList/ChannelList.js.map +1 -1
  121. package/lib/module/components/ChannelList/hooks/usePaginatedChannels.js +48 -176
  122. package/lib/module/components/ChannelList/hooks/usePaginatedChannels.js.map +1 -1
  123. package/lib/module/components/ChannelPreview/hooks/useIsChannelMuted.js +13 -2
  124. package/lib/module/components/ChannelPreview/hooks/useIsChannelMuted.js.map +1 -1
  125. package/lib/module/components/Chat/Chat.js +33 -46
  126. package/lib/module/components/Chat/Chat.js.map +1 -1
  127. package/lib/module/components/Chat/hooks/useAppSettings.js +47 -120
  128. package/lib/module/components/Chat/hooks/useAppSettings.js.map +1 -1
  129. package/lib/module/components/Chat/hooks/useSyncDatabase.js +0 -15
  130. package/lib/module/components/Chat/hooks/useSyncDatabase.js.map +1 -1
  131. package/lib/module/components/MessageMenu/MessageUserReactions.js +5 -0
  132. package/lib/module/components/MessageMenu/MessageUserReactions.js.map +1 -1
  133. package/lib/module/components/MessageMenu/hooks/useFetchReactions.js +92 -108
  134. package/lib/module/components/MessageMenu/hooks/useFetchReactions.js.map +1 -1
  135. package/lib/module/index.js +8 -0
  136. package/lib/module/index.js.map +1 -1
  137. package/lib/module/mock-builders/event/channelVisible.js +13 -0
  138. package/lib/module/mock-builders/event/channelVisible.js.map +1 -0
  139. package/lib/module/mock-builders/event/memberAdded.js +4 -2
  140. package/lib/module/mock-builders/event/memberAdded.js.map +1 -1
  141. package/lib/module/mock-builders/event/memberRemoved.js +2 -1
  142. package/lib/module/mock-builders/event/memberRemoved.js.map +1 -1
  143. package/lib/module/mock-builders/event/memberUpdated.js +2 -1
  144. package/lib/module/mock-builders/event/memberUpdated.js.map +1 -1
  145. package/lib/module/mock-builders/event/messageNew.js +4 -2
  146. package/lib/module/mock-builders/event/messageNew.js.map +1 -1
  147. package/lib/module/mock-builders/event/messageRead.js +6 -3
  148. package/lib/module/mock-builders/event/messageRead.js.map +1 -1
  149. package/lib/module/mock-builders/event/notificationMarkUnread.js +3 -0
  150. package/lib/module/mock-builders/event/notificationMarkUnread.js.map +1 -1
  151. package/lib/module/mock-builders/generator/channel.js +10 -3
  152. package/lib/module/mock-builders/generator/channel.js.map +1 -1
  153. package/lib/module/store/OfflineDB.js +108 -0
  154. package/lib/module/store/OfflineDB.js.map +1 -0
  155. package/lib/module/store/SqliteClient.js +11 -10
  156. package/lib/module/store/SqliteClient.js.map +1 -1
  157. package/lib/module/store/apis/addPendingTask.js.map +1 -1
  158. package/lib/module/store/apis/channelExists.js +34 -0
  159. package/lib/module/store/apis/channelExists.js.map +1 -0
  160. package/lib/module/store/apis/deleteChannel.js +4 -4
  161. package/lib/module/store/apis/deleteChannel.js.map +1 -1
  162. package/lib/module/store/apis/deleteMember.js +4 -4
  163. package/lib/module/store/apis/deleteMember.js.map +1 -1
  164. package/lib/module/store/apis/deleteMessage.js +16 -12
  165. package/lib/module/store/apis/deleteMessage.js.map +1 -1
  166. package/lib/module/store/apis/deleteMessagesForChannel.js +11 -12
  167. package/lib/module/store/apis/deleteMessagesForChannel.js.map +1 -1
  168. package/lib/module/store/apis/deleteReaction.js +29 -17
  169. package/lib/module/store/apis/deleteReaction.js.map +1 -1
  170. package/lib/module/store/apis/deleteReactions.js +4 -4
  171. package/lib/module/store/apis/deleteReactions.js.map +1 -1
  172. package/lib/module/store/apis/dropPendingTasks.js +41 -0
  173. package/lib/module/store/apis/dropPendingTasks.js.map +1 -0
  174. package/lib/module/store/apis/getChannelMessages.js +1 -1
  175. package/lib/module/store/apis/getChannelMessages.js.map +1 -1
  176. package/lib/module/store/apis/getChannels.js +18 -21
  177. package/lib/module/store/apis/getChannels.js.map +1 -1
  178. package/lib/module/store/apis/getLastSyncedAt.js +3 -9
  179. package/lib/module/store/apis/getLastSyncedAt.js.map +1 -1
  180. package/lib/module/store/apis/getReactionsforFilterSort.js +5 -8
  181. package/lib/module/store/apis/getReactionsforFilterSort.js.map +1 -1
  182. package/lib/module/store/apis/index.js +103 -4
  183. package/lib/module/store/apis/index.js.map +1 -1
  184. package/lib/module/store/apis/insertReaction.js +4 -4
  185. package/lib/module/store/apis/insertReaction.js.map +1 -1
  186. package/lib/module/store/apis/queries/selectMessagesForChannels.js +1 -1
  187. package/lib/module/store/apis/queries/selectMessagesForChannels.js.map +1 -1
  188. package/lib/module/store/apis/queries/selectReactionsForMessages.js +25 -5
  189. package/lib/module/store/apis/queries/selectReactionsForMessages.js.map +1 -1
  190. package/lib/module/store/apis/softDeleteMessage.js +45 -0
  191. package/lib/module/store/apis/softDeleteMessage.js.map +1 -0
  192. package/lib/module/store/apis/updateMessage.js +7 -11
  193. package/lib/module/store/apis/updateMessage.js.map +1 -1
  194. package/lib/module/store/apis/updateReaction.js +11 -9
  195. package/lib/module/store/apis/updateReaction.js.map +1 -1
  196. package/lib/module/store/apis/upsertAppSettings.js +9 -7
  197. package/lib/module/store/apis/upsertAppSettings.js.map +1 -1
  198. package/lib/module/store/apis/upsertChannelData.js +4 -4
  199. package/lib/module/store/apis/upsertChannelData.js.map +1 -1
  200. package/lib/module/store/apis/upsertChannelDataFromChannel.js +3 -3
  201. package/lib/module/store/apis/upsertChannelDataFromChannel.js.map +1 -1
  202. package/lib/module/store/apis/upsertChannels.js +86 -83
  203. package/lib/module/store/apis/upsertChannels.js.map +1 -1
  204. package/lib/module/store/apis/upsertCidsForQuery.js +4 -4
  205. package/lib/module/store/apis/upsertCidsForQuery.js.map +1 -1
  206. package/lib/module/store/apis/upsertMembers.js +4 -4
  207. package/lib/module/store/apis/upsertMembers.js.map +1 -1
  208. package/lib/module/store/apis/upsertMessages.js +4 -4
  209. package/lib/module/store/apis/upsertMessages.js.map +1 -1
  210. package/lib/module/store/apis/upsertPoll.js +42 -0
  211. package/lib/module/store/apis/upsertPoll.js.map +1 -0
  212. package/lib/module/store/apis/upsertReads.js +4 -4
  213. package/lib/module/store/apis/upsertReads.js.map +1 -1
  214. package/lib/module/store/apis/upsertUserSyncStatus.js +13 -7
  215. package/lib/module/store/apis/upsertUserSyncStatus.js.map +1 -1
  216. package/lib/module/store/mappers/mapMemberToStorable.js +6 -2
  217. package/lib/module/store/mappers/mapMemberToStorable.js.map +1 -1
  218. package/lib/module/store/mappers/mapReadToStorable.js +3 -1
  219. package/lib/module/store/mappers/mapReadToStorable.js.map +1 -1
  220. package/lib/module/store/mappers/mapStorableToMember.js +5 -1
  221. package/lib/module/store/mappers/mapStorableToMember.js.map +1 -1
  222. package/lib/module/store/mappers/mapStorableToRead.js +3 -1
  223. package/lib/module/store/mappers/mapStorableToRead.js.map +1 -1
  224. package/lib/module/store/mappers/mapStorableToTask.js.map +1 -1
  225. package/lib/module/store/schema.js +2 -0
  226. package/lib/module/store/schema.js.map +1 -1
  227. package/lib/module/utils/addReactionToLocalState.js +62 -81
  228. package/lib/module/utils/addReactionToLocalState.js.map +1 -1
  229. package/lib/module/utils/removeReactionFromLocalState.js +0 -6
  230. package/lib/module/utils/removeReactionFromLocalState.js.map +1 -1
  231. package/lib/module/version.json +1 -1
  232. package/lib/typescript/components/Channel/Channel.d.ts +1 -1
  233. package/lib/typescript/components/Channel/Channel.d.ts.map +1 -1
  234. package/lib/typescript/components/Channel/hooks/useCreateThreadContext.d.ts.map +1 -1
  235. package/lib/typescript/components/ChannelList/ChannelList.d.ts.map +1 -1
  236. package/lib/typescript/components/ChannelList/hooks/usePaginatedChannels.d.ts +1 -1
  237. package/lib/typescript/components/ChannelList/hooks/usePaginatedChannels.d.ts.map +1 -1
  238. package/lib/typescript/components/ChannelPreview/hooks/useIsChannelMuted.d.ts.map +1 -1
  239. package/lib/typescript/components/Chat/Chat.d.ts.map +1 -1
  240. package/lib/typescript/components/Chat/hooks/useAppSettings.d.ts.map +1 -1
  241. package/lib/typescript/components/Chat/hooks/useSyncDatabase.d.ts +9 -1
  242. package/lib/typescript/components/Chat/hooks/useSyncDatabase.d.ts.map +1 -1
  243. package/lib/typescript/components/MessageMenu/MessageUserReactions.d.ts.map +1 -1
  244. package/lib/typescript/components/MessageMenu/hooks/useFetchReactions.d.ts.map +1 -1
  245. package/lib/typescript/contexts/messagesContext/MessagesContext.d.ts +1 -1
  246. package/lib/typescript/contexts/messagesContext/MessagesContext.d.ts.map +1 -1
  247. package/lib/typescript/hooks/useTranslatedMessage.d.ts.map +1 -1
  248. package/lib/typescript/index.d.ts +1 -0
  249. package/lib/typescript/index.d.ts.map +1 -1
  250. package/lib/typescript/store/OfflineDB.d.ts +112 -0
  251. package/lib/typescript/store/OfflineDB.d.ts.map +1 -0
  252. package/lib/typescript/store/SqliteClient.d.ts +1 -1
  253. package/lib/typescript/store/SqliteClient.d.ts.map +1 -1
  254. package/lib/typescript/store/apis/addPendingTask.d.ts +1 -1
  255. package/lib/typescript/store/apis/addPendingTask.d.ts.map +1 -1
  256. package/lib/typescript/store/apis/channelExists.d.ts +4 -0
  257. package/lib/typescript/store/apis/channelExists.d.ts.map +1 -0
  258. package/lib/typescript/store/apis/deleteChannel.d.ts +2 -2
  259. package/lib/typescript/store/apis/deleteChannel.d.ts.map +1 -1
  260. package/lib/typescript/store/apis/deleteMember.d.ts +2 -2
  261. package/lib/typescript/store/apis/deleteMember.d.ts.map +1 -1
  262. package/lib/typescript/store/apis/deleteMessage.d.ts +3 -3
  263. package/lib/typescript/store/apis/deleteMessage.d.ts.map +1 -1
  264. package/lib/typescript/store/apis/deleteMessagesForChannel.d.ts +4 -3
  265. package/lib/typescript/store/apis/deleteMessagesForChannel.d.ts.map +1 -1
  266. package/lib/typescript/store/apis/deleteReaction.d.ts +7 -6
  267. package/lib/typescript/store/apis/deleteReaction.d.ts.map +1 -1
  268. package/lib/typescript/store/apis/deleteReactions.d.ts +2 -2
  269. package/lib/typescript/store/apis/deleteReactions.d.ts.map +1 -1
  270. package/lib/typescript/store/apis/dropPendingTasks.d.ts +16 -0
  271. package/lib/typescript/store/apis/dropPendingTasks.d.ts.map +1 -0
  272. package/lib/typescript/store/apis/getChannels.d.ts.map +1 -1
  273. package/lib/typescript/store/apis/getLastSyncedAt.d.ts +1 -1
  274. package/lib/typescript/store/apis/getLastSyncedAt.d.ts.map +1 -1
  275. package/lib/typescript/store/apis/getPendingTasks.d.ts +1 -1
  276. package/lib/typescript/store/apis/getPendingTasks.d.ts.map +1 -1
  277. package/lib/typescript/store/apis/getReactionsforFilterSort.d.ts +5 -3
  278. package/lib/typescript/store/apis/getReactionsforFilterSort.d.ts.map +1 -1
  279. package/lib/typescript/store/apis/index.d.ts +10 -1
  280. package/lib/typescript/store/apis/index.d.ts.map +1 -1
  281. package/lib/typescript/store/apis/insertReaction.d.ts +2 -2
  282. package/lib/typescript/store/apis/insertReaction.d.ts.map +1 -1
  283. package/lib/typescript/store/apis/queries/selectReactionsForMessages.d.ts +5 -1
  284. package/lib/typescript/store/apis/queries/selectReactionsForMessages.d.ts.map +1 -1
  285. package/lib/typescript/store/apis/softDeleteMessage.d.ts +5 -0
  286. package/lib/typescript/store/apis/softDeleteMessage.d.ts.map +1 -0
  287. package/lib/typescript/store/apis/updateMessage.d.ts +2 -2
  288. package/lib/typescript/store/apis/updateMessage.d.ts.map +1 -1
  289. package/lib/typescript/store/apis/updateReaction.d.ts +2 -2
  290. package/lib/typescript/store/apis/updateReaction.d.ts.map +1 -1
  291. package/lib/typescript/store/apis/upsertAppSettings.d.ts +3 -3
  292. package/lib/typescript/store/apis/upsertAppSettings.d.ts.map +1 -1
  293. package/lib/typescript/store/apis/upsertChannelData.d.ts +2 -2
  294. package/lib/typescript/store/apis/upsertChannelData.d.ts.map +1 -1
  295. package/lib/typescript/store/apis/upsertChannelDataFromChannel.d.ts +2 -2
  296. package/lib/typescript/store/apis/upsertChannelDataFromChannel.d.ts.map +1 -1
  297. package/lib/typescript/store/apis/upsertChannels.d.ts +3 -5
  298. package/lib/typescript/store/apis/upsertChannels.d.ts.map +1 -1
  299. package/lib/typescript/store/apis/upsertCidsForQuery.d.ts +2 -2
  300. package/lib/typescript/store/apis/upsertCidsForQuery.d.ts.map +1 -1
  301. package/lib/typescript/store/apis/upsertMembers.d.ts +2 -2
  302. package/lib/typescript/store/apis/upsertMembers.d.ts.map +1 -1
  303. package/lib/typescript/store/apis/upsertMessages.d.ts +2 -2
  304. package/lib/typescript/store/apis/upsertMessages.d.ts.map +1 -1
  305. package/lib/typescript/store/apis/upsertPoll.d.ts +7 -0
  306. package/lib/typescript/store/apis/upsertPoll.d.ts.map +1 -0
  307. package/lib/typescript/store/apis/upsertReads.d.ts +2 -2
  308. package/lib/typescript/store/apis/upsertReads.d.ts.map +1 -1
  309. package/lib/typescript/store/apis/upsertUserSyncStatus.d.ts +3 -2
  310. package/lib/typescript/store/apis/upsertUserSyncStatus.d.ts.map +1 -1
  311. package/lib/typescript/store/mappers/mapMemberToStorable.d.ts.map +1 -1
  312. package/lib/typescript/store/mappers/mapReadToStorable.d.ts.map +1 -1
  313. package/lib/typescript/store/mappers/mapStorableToMember.d.ts.map +1 -1
  314. package/lib/typescript/store/mappers/mapStorableToRead.d.ts.map +1 -1
  315. package/lib/typescript/store/mappers/mapStorableToTask.d.ts +2 -1
  316. package/lib/typescript/store/mappers/mapStorableToTask.d.ts.map +1 -1
  317. package/lib/typescript/store/mappers/mapTaskToStorable.d.ts +18 -10
  318. package/lib/typescript/store/mappers/mapTaskToStorable.d.ts.map +1 -1
  319. package/lib/typescript/store/schema.d.ts +3 -2
  320. package/lib/typescript/store/schema.d.ts.map +1 -1
  321. package/lib/typescript/utils/addReactionToLocalState.d.ts +1 -1
  322. package/lib/typescript/utils/addReactionToLocalState.d.ts.map +1 -1
  323. package/lib/typescript/utils/removeReactionFromLocalState.d.ts.map +1 -1
  324. package/package.json +5 -4
  325. package/src/__tests__/offline-support/offline-feature.js +894 -21
  326. package/src/__tests__/offline-support/optimistic-update.js +154 -44
  327. package/src/components/Channel/Channel.tsx +95 -118
  328. package/src/components/ChannelList/ChannelList.tsx +1 -23
  329. package/src/components/ChannelList/hooks/usePaginatedChannels.ts +9 -93
  330. package/src/components/ChannelPreview/hooks/useIsChannelMuted.ts +20 -2
  331. package/src/components/Chat/Chat.tsx +21 -45
  332. package/src/components/Chat/__tests__/Chat.test.js +21 -13
  333. package/src/components/Chat/hooks/useAppSettings.ts +17 -54
  334. package/src/components/Chat/hooks/useSyncDatabase.ts +11 -17
  335. package/src/components/MessageMenu/MessageUserReactions.tsx +7 -1
  336. package/src/components/MessageMenu/hooks/useFetchReactions.ts +68 -35
  337. package/src/contexts/messagesContext/MessagesContext.tsx +1 -1
  338. package/src/index.ts +1 -0
  339. package/src/mock-builders/event/channelVisible.js +7 -0
  340. package/src/mock-builders/event/memberAdded.js +3 -1
  341. package/src/mock-builders/event/memberRemoved.js +1 -0
  342. package/src/mock-builders/event/memberUpdated.js +1 -0
  343. package/src/mock-builders/event/messageNew.js +1 -0
  344. package/src/mock-builders/event/messageRead.js +5 -2
  345. package/src/mock-builders/event/notificationMarkUnread.js +3 -0
  346. package/src/mock-builders/generator/channel.ts +15 -3
  347. package/src/store/OfflineDB.ts +93 -0
  348. package/src/store/SqliteClient.ts +7 -1
  349. package/src/store/apis/addPendingTask.ts +2 -1
  350. package/src/store/apis/channelExists.ts +14 -0
  351. package/src/store/apis/deleteChannel.ts +9 -3
  352. package/src/store/apis/deleteMember.ts +4 -4
  353. package/src/store/apis/deleteMessage.ts +18 -8
  354. package/src/store/apis/deleteMessagesForChannel.ts +12 -8
  355. package/src/store/apis/deleteReaction.ts +39 -19
  356. package/src/store/apis/deleteReactions.ts +4 -4
  357. package/src/store/apis/dropPendingTasks.ts +32 -0
  358. package/src/store/apis/getChannelMessages.ts +1 -1
  359. package/src/store/apis/getChannels.ts +10 -7
  360. package/src/store/apis/getLastSyncedAt.ts +2 -5
  361. package/src/store/apis/getReactionsforFilterSort.ts +8 -7
  362. package/src/store/apis/index.ts +10 -1
  363. package/src/store/apis/insertReaction.ts +4 -4
  364. package/src/store/apis/queries/selectMessagesForChannels.ts +2 -2
  365. package/src/store/apis/queries/selectReactionsForMessages.ts +21 -2
  366. package/src/store/apis/softDeleteMessage.ts +32 -0
  367. package/src/store/apis/updateMessage.ts +3 -10
  368. package/src/store/apis/updateReaction.ts +7 -5
  369. package/src/store/apis/upsertAppSettings.ts +13 -9
  370. package/src/store/apis/upsertChannelData.ts +4 -4
  371. package/src/store/apis/upsertChannelDataFromChannel.ts +3 -3
  372. package/src/store/apis/upsertChannels.ts +14 -24
  373. package/src/store/apis/upsertCidsForQuery.ts +4 -4
  374. package/src/store/apis/upsertMembers.ts +4 -4
  375. package/src/store/apis/upsertMessages.ts +4 -4
  376. package/src/store/apis/upsertPoll.ts +29 -0
  377. package/src/store/apis/upsertReads.ts +4 -4
  378. package/src/store/apis/upsertUserSyncStatus.ts +13 -5
  379. package/src/store/mappers/mapMemberToStorable.ts +4 -0
  380. package/src/store/mappers/mapReadToStorable.ts +2 -1
  381. package/src/store/mappers/mapStorableToMember.ts +4 -0
  382. package/src/store/mappers/mapStorableToRead.ts +2 -1
  383. package/src/store/mappers/mapStorableToTask.ts +3 -1
  384. package/src/store/mappers/mapTaskToStorable.ts +1 -1
  385. package/src/store/schema.ts +5 -3
  386. package/src/utils/addReactionToLocalState.ts +9 -63
  387. package/src/utils/removeReactionFromLocalState.ts +0 -8
  388. package/src/version.json +1 -1
  389. package/lib/commonjs/components/Chat/hooks/handleEventToSyncDB.js +0 -406
  390. package/lib/commonjs/components/Chat/hooks/handleEventToSyncDB.js.map +0 -1
  391. package/lib/commonjs/store/apis/updatePollMessage.js +0 -84
  392. package/lib/commonjs/store/apis/updatePollMessage.js.map +0 -1
  393. package/lib/commonjs/utils/DBSyncManager.js +0 -470
  394. package/lib/commonjs/utils/DBSyncManager.js.map +0 -1
  395. package/lib/module/components/Chat/hooks/handleEventToSyncDB.js +0 -406
  396. package/lib/module/components/Chat/hooks/handleEventToSyncDB.js.map +0 -1
  397. package/lib/module/store/apis/updatePollMessage.js +0 -84
  398. package/lib/module/store/apis/updatePollMessage.js.map +0 -1
  399. package/lib/module/utils/DBSyncManager.js +0 -470
  400. package/lib/module/utils/DBSyncManager.js.map +0 -1
  401. package/lib/typescript/components/Chat/hooks/handleEventToSyncDB.d.ts +0 -4
  402. package/lib/typescript/components/Chat/hooks/handleEventToSyncDB.d.ts.map +0 -1
  403. package/lib/typescript/store/apis/updatePollMessage.d.ts +0 -10
  404. package/lib/typescript/store/apis/updatePollMessage.d.ts.map +0 -1
  405. package/lib/typescript/utils/DBSyncManager.d.ts +0 -50
  406. package/lib/typescript/utils/DBSyncManager.d.ts.map +0 -1
  407. package/src/components/Chat/hooks/handleEventToSyncDB.ts +0 -290
  408. package/src/store/apis/updatePollMessage.ts +0 -71
  409. 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 succesful', async () => {
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 succesful', async () => {
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 succesful', async () => {
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
- it('pending task should be executed after connection is recovered', async () => {
330
- const message = channel.state.messages[0];
331
- const reaction = generateReaction();
332
-
333
- render(
334
- <Chat client={chatClient} enableOfflineSupport>
335
- <Channel channel={channel} initialValue={message.text}>
336
- <CallbackEffectWithContext
337
- callback={async ({ deleteMessage, sendReaction }) => {
338
- useMockedApis(chatClient, [erroredDeleteApi()]);
339
- try {
340
- await deleteMessage(reaction);
341
- } catch (e) {
342
- // do nothing
343
- }
344
-
345
- useMockedApis(chatClient, [erroredPostApi()]);
346
- try {
347
- await sendReaction(reaction.type, message.id);
348
- } catch (e) {
349
- // do nothing
350
- }
351
- }}
352
- context={MessagesContext}
353
- >
354
- <View testID='children' />
355
- </CallbackEffectWithContext>
356
- </Channel>
357
- </Chat>,
358
- );
359
- await waitFor(() => expect(screen.getByTestId('children')).toBeTruthy());
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
- await waitFor(async () => {
362
- const pendingTasksRows = await BetterSqlite.selectFromTable('pendingTasks');
436
+ act(() => dispatchConnectionChangedEvent(chatClient, true));
363
437
 
364
- expect(pendingTasksRows.length).toBe(2);
438
+ await waitFor(() => {
439
+ expect(deleteMessageSpy).toHaveBeenCalled();
440
+ expect(sendReactionSpy).toHaveBeenCalled();
441
+ });
365
442
  });
366
443
 
367
- jest.spyOn(chatClient, 'deleteMessage').mockImplementation();
368
- jest.spyOn(channel, 'sendReaction').mockImplementation();
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
- act(() => dispatchConnectionChangedEvent(chatClient, true));
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
- await waitFor(() => {
373
- expect(chatClient.deleteMessage).toHaveBeenCalled();
374
- expect(channel.sendReaction).toHaveBeenCalled();
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 = DBSyncManager.onSyncStatusChange((statusChanged) => {
1107
- if (statusChanged) {
1108
- connectionChangedHandler();
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
- // eslint-disable-next-line react-hooks/exhaustive-deps
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.message) {
1396
- messageResponse.message.status = MessageStatusTypes.RECEIVED;
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: { ...messageResponse.message, cid: channel.cid },
1430
+ message: { ...newMessageResponse, cid: channel.cid },
1401
1431
  });
1402
1432
  }
1403
1433
  if (retrying) {
1404
- replaceMessage(message, messageResponse.message);
1434
+ replaceMessage(message, newMessageResponse);
1405
1435
  } else {
1406
- updateMessage(messageResponse.message, {}, true);
1436
+ updateMessage(newMessageResponse, {}, true);
1407
1437
  }
1408
1438
  }
1409
1439
  } catch (err) {
1410
1440
  console.log(err);
1411
- message.status = MessageStatusTypes.FAILED;
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 (enableOfflineSupport) {
1516
- await dbApi.deleteMessage({
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 (!enableOfflineSupport) {
1537
- await channel.sendReaction(...payload);
1538
- return;
1539
- }
1554
+ if (enableOfflineSupport) {
1555
+ await addReactionToLocalState({
1556
+ channel,
1557
+ enforceUniqueReaction,
1558
+ messageId,
1559
+ reactionType: type,
1560
+ user: client.user,
1561
+ });
1540
1562
 
1541
- addReactionToLocalState({
1542
- channel,
1543
- enforceUniqueReaction,
1544
- messageId,
1545
- reactionType: type,
1546
- user: client.user,
1547
- });
1563
+ copyMessagesStateFromChannel(channel);
1564
+ }
1548
1565
 
1549
- copyMessagesStateFromChannel(channel);
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 (!enableOfflineSupport) {
1573
- if (message.status === MessageStatusTypes.FAILED) {
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
- if (message.status === MessageStatusTypes.FAILED) {
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
- if (data?.message) {
1607
- updateMessage({ ...data.message });
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 (!enableOfflineSupport) {
1622
- await channel.deleteReaction(...payload);
1623
- return;
1624
- }
1625
-
1626
- removeReactionFromLocalState({
1627
- channel,
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
- copyMessagesStateFromChannel(channel);
1617
+ copyMessagesStateFromChannel(channel);
1618
+ }
1634
1619
 
1635
- await DBSyncManager.queueTask({
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: true, lockChannelOrder });
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,