@ethora/chat-component-rn 26.8.1 → 26.8.2

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 (604) hide show
  1. package/CHANGELOG.md +96 -0
  2. package/README.md +43 -10
  3. package/lib/commonjs/assets/icons.js +7 -2
  4. package/lib/commonjs/assets/icons.js.map +1 -1
  5. package/lib/commonjs/components/AuthForms/Login.js +4 -4
  6. package/lib/commonjs/components/AuthForms/Login.js.map +1 -1
  7. package/lib/commonjs/components/Header/HeaderRoomList.js +29 -8
  8. package/lib/commonjs/components/Header/HeaderRoomList.js.map +1 -1
  9. package/lib/commonjs/components/MainComponents/ChatHeader.js +9 -3
  10. package/lib/commonjs/components/MainComponents/ChatHeader.js.map +1 -1
  11. package/lib/commonjs/components/MainComponents/ChatRoom.js +150 -14
  12. package/lib/commonjs/components/MainComponents/ChatRoom.js.map +1 -1
  13. package/lib/commonjs/components/MainComponents/ChatWrapper.js +34 -13
  14. package/lib/commonjs/components/MainComponents/ChatWrapper.js.map +1 -1
  15. package/lib/commonjs/components/MainComponents/LoginWrapper.js +2 -1
  16. package/lib/commonjs/components/MainComponents/LoginWrapper.js.map +1 -1
  17. package/lib/commonjs/components/MainComponents/MediaMessage.js +29 -9
  18. package/lib/commonjs/components/MainComponents/MediaMessage.js.map +1 -1
  19. package/lib/commonjs/components/MainComponents/MessageContainer.js +5 -1
  20. package/lib/commonjs/components/MainComponents/MessageContainer.js.map +1 -1
  21. package/lib/commonjs/components/MainComponents/MessageList.js +13 -5
  22. package/lib/commonjs/components/MainComponents/MessageList.js.map +1 -1
  23. package/lib/commonjs/components/MainComponents/ProfileImagePlaceholder.js +14 -13
  24. package/lib/commonjs/components/MainComponents/ProfileImagePlaceholder.js.map +1 -1
  25. package/lib/commonjs/components/MainComponents/RoomList.js +208 -35
  26. package/lib/commonjs/components/MainComponents/RoomList.js.map +1 -1
  27. package/lib/commonjs/components/Menu/HeaderRoomListMenu.js +317 -98
  28. package/lib/commonjs/components/Menu/HeaderRoomListMenu.js.map +1 -1
  29. package/lib/commonjs/components/Modals/AttachSheet/AttachSheet.js +322 -110
  30. package/lib/commonjs/components/Modals/AttachSheet/AttachSheet.js.map +1 -1
  31. package/lib/commonjs/components/Modals/ChatProfileModal/ChatProfileModal.js +546 -203
  32. package/lib/commonjs/components/Modals/ChatProfileModal/ChatProfileModal.js.map +1 -1
  33. package/lib/commonjs/components/Modals/ChatProfileModal/ReportChatModal.js +226 -0
  34. package/lib/commonjs/components/Modals/ChatProfileModal/ReportChatModal.js.map +1 -0
  35. package/lib/commonjs/components/Modals/FilePreviewModal/FilePreviewModal.js +69 -27
  36. package/lib/commonjs/components/Modals/FilePreviewModal/FilePreviewModal.js.map +1 -1
  37. package/lib/commonjs/components/Modals/FilePreviewModal/PdfView.js +2 -1
  38. package/lib/commonjs/components/Modals/FilePreviewModal/PdfView.js.map +1 -1
  39. package/lib/commonjs/components/Modals/Modal/Modal.js +8 -0
  40. package/lib/commonjs/components/Modals/Modal/Modal.js.map +1 -1
  41. package/lib/commonjs/components/Modals/NewChatModal/ModalContent.js +2 -1
  42. package/lib/commonjs/components/Modals/NewChatModal/ModalContent.js.map +1 -1
  43. package/lib/commonjs/components/Modals/NewChatModal/NewChatModal.js +202 -106
  44. package/lib/commonjs/components/Modals/NewChatModal/NewChatModal.js.map +1 -1
  45. package/lib/commonjs/components/Modals/NewChatModal/UpdNewChatModal.js +8 -0
  46. package/lib/commonjs/components/Modals/NewChatModal/UpdNewChatModal.js.map +1 -1
  47. package/lib/commonjs/components/Modals/ProfileHeader/ProfileHeader.js +563 -0
  48. package/lib/commonjs/components/Modals/ProfileHeader/ProfileHeader.js.map +1 -0
  49. package/lib/commonjs/components/Modals/ProfileHeader/ProfileMenu.js +210 -0
  50. package/lib/commonjs/components/Modals/ProfileHeader/ProfileMenu.js.map +1 -0
  51. package/lib/commonjs/components/Modals/SelectUsersModal/SelectUsersModal.js +4 -2
  52. package/lib/commonjs/components/Modals/SelectUsersModal/SelectUsersModal.js.map +1 -1
  53. package/lib/commonjs/components/Modals/UserProfileModal/EditUserModal.js +7 -21
  54. package/lib/commonjs/components/Modals/UserProfileModal/EditUserModal.js.map +1 -1
  55. package/lib/commonjs/components/Modals/UserProfileModal/UserProfileModal.js +507 -244
  56. package/lib/commonjs/components/Modals/UserProfileModal/UserProfileModal.js.map +1 -1
  57. package/lib/commonjs/components/Modals/UserSettingsModal/UserSettingsModal.js +74 -46
  58. package/lib/commonjs/components/Modals/UserSettingsModal/UserSettingsModal.js.map +1 -1
  59. package/lib/commonjs/components/Modals/styledModalComponents.js +9 -2
  60. package/lib/commonjs/components/Modals/styledModalComponents.js.map +1 -1
  61. package/lib/commonjs/components/RoomComponents/ChatRoomItem.js +21 -7
  62. package/lib/commonjs/components/RoomComponents/ChatRoomItem.js.map +1 -1
  63. package/lib/commonjs/components/RoomComponents/styled/LastMessageFile.js +22 -3
  64. package/lib/commonjs/components/RoomComponents/styled/LastMessageFile.js.map +1 -1
  65. package/lib/commonjs/components/RoomComponents/styled/LastMessagePhoto.js +17 -3
  66. package/lib/commonjs/components/RoomComponents/styled/LastMessagePhoto.js.map +1 -1
  67. package/lib/commonjs/components/RoomComponents/styled/LastMessageVideo.js +17 -3
  68. package/lib/commonjs/components/RoomComponents/styled/LastMessageVideo.js.map +1 -1
  69. package/lib/commonjs/components/VideoCalls/VideoCallSession.js +6 -3
  70. package/lib/commonjs/components/VideoCalls/VideoCallSession.js.map +1 -1
  71. package/lib/commonjs/components/styled/AudioMessage.js +2 -1
  72. package/lib/commonjs/components/styled/AudioMessage.js.map +1 -1
  73. package/lib/commonjs/components/styled/MessageImage.js +37 -9
  74. package/lib/commonjs/components/styled/MessageImage.js.map +1 -1
  75. package/lib/commonjs/components/styled/SendInput.js +80 -11
  76. package/lib/commonjs/components/styled/SendInput.js.map +1 -1
  77. package/lib/commonjs/components/styled/StyledComponents.js +9 -3
  78. package/lib/commonjs/components/styled/StyledComponents.js.map +1 -1
  79. package/lib/commonjs/components/styled/StyledInputComponents/StyledInputComponents.js +11 -4
  80. package/lib/commonjs/components/styled/StyledInputComponents/StyledInputComponents.js.map +1 -1
  81. package/lib/commonjs/components/styled/UnsupportedType.js +14 -4
  82. package/lib/commonjs/components/styled/UnsupportedType.js.map +1 -1
  83. package/lib/commonjs/components/styled/VideoMessage.js +119 -61
  84. package/lib/commonjs/components/styled/VideoMessage.js.map +1 -1
  85. package/lib/commonjs/context/xmppProvider.js +184 -59
  86. package/lib/commonjs/context/xmppProvider.js.map +1 -1
  87. package/lib/commonjs/helpers/createMessageFromXml.js +19 -1
  88. package/lib/commonjs/helpers/createMessageFromXml.js.map +1 -1
  89. package/lib/commonjs/helpers/ensureScopedChatCache.js +2 -2
  90. package/lib/commonjs/helpers/ensureScopedChatCache.js.map +1 -1
  91. package/lib/commonjs/helpers/getChatBackground.js +23 -0
  92. package/lib/commonjs/helpers/getChatBackground.js.map +1 -0
  93. package/lib/commonjs/helpers/getDisplayFileName.js +79 -0
  94. package/lib/commonjs/helpers/getDisplayFileName.js.map +1 -0
  95. package/lib/commonjs/helpers/getServerReadTimestamp.js +188 -0
  96. package/lib/commonjs/helpers/getServerReadTimestamp.js.map +1 -0
  97. package/lib/commonjs/helpers/historyPreloadScheduler.js +65 -2
  98. package/lib/commonjs/helpers/historyPreloadScheduler.js.map +1 -1
  99. package/lib/commonjs/helpers/initXmppRooms.js +14 -8
  100. package/lib/commonjs/helpers/initXmppRooms.js.map +1 -1
  101. package/lib/commonjs/helpers/insertMessageWithDelimiter.js +51 -9
  102. package/lib/commonjs/helpers/insertMessageWithDelimiter.js.map +1 -1
  103. package/lib/commonjs/helpers/isOwnMessage.js +75 -0
  104. package/lib/commonjs/helpers/isOwnMessage.js.map +1 -0
  105. package/lib/commonjs/helpers/keyboardLayout.js +12 -2
  106. package/lib/commonjs/helpers/keyboardLayout.js.map +1 -1
  107. package/lib/commonjs/helpers/mediaLibraryRuntime.js +31 -0
  108. package/lib/commonjs/helpers/mediaLibraryRuntime.js.map +1 -0
  109. package/lib/commonjs/helpers/mimeToExtension.js +6 -14
  110. package/lib/commonjs/helpers/mimeToExtension.js.map +1 -1
  111. package/lib/commonjs/helpers/msgSortableMs.js +37 -0
  112. package/lib/commonjs/helpers/msgSortableMs.js.map +1 -0
  113. package/lib/commonjs/helpers/persistCrypto.js +122 -0
  114. package/lib/commonjs/helpers/persistCrypto.js.map +1 -0
  115. package/lib/commonjs/helpers/pickImageAsset.js +68 -0
  116. package/lib/commonjs/helpers/pickImageAsset.js.map +1 -0
  117. package/lib/commonjs/helpers/pushPayload.js +71 -0
  118. package/lib/commonjs/helpers/pushPayload.js.map +1 -0
  119. package/lib/commonjs/helpers/resolveInitBeforeLoadUser.js +130 -17
  120. package/lib/commonjs/helpers/resolveInitBeforeLoadUser.js.map +1 -1
  121. package/lib/commonjs/helpers/secureFileUrl.js +101 -0
  122. package/lib/commonjs/helpers/secureFileUrl.js.map +1 -0
  123. package/lib/commonjs/helpers/secureKeyValue.js +83 -0
  124. package/lib/commonjs/helpers/secureKeyValue.js.map +1 -0
  125. package/lib/commonjs/helpers/secureStoreRuntime.js +59 -0
  126. package/lib/commonjs/helpers/secureStoreRuntime.js.map +1 -0
  127. package/lib/commonjs/helpers/secureUserStorage.js +75 -0
  128. package/lib/commonjs/helpers/secureUserStorage.js.map +1 -0
  129. package/lib/commonjs/helpers/shallowEqual.js +36 -0
  130. package/lib/commonjs/helpers/shallowEqual.js.map +1 -0
  131. package/lib/commonjs/helpers/sheetGestures.js +32 -0
  132. package/lib/commonjs/helpers/sheetGestures.js.map +1 -0
  133. package/lib/commonjs/hooks/useChatRoomFocus.js +45 -12
  134. package/lib/commonjs/hooks/useChatRoomFocus.js.map +1 -1
  135. package/lib/commonjs/hooks/useChatWrapperInit.js +30 -10
  136. package/lib/commonjs/hooks/useChatWrapperInit.js.map +1 -1
  137. package/lib/commonjs/hooks/useComposing.js +27 -0
  138. package/lib/commonjs/hooks/useComposing.js.map +1 -1
  139. package/lib/commonjs/hooks/useFileToken.js +10 -0
  140. package/lib/commonjs/hooks/useFileToken.js.map +1 -0
  141. package/lib/commonjs/hooks/useLogout.js +23 -7
  142. package/lib/commonjs/hooks/useLogout.js.map +1 -1
  143. package/lib/commonjs/hooks/usePendingNotification.js +8 -11
  144. package/lib/commonjs/hooks/usePendingNotification.js.map +1 -1
  145. package/lib/commonjs/hooks/useSendMessage.js +50 -14
  146. package/lib/commonjs/hooks/useSendMessage.js.map +1 -1
  147. package/lib/commonjs/hooks/useUnreadMessagesCounter.js +6 -1
  148. package/lib/commonjs/hooks/useUnreadMessagesCounter.js.map +1 -1
  149. package/lib/commonjs/i18n/strings.js +145 -37
  150. package/lib/commonjs/i18n/strings.js.map +1 -1
  151. package/lib/commonjs/main.js +44 -0
  152. package/lib/commonjs/main.js.map +1 -1
  153. package/lib/commonjs/networking/api-requests/auth.api.js +134 -60
  154. package/lib/commonjs/networking/api-requests/auth.api.js.map +1 -1
  155. package/lib/commonjs/networking/api-requests/roomMembers.api.js +1 -1
  156. package/lib/commonjs/networking/api-requests/roomMembers.api.js.map +1 -1
  157. package/lib/commonjs/networking/api-requests/rooms.api.js +9 -9
  158. package/lib/commonjs/networking/api-requests/rooms.api.js.map +1 -1
  159. package/lib/commonjs/networking/api-requests/user.api.js +68 -9
  160. package/lib/commonjs/networking/api-requests/user.api.js.map +1 -1
  161. package/lib/commonjs/networking/apiClient.js +62 -112
  162. package/lib/commonjs/networking/apiClient.js.map +1 -1
  163. package/lib/commonjs/networking/authRefresh.js +332 -0
  164. package/lib/commonjs/networking/authRefresh.js.map +1 -0
  165. package/lib/commonjs/networking/stanzaHandlers.js +41 -28
  166. package/lib/commonjs/networking/stanzaHandlers.js.map +1 -1
  167. package/lib/commonjs/networking/xmpp/flushLastViewedToPrivateStore.js +46 -8
  168. package/lib/commonjs/networking/xmpp/flushLastViewedToPrivateStore.js.map +1 -1
  169. package/lib/commonjs/networking/xmpp/presenceInRoom.xmpp.js +8 -1
  170. package/lib/commonjs/networking/xmpp/presenceInRoom.xmpp.js.map +1 -1
  171. package/lib/commonjs/networking/xmpp/subscribeToRoomMessages.xmpp.js +5 -1
  172. package/lib/commonjs/networking/xmpp/subscribeToRoomMessages.xmpp.js.map +1 -1
  173. package/lib/commonjs/networking/xmppClient.js +124 -8
  174. package/lib/commonjs/networking/xmppClient.js.map +1 -1
  175. package/lib/commonjs/roomStore/chatSettingsSlice.js +26 -7
  176. package/lib/commonjs/roomStore/chatSettingsSlice.js.map +1 -1
  177. package/lib/commonjs/roomStore/index.js +35 -2
  178. package/lib/commonjs/roomStore/index.js.map +1 -1
  179. package/lib/commonjs/roomStore/persistence.js +226 -23
  180. package/lib/commonjs/roomStore/persistence.js.map +1 -1
  181. package/lib/commonjs/roomStore/roomsSlice.js +151 -38
  182. package/lib/commonjs/roomStore/roomsSlice.js.map +1 -1
  183. package/lib/commonjs/services/pushSubscriptionService.js +15 -13
  184. package/lib/commonjs/services/pushSubscriptionService.js.map +1 -1
  185. package/lib/commonjs/version.js +1 -1
  186. package/lib/module/assets/icons.js +6 -1
  187. package/lib/module/assets/icons.js.map +1 -1
  188. package/lib/module/components/AuthForms/Login.js +4 -4
  189. package/lib/module/components/AuthForms/Login.js.map +1 -1
  190. package/lib/module/components/Header/HeaderRoomList.js +29 -8
  191. package/lib/module/components/Header/HeaderRoomList.js.map +1 -1
  192. package/lib/module/components/MainComponents/ChatHeader.js +9 -3
  193. package/lib/module/components/MainComponents/ChatHeader.js.map +1 -1
  194. package/lib/module/components/MainComponents/ChatRoom.js +152 -16
  195. package/lib/module/components/MainComponents/ChatRoom.js.map +1 -1
  196. package/lib/module/components/MainComponents/ChatWrapper.js +35 -14
  197. package/lib/module/components/MainComponents/ChatWrapper.js.map +1 -1
  198. package/lib/module/components/MainComponents/LoginWrapper.js +2 -1
  199. package/lib/module/components/MainComponents/LoginWrapper.js.map +1 -1
  200. package/lib/module/components/MainComponents/MediaMessage.js +30 -10
  201. package/lib/module/components/MainComponents/MediaMessage.js.map +1 -1
  202. package/lib/module/components/MainComponents/MessageContainer.js +5 -1
  203. package/lib/module/components/MainComponents/MessageContainer.js.map +1 -1
  204. package/lib/module/components/MainComponents/MessageList.js +13 -5
  205. package/lib/module/components/MainComponents/MessageList.js.map +1 -1
  206. package/lib/module/components/MainComponents/ProfileImagePlaceholder.js +14 -13
  207. package/lib/module/components/MainComponents/ProfileImagePlaceholder.js.map +1 -1
  208. package/lib/module/components/MainComponents/RoomList.js +207 -35
  209. package/lib/module/components/MainComponents/RoomList.js.map +1 -1
  210. package/lib/module/components/Menu/HeaderRoomListMenu.js +319 -101
  211. package/lib/module/components/Menu/HeaderRoomListMenu.js.map +1 -1
  212. package/lib/module/components/Modals/AttachSheet/AttachSheet.js +313 -113
  213. package/lib/module/components/Modals/AttachSheet/AttachSheet.js.map +1 -1
  214. package/lib/module/components/Modals/ChatProfileModal/ChatProfileModal.js +549 -207
  215. package/lib/module/components/Modals/ChatProfileModal/ChatProfileModal.js.map +1 -1
  216. package/lib/module/components/Modals/ChatProfileModal/ReportChatModal.js +223 -0
  217. package/lib/module/components/Modals/ChatProfileModal/ReportChatModal.js.map +1 -0
  218. package/lib/module/components/Modals/FilePreviewModal/FilePreviewModal.js +70 -28
  219. package/lib/module/components/Modals/FilePreviewModal/FilePreviewModal.js.map +1 -1
  220. package/lib/module/components/Modals/FilePreviewModal/PdfView.js +2 -1
  221. package/lib/module/components/Modals/FilePreviewModal/PdfView.js.map +1 -1
  222. package/lib/module/components/Modals/Modal/Modal.js +9 -1
  223. package/lib/module/components/Modals/Modal/Modal.js.map +1 -1
  224. package/lib/module/components/Modals/NewChatModal/ModalContent.js +2 -1
  225. package/lib/module/components/Modals/NewChatModal/ModalContent.js.map +1 -1
  226. package/lib/module/components/Modals/NewChatModal/NewChatModal.js +205 -108
  227. package/lib/module/components/Modals/NewChatModal/NewChatModal.js.map +1 -1
  228. package/lib/module/components/Modals/NewChatModal/UpdNewChatModal.js +8 -0
  229. package/lib/module/components/Modals/NewChatModal/UpdNewChatModal.js.map +1 -1
  230. package/lib/module/components/Modals/ProfileHeader/ProfileHeader.js +555 -0
  231. package/lib/module/components/Modals/ProfileHeader/ProfileHeader.js.map +1 -0
  232. package/lib/module/components/Modals/ProfileHeader/ProfileMenu.js +205 -0
  233. package/lib/module/components/Modals/ProfileHeader/ProfileMenu.js.map +1 -0
  234. package/lib/module/components/Modals/SelectUsersModal/SelectUsersModal.js +4 -2
  235. package/lib/module/components/Modals/SelectUsersModal/SelectUsersModal.js.map +1 -1
  236. package/lib/module/components/Modals/UserProfileModal/EditUserModal.js +9 -23
  237. package/lib/module/components/Modals/UserProfileModal/EditUserModal.js.map +1 -1
  238. package/lib/module/components/Modals/UserProfileModal/UserProfileModal.js +509 -248
  239. package/lib/module/components/Modals/UserProfileModal/UserProfileModal.js.map +1 -1
  240. package/lib/module/components/Modals/UserSettingsModal/UserSettingsModal.js +76 -48
  241. package/lib/module/components/Modals/UserSettingsModal/UserSettingsModal.js.map +1 -1
  242. package/lib/module/components/Modals/styledModalComponents.js +9 -2
  243. package/lib/module/components/Modals/styledModalComponents.js.map +1 -1
  244. package/lib/module/components/RoomComponents/ChatRoomItem.js +21 -7
  245. package/lib/module/components/RoomComponents/ChatRoomItem.js.map +1 -1
  246. package/lib/module/components/RoomComponents/styled/LastMessageFile.js +22 -3
  247. package/lib/module/components/RoomComponents/styled/LastMessageFile.js.map +1 -1
  248. package/lib/module/components/RoomComponents/styled/LastMessagePhoto.js +17 -3
  249. package/lib/module/components/RoomComponents/styled/LastMessagePhoto.js.map +1 -1
  250. package/lib/module/components/RoomComponents/styled/LastMessageVideo.js +17 -3
  251. package/lib/module/components/RoomComponents/styled/LastMessageVideo.js.map +1 -1
  252. package/lib/module/components/VideoCalls/VideoCallSession.js +6 -3
  253. package/lib/module/components/VideoCalls/VideoCallSession.js.map +1 -1
  254. package/lib/module/components/styled/AudioMessage.js +2 -1
  255. package/lib/module/components/styled/AudioMessage.js.map +1 -1
  256. package/lib/module/components/styled/MessageImage.js +37 -9
  257. package/lib/module/components/styled/MessageImage.js.map +1 -1
  258. package/lib/module/components/styled/SendInput.js +81 -12
  259. package/lib/module/components/styled/SendInput.js.map +1 -1
  260. package/lib/module/components/styled/StyledComponents.js +9 -3
  261. package/lib/module/components/styled/StyledComponents.js.map +1 -1
  262. package/lib/module/components/styled/StyledInputComponents/StyledInputComponents.js +11 -4
  263. package/lib/module/components/styled/StyledInputComponents/StyledInputComponents.js.map +1 -1
  264. package/lib/module/components/styled/UnsupportedType.js +14 -4
  265. package/lib/module/components/styled/UnsupportedType.js.map +1 -1
  266. package/lib/module/components/styled/VideoMessage.js +120 -62
  267. package/lib/module/components/styled/VideoMessage.js.map +1 -1
  268. package/lib/module/context/xmppProvider.js +184 -60
  269. package/lib/module/context/xmppProvider.js.map +1 -1
  270. package/lib/module/helpers/createMessageFromXml.js +19 -1
  271. package/lib/module/helpers/createMessageFromXml.js.map +1 -1
  272. package/lib/module/helpers/ensureScopedChatCache.js +2 -2
  273. package/lib/module/helpers/ensureScopedChatCache.js.map +1 -1
  274. package/lib/module/helpers/getChatBackground.js +18 -0
  275. package/lib/module/helpers/getChatBackground.js.map +1 -0
  276. package/lib/module/helpers/getDisplayFileName.js +73 -0
  277. package/lib/module/helpers/getDisplayFileName.js.map +1 -0
  278. package/lib/module/helpers/getServerReadTimestamp.js +181 -0
  279. package/lib/module/helpers/getServerReadTimestamp.js.map +1 -0
  280. package/lib/module/helpers/historyPreloadScheduler.js +66 -3
  281. package/lib/module/helpers/historyPreloadScheduler.js.map +1 -1
  282. package/lib/module/helpers/initXmppRooms.js +14 -8
  283. package/lib/module/helpers/initXmppRooms.js.map +1 -1
  284. package/lib/module/helpers/insertMessageWithDelimiter.js +52 -9
  285. package/lib/module/helpers/insertMessageWithDelimiter.js.map +1 -1
  286. package/lib/module/helpers/isOwnMessage.js +70 -0
  287. package/lib/module/helpers/isOwnMessage.js.map +1 -0
  288. package/lib/module/helpers/keyboardLayout.js +12 -2
  289. package/lib/module/helpers/keyboardLayout.js.map +1 -1
  290. package/lib/module/helpers/mediaLibraryRuntime.js +25 -0
  291. package/lib/module/helpers/mediaLibraryRuntime.js.map +1 -0
  292. package/lib/module/helpers/mimeToExtension.js +6 -13
  293. package/lib/module/helpers/mimeToExtension.js.map +1 -1
  294. package/lib/module/helpers/msgSortableMs.js +32 -0
  295. package/lib/module/helpers/msgSortableMs.js.map +1 -0
  296. package/lib/module/helpers/persistCrypto.js +115 -0
  297. package/lib/module/helpers/persistCrypto.js.map +1 -0
  298. package/lib/module/helpers/pickImageAsset.js +63 -0
  299. package/lib/module/helpers/pickImageAsset.js.map +1 -0
  300. package/lib/module/helpers/pushPayload.js +63 -0
  301. package/lib/module/helpers/pushPayload.js.map +1 -0
  302. package/lib/module/helpers/resolveInitBeforeLoadUser.js +130 -16
  303. package/lib/module/helpers/resolveInitBeforeLoadUser.js.map +1 -1
  304. package/lib/module/helpers/secureFileUrl.js +91 -0
  305. package/lib/module/helpers/secureFileUrl.js.map +1 -0
  306. package/lib/module/helpers/secureKeyValue.js +75 -0
  307. package/lib/module/helpers/secureKeyValue.js.map +1 -0
  308. package/lib/module/helpers/secureStoreRuntime.js +52 -0
  309. package/lib/module/helpers/secureStoreRuntime.js.map +1 -0
  310. package/lib/module/helpers/secureUserStorage.js +72 -0
  311. package/lib/module/helpers/secureUserStorage.js.map +1 -0
  312. package/lib/module/helpers/shallowEqual.js +31 -0
  313. package/lib/module/helpers/shallowEqual.js.map +1 -0
  314. package/lib/module/helpers/sheetGestures.js +26 -0
  315. package/lib/module/helpers/sheetGestures.js.map +1 -0
  316. package/lib/module/hooks/useChatRoomFocus.js +46 -13
  317. package/lib/module/hooks/useChatRoomFocus.js.map +1 -1
  318. package/lib/module/hooks/useChatWrapperInit.js +30 -10
  319. package/lib/module/hooks/useChatWrapperInit.js.map +1 -1
  320. package/lib/module/hooks/useComposing.js +28 -1
  321. package/lib/module/hooks/useComposing.js.map +1 -1
  322. package/lib/module/hooks/useFileToken.js +5 -0
  323. package/lib/module/hooks/useFileToken.js.map +1 -0
  324. package/lib/module/hooks/useLogout.js +23 -7
  325. package/lib/module/hooks/useLogout.js.map +1 -1
  326. package/lib/module/hooks/usePendingNotification.js +8 -11
  327. package/lib/module/hooks/usePendingNotification.js.map +1 -1
  328. package/lib/module/hooks/useSendMessage.js +52 -16
  329. package/lib/module/hooks/useSendMessage.js.map +1 -1
  330. package/lib/module/hooks/useUnreadMessagesCounter.js +6 -1
  331. package/lib/module/hooks/useUnreadMessagesCounter.js.map +1 -1
  332. package/lib/module/i18n/strings.js +145 -37
  333. package/lib/module/i18n/strings.js.map +1 -1
  334. package/lib/module/main.js +14 -2
  335. package/lib/module/main.js.map +1 -1
  336. package/lib/module/networking/api-requests/auth.api.js +131 -59
  337. package/lib/module/networking/api-requests/auth.api.js.map +1 -1
  338. package/lib/module/networking/api-requests/roomMembers.api.js +1 -1
  339. package/lib/module/networking/api-requests/roomMembers.api.js.map +1 -1
  340. package/lib/module/networking/api-requests/rooms.api.js +9 -9
  341. package/lib/module/networking/api-requests/rooms.api.js.map +1 -1
  342. package/lib/module/networking/api-requests/user.api.js +64 -7
  343. package/lib/module/networking/api-requests/user.api.js.map +1 -1
  344. package/lib/module/networking/apiClient.js +61 -113
  345. package/lib/module/networking/apiClient.js.map +1 -1
  346. package/lib/module/networking/authRefresh.js +321 -0
  347. package/lib/module/networking/authRefresh.js.map +1 -0
  348. package/lib/module/networking/stanzaHandlers.js +41 -28
  349. package/lib/module/networking/stanzaHandlers.js.map +1 -1
  350. package/lib/module/networking/xmpp/flushLastViewedToPrivateStore.js +46 -8
  351. package/lib/module/networking/xmpp/flushLastViewedToPrivateStore.js.map +1 -1
  352. package/lib/module/networking/xmpp/presenceInRoom.xmpp.js +8 -1
  353. package/lib/module/networking/xmpp/presenceInRoom.xmpp.js.map +1 -1
  354. package/lib/module/networking/xmpp/subscribeToRoomMessages.xmpp.js +5 -1
  355. package/lib/module/networking/xmpp/subscribeToRoomMessages.xmpp.js.map +1 -1
  356. package/lib/module/networking/xmppClient.js +124 -8
  357. package/lib/module/networking/xmppClient.js.map +1 -1
  358. package/lib/module/roomStore/chatSettingsSlice.js +26 -7
  359. package/lib/module/roomStore/chatSettingsSlice.js.map +1 -1
  360. package/lib/module/roomStore/index.js +37 -4
  361. package/lib/module/roomStore/index.js.map +1 -1
  362. package/lib/module/roomStore/persistence.js +223 -22
  363. package/lib/module/roomStore/persistence.js.map +1 -1
  364. package/lib/module/roomStore/roomsSlice.js +139 -34
  365. package/lib/module/roomStore/roomsSlice.js.map +1 -1
  366. package/lib/module/services/pushSubscriptionService.js +15 -13
  367. package/lib/module/services/pushSubscriptionService.js.map +1 -1
  368. package/lib/module/version.js +1 -1
  369. package/lib/typescript/assets/icons.d.ts +16 -0
  370. package/lib/typescript/assets/icons.d.ts.map +1 -1
  371. package/lib/typescript/components/AuthForms/Login.d.ts.map +1 -1
  372. package/lib/typescript/components/Header/HeaderRoomList.d.ts.map +1 -1
  373. package/lib/typescript/components/MainComponents/ChatHeader.d.ts.map +1 -1
  374. package/lib/typescript/components/MainComponents/ChatRoom.d.ts.map +1 -1
  375. package/lib/typescript/components/MainComponents/ChatWrapper.d.ts.map +1 -1
  376. package/lib/typescript/components/MainComponents/LoginWrapper.d.ts.map +1 -1
  377. package/lib/typescript/components/MainComponents/MediaMessage.d.ts.map +1 -1
  378. package/lib/typescript/components/MainComponents/MessageContainer.d.ts.map +1 -1
  379. package/lib/typescript/components/MainComponents/MessageList.d.ts +10 -1
  380. package/lib/typescript/components/MainComponents/MessageList.d.ts.map +1 -1
  381. package/lib/typescript/components/MainComponents/ProfileImagePlaceholder.d.ts.map +1 -1
  382. package/lib/typescript/components/MainComponents/RoomList.d.ts +7 -0
  383. package/lib/typescript/components/MainComponents/RoomList.d.ts.map +1 -1
  384. package/lib/typescript/components/Menu/HeaderRoomListMenu.d.ts +3 -0
  385. package/lib/typescript/components/Menu/HeaderRoomListMenu.d.ts.map +1 -1
  386. package/lib/typescript/components/Modals/AttachSheet/AttachSheet.d.ts +9 -0
  387. package/lib/typescript/components/Modals/AttachSheet/AttachSheet.d.ts.map +1 -1
  388. package/lib/typescript/components/Modals/ChatProfileModal/ChatProfileModal.d.ts +10 -0
  389. package/lib/typescript/components/Modals/ChatProfileModal/ChatProfileModal.d.ts.map +1 -1
  390. package/lib/typescript/components/Modals/ChatProfileModal/ReportChatModal.d.ts +9 -0
  391. package/lib/typescript/components/Modals/ChatProfileModal/ReportChatModal.d.ts.map +1 -0
  392. package/lib/typescript/components/Modals/FilePreviewModal/FilePreviewModal.d.ts.map +1 -1
  393. package/lib/typescript/components/Modals/FilePreviewModal/PdfView.d.ts.map +1 -1
  394. package/lib/typescript/components/Modals/Modal/Modal.d.ts.map +1 -1
  395. package/lib/typescript/components/Modals/NewChatModal/ModalContent.d.ts +4 -2
  396. package/lib/typescript/components/Modals/NewChatModal/ModalContent.d.ts.map +1 -1
  397. package/lib/typescript/components/Modals/NewChatModal/NewChatModal.d.ts +1 -1
  398. package/lib/typescript/components/Modals/NewChatModal/NewChatModal.d.ts.map +1 -1
  399. package/lib/typescript/components/Modals/NewChatModal/UpdNewChatModal.d.ts.map +1 -1
  400. package/lib/typescript/components/Modals/ProfileHeader/ProfileHeader.d.ts +75 -0
  401. package/lib/typescript/components/Modals/ProfileHeader/ProfileHeader.d.ts.map +1 -0
  402. package/lib/typescript/components/Modals/ProfileHeader/ProfileMenu.d.ts +25 -0
  403. package/lib/typescript/components/Modals/ProfileHeader/ProfileMenu.d.ts.map +1 -0
  404. package/lib/typescript/components/Modals/SelectUsersModal/SelectUsersModal.d.ts +6 -1
  405. package/lib/typescript/components/Modals/SelectUsersModal/SelectUsersModal.d.ts.map +1 -1
  406. package/lib/typescript/components/Modals/UserProfileModal/EditUserModal.d.ts.map +1 -1
  407. package/lib/typescript/components/Modals/UserProfileModal/UserProfileModal.d.ts +16 -0
  408. package/lib/typescript/components/Modals/UserProfileModal/UserProfileModal.d.ts.map +1 -1
  409. package/lib/typescript/components/Modals/UserSettingsModal/UserSettingsModal.d.ts +1 -0
  410. package/lib/typescript/components/Modals/UserSettingsModal/UserSettingsModal.d.ts.map +1 -1
  411. package/lib/typescript/components/Modals/styledModalComponents.d.ts.map +1 -1
  412. package/lib/typescript/components/RoomComponents/ChatRoomItem.d.ts.map +1 -1
  413. package/lib/typescript/components/RoomComponents/styled/LastMessageFile.d.ts +1 -1
  414. package/lib/typescript/components/RoomComponents/styled/LastMessageFile.d.ts.map +1 -1
  415. package/lib/typescript/components/RoomComponents/styled/LastMessagePhoto.d.ts +1 -1
  416. package/lib/typescript/components/RoomComponents/styled/LastMessagePhoto.d.ts.map +1 -1
  417. package/lib/typescript/components/RoomComponents/styled/LastMessageVideo.d.ts +1 -1
  418. package/lib/typescript/components/RoomComponents/styled/LastMessageVideo.d.ts.map +1 -1
  419. package/lib/typescript/components/VideoCalls/VideoCallSession.d.ts.map +1 -1
  420. package/lib/typescript/components/styled/AudioMessage.d.ts.map +1 -1
  421. package/lib/typescript/components/styled/MessageImage.d.ts +14 -0
  422. package/lib/typescript/components/styled/MessageImage.d.ts.map +1 -1
  423. package/lib/typescript/components/styled/SendInput.d.ts.map +1 -1
  424. package/lib/typescript/components/styled/StyledComponents.d.ts.map +1 -1
  425. package/lib/typescript/components/styled/StyledInputComponents/StyledInputComponents.d.ts.map +1 -1
  426. package/lib/typescript/components/styled/UnsupportedType.d.ts.map +1 -1
  427. package/lib/typescript/components/styled/VideoMessage.d.ts +8 -0
  428. package/lib/typescript/components/styled/VideoMessage.d.ts.map +1 -1
  429. package/lib/typescript/context/xmppProvider.d.ts.map +1 -1
  430. package/lib/typescript/helpers/createMessageFromXml.d.ts.map +1 -1
  431. package/lib/typescript/helpers/getChatBackground.d.ts +15 -0
  432. package/lib/typescript/helpers/getChatBackground.d.ts.map +1 -0
  433. package/lib/typescript/helpers/getDisplayFileName.d.ts +49 -0
  434. package/lib/typescript/helpers/getDisplayFileName.d.ts.map +1 -0
  435. package/lib/typescript/helpers/getServerReadTimestamp.d.ts +108 -0
  436. package/lib/typescript/helpers/getServerReadTimestamp.d.ts.map +1 -0
  437. package/lib/typescript/helpers/historyPreloadScheduler.d.ts.map +1 -1
  438. package/lib/typescript/helpers/initXmppRooms.d.ts.map +1 -1
  439. package/lib/typescript/helpers/insertMessageWithDelimiter.d.ts +1 -1
  440. package/lib/typescript/helpers/insertMessageWithDelimiter.d.ts.map +1 -1
  441. package/lib/typescript/helpers/isOwnMessage.d.ts +36 -0
  442. package/lib/typescript/helpers/isOwnMessage.d.ts.map +1 -0
  443. package/lib/typescript/helpers/keyboardLayout.d.ts +5 -1
  444. package/lib/typescript/helpers/keyboardLayout.d.ts.map +1 -1
  445. package/lib/typescript/helpers/mediaLibraryRuntime.d.ts +3 -0
  446. package/lib/typescript/helpers/mediaLibraryRuntime.d.ts.map +1 -0
  447. package/lib/typescript/helpers/mimeToExtension.d.ts +0 -15
  448. package/lib/typescript/helpers/mimeToExtension.d.ts.map +1 -1
  449. package/lib/typescript/helpers/msgSortableMs.d.ts +2 -0
  450. package/lib/typescript/helpers/msgSortableMs.d.ts.map +1 -0
  451. package/lib/typescript/helpers/persistCrypto.d.ts +13 -0
  452. package/lib/typescript/helpers/persistCrypto.d.ts.map +1 -0
  453. package/lib/typescript/helpers/pickImageAsset.d.ts +27 -0
  454. package/lib/typescript/helpers/pickImageAsset.d.ts.map +1 -0
  455. package/lib/typescript/helpers/pushPayload.d.ts +7 -0
  456. package/lib/typescript/helpers/pushPayload.d.ts.map +1 -0
  457. package/lib/typescript/helpers/resolveInitBeforeLoadUser.d.ts.map +1 -1
  458. package/lib/typescript/helpers/secureFileUrl.d.ts +7 -0
  459. package/lib/typescript/helpers/secureFileUrl.d.ts.map +1 -0
  460. package/lib/typescript/helpers/secureKeyValue.d.ts +13 -0
  461. package/lib/typescript/helpers/secureKeyValue.d.ts.map +1 -0
  462. package/lib/typescript/helpers/secureStoreRuntime.d.ts +29 -0
  463. package/lib/typescript/helpers/secureStoreRuntime.d.ts.map +1 -0
  464. package/lib/typescript/helpers/secureUserStorage.d.ts +23 -0
  465. package/lib/typescript/helpers/secureUserStorage.d.ts.map +1 -0
  466. package/lib/typescript/helpers/shallowEqual.d.ts +11 -0
  467. package/lib/typescript/helpers/shallowEqual.d.ts.map +1 -0
  468. package/lib/typescript/helpers/sheetGestures.d.ts +20 -0
  469. package/lib/typescript/helpers/sheetGestures.d.ts.map +1 -0
  470. package/lib/typescript/hooks/useChatRoomFocus.d.ts +4 -1
  471. package/lib/typescript/hooks/useChatRoomFocus.d.ts.map +1 -1
  472. package/lib/typescript/hooks/useChatWrapperInit.d.ts.map +1 -1
  473. package/lib/typescript/hooks/useComposing.d.ts.map +1 -1
  474. package/lib/typescript/hooks/useFileToken.d.ts +2 -0
  475. package/lib/typescript/hooks/useFileToken.d.ts.map +1 -0
  476. package/lib/typescript/hooks/useLogout.d.ts.map +1 -1
  477. package/lib/typescript/hooks/usePendingNotification.d.ts.map +1 -1
  478. package/lib/typescript/hooks/useSendMessage.d.ts.map +1 -1
  479. package/lib/typescript/hooks/useUnreadMessagesCounter.d.ts +1 -0
  480. package/lib/typescript/hooks/useUnreadMessagesCounter.d.ts.map +1 -1
  481. package/lib/typescript/i18n/strings.d.ts.map +1 -1
  482. package/lib/typescript/main.d.ts +9 -2
  483. package/lib/typescript/main.d.ts.map +1 -1
  484. package/lib/typescript/networking/api-requests/auth.api.d.ts +3 -1
  485. package/lib/typescript/networking/api-requests/auth.api.d.ts.map +1 -1
  486. package/lib/typescript/networking/api-requests/user.api.d.ts +27 -0
  487. package/lib/typescript/networking/api-requests/user.api.d.ts.map +1 -1
  488. package/lib/typescript/networking/apiClient.d.ts +12 -6
  489. package/lib/typescript/networking/apiClient.d.ts.map +1 -1
  490. package/lib/typescript/networking/authRefresh.d.ts +95 -0
  491. package/lib/typescript/networking/authRefresh.d.ts.map +1 -0
  492. package/lib/typescript/networking/stanzaHandlers.d.ts.map +1 -1
  493. package/lib/typescript/networking/xmpp/flushLastViewedToPrivateStore.d.ts +10 -2
  494. package/lib/typescript/networking/xmpp/flushLastViewedToPrivateStore.d.ts.map +1 -1
  495. package/lib/typescript/networking/xmpp/presenceInRoom.xmpp.d.ts.map +1 -1
  496. package/lib/typescript/networking/xmpp/subscribeToRoomMessages.xmpp.d.ts.map +1 -1
  497. package/lib/typescript/networking/xmppClient.d.ts +14 -0
  498. package/lib/typescript/networking/xmppClient.d.ts.map +1 -1
  499. package/lib/typescript/roomStore/chatSettingsSlice.d.ts +16 -0
  500. package/lib/typescript/roomStore/chatSettingsSlice.d.ts.map +1 -1
  501. package/lib/typescript/roomStore/index.d.ts.map +1 -1
  502. package/lib/typescript/roomStore/persistence.d.ts +18 -1
  503. package/lib/typescript/roomStore/persistence.d.ts.map +1 -1
  504. package/lib/typescript/roomStore/roomsSlice.d.ts +43 -3
  505. package/lib/typescript/roomStore/roomsSlice.d.ts.map +1 -1
  506. package/lib/typescript/services/pushSubscriptionService.d.ts +1 -1
  507. package/lib/typescript/services/pushSubscriptionService.d.ts.map +1 -1
  508. package/lib/typescript/types/types.d.ts +50 -5
  509. package/lib/typescript/types/types.d.ts.map +1 -1
  510. package/lib/typescript/version.d.ts +1 -1
  511. package/package.json +41 -28
  512. package/src/assets/icons.tsx +48 -9
  513. package/src/components/AuthForms/Login.tsx +3 -3
  514. package/src/components/Header/HeaderRoomList.tsx +29 -7
  515. package/src/components/MainComponents/ChatHeader.tsx +9 -3
  516. package/src/components/MainComponents/ChatRoom.tsx +161 -15
  517. package/src/components/MainComponents/ChatWrapper.tsx +36 -20
  518. package/src/components/MainComponents/LoginWrapper.tsx +1 -0
  519. package/src/components/MainComponents/MediaMessage.tsx +26 -8
  520. package/src/components/MainComponents/MessageContainer.tsx +5 -1
  521. package/src/components/MainComponents/MessageList.tsx +23 -4
  522. package/src/components/MainComponents/ProfileImagePlaceholder.tsx +21 -14
  523. package/src/components/MainComponents/RoomList.tsx +236 -39
  524. package/src/components/Menu/HeaderRoomListMenu.tsx +328 -75
  525. package/src/components/Modals/AttachSheet/AttachSheet.tsx +333 -97
  526. package/src/components/Modals/ChatProfileModal/ChatProfileModal.tsx +600 -282
  527. package/src/components/Modals/ChatProfileModal/ReportChatModal.tsx +244 -0
  528. package/src/components/Modals/FilePreviewModal/FilePreviewModal.tsx +79 -38
  529. package/src/components/Modals/FilePreviewModal/PdfView.tsx +2 -1
  530. package/src/components/Modals/Modal/Modal.tsx +7 -0
  531. package/src/components/Modals/NewChatModal/ModalContent.tsx +6 -3
  532. package/src/components/Modals/NewChatModal/NewChatModal.tsx +219 -119
  533. package/src/components/Modals/NewChatModal/UpdNewChatModal.tsx +12 -1
  534. package/src/components/Modals/ProfileHeader/ProfileHeader.tsx +624 -0
  535. package/src/components/Modals/ProfileHeader/ProfileMenu.tsx +217 -0
  536. package/src/components/Modals/SelectUsersModal/SelectUsersModal.tsx +14 -4
  537. package/src/components/Modals/UserProfileModal/EditUserModal.tsx +9 -25
  538. package/src/components/Modals/UserProfileModal/UserProfileModal.tsx +617 -307
  539. package/src/components/Modals/UserSettingsModal/UserSettingsModal.tsx +75 -58
  540. package/src/components/Modals/styledModalComponents.tsx +9 -2
  541. package/src/components/RoomComponents/ChatRoomItem.tsx +18 -3
  542. package/src/components/RoomComponents/styled/LastMessageFile.tsx +28 -4
  543. package/src/components/RoomComponents/styled/LastMessagePhoto.tsx +18 -3
  544. package/src/components/RoomComponents/styled/LastMessageVideo.tsx +18 -3
  545. package/src/components/VideoCalls/VideoCallSession.tsx +8 -3
  546. package/src/components/styled/AudioMessage.tsx +2 -1
  547. package/src/components/styled/MessageImage.tsx +53 -7
  548. package/src/components/styled/SendInput.tsx +83 -12
  549. package/src/components/styled/StyledComponents.ts +9 -3
  550. package/src/components/styled/StyledInputComponents/StyledInputComponents.tsx +11 -4
  551. package/src/components/styled/UnsupportedType.tsx +14 -4
  552. package/src/components/styled/VideoMessage.tsx +131 -54
  553. package/src/context/xmppProvider.tsx +216 -57
  554. package/src/helpers/createMessageFromXml.ts +20 -1
  555. package/src/helpers/ensureScopedChatCache.ts +2 -2
  556. package/src/helpers/getChatBackground.ts +18 -0
  557. package/src/helpers/getDisplayFileName.ts +87 -0
  558. package/src/helpers/getServerReadTimestamp.ts +197 -0
  559. package/src/helpers/historyPreloadScheduler.ts +80 -3
  560. package/src/helpers/initXmppRooms.tsx +14 -10
  561. package/src/helpers/insertMessageWithDelimiter.ts +55 -19
  562. package/src/helpers/isOwnMessage.ts +90 -0
  563. package/src/helpers/keyboardLayout.ts +23 -2
  564. package/src/helpers/mediaLibraryRuntime.ts +25 -0
  565. package/src/helpers/mimeToExtension.ts +6 -22
  566. package/src/helpers/msgSortableMs.ts +25 -0
  567. package/src/helpers/persistCrypto.ts +127 -0
  568. package/src/helpers/pickImageAsset.ts +68 -0
  569. package/src/helpers/pushPayload.ts +62 -0
  570. package/src/helpers/resolveInitBeforeLoadUser.ts +125 -18
  571. package/src/helpers/secureFileUrl.ts +103 -0
  572. package/src/helpers/secureKeyValue.ts +80 -0
  573. package/src/helpers/secureStoreRuntime.ts +62 -0
  574. package/src/helpers/secureUserStorage.ts +80 -0
  575. package/src/helpers/shallowEqual.ts +33 -0
  576. package/src/helpers/sheetGestures.ts +25 -0
  577. package/src/hooks/useChatRoomFocus.ts +49 -9
  578. package/src/hooks/useChatWrapperInit.ts +30 -10
  579. package/src/hooks/useComposing.tsx +37 -1
  580. package/src/hooks/useFileToken.ts +7 -0
  581. package/src/hooks/useLogout.tsx +29 -9
  582. package/src/hooks/usePendingNotification.ts +5 -11
  583. package/src/hooks/useSendMessage.tsx +60 -15
  584. package/src/hooks/useUnreadMessagesCounter.ts +11 -0
  585. package/src/i18n/strings.ts +145 -37
  586. package/src/main.ts +26 -2
  587. package/src/networking/api-requests/auth.api.ts +156 -48
  588. package/src/networking/api-requests/roomMembers.api.ts +1 -1
  589. package/src/networking/api-requests/rooms.api.ts +9 -9
  590. package/src/networking/api-requests/user.api.ts +79 -7
  591. package/src/networking/apiClient.ts +68 -123
  592. package/src/networking/authRefresh.ts +451 -0
  593. package/src/networking/stanzaHandlers.ts +44 -28
  594. package/src/networking/xmpp/flushLastViewedToPrivateStore.ts +71 -10
  595. package/src/networking/xmpp/presenceInRoom.xmpp.ts +6 -1
  596. package/src/networking/xmpp/subscribeToRoomMessages.xmpp.ts +12 -1
  597. package/src/networking/xmppClient.ts +141 -9
  598. package/src/roomStore/chatSettingsSlice.ts +34 -10
  599. package/src/roomStore/index.ts +40 -4
  600. package/src/roomStore/persistence.ts +234 -24
  601. package/src/roomStore/roomsSlice.ts +161 -29
  602. package/src/services/pushSubscriptionService.ts +18 -13
  603. package/src/types/types.ts +72 -5
  604. package/src/version.ts +1 -1
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getChatBackgroundColor = exports.DEFAULT_CHAT_BACKGROUND = void 0;
7
+ /** @format */
8
+
9
+ /** Ground behind the conversation, and behind the rounded corners of the
10
+ * header and the composer that sit over it. */
11
+ const DEFAULT_CHAT_BACKGROUND = exports.DEFAULT_CHAT_BACKGROUND = '#F3F6FC';
12
+
13
+ /**
14
+ * One place for the conversation's background colour.
15
+ *
16
+ * The message list has always painted it; the chat container behind it was
17
+ * plain white, which is what made the header's rounded bottom corners and
18
+ * the composer's rounded top corners invisible — the corners revealed the
19
+ * white parent, not the conversation.
20
+ */
21
+ const getChatBackgroundColor = config => config?.backgroundChat?.color || DEFAULT_CHAT_BACKGROUND;
22
+ exports.getChatBackgroundColor = getChatBackgroundColor;
23
+ //# sourceMappingURL=getChatBackground.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["DEFAULT_CHAT_BACKGROUND","exports","getChatBackgroundColor","config","backgroundChat","color"],"sourceRoot":"../../../src","sources":["helpers/getChatBackground.ts"],"mappings":";;;;;;AAAA;;AAIA;AACA;AACO,MAAMA,uBAAuB,GAAAC,OAAA,CAAAD,uBAAA,GAAG,SAAS;;AAEhD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAME,sBAAsB,GAAIC,MAAgB,IACrDA,MAAM,EAAEC,cAAc,EAAEC,KAAK,IAAIL,uBAAuB;AAACC,OAAA,CAAAC,sBAAA,GAAAA,sBAAA","ignoreList":[]}
@@ -0,0 +1,79 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getDisplayFileName = getDisplayFileName;
7
+ exports.getUniqueFileName = getUniqueFileName;
8
+ exports.sanitizeFileNameForPath = sanitizeFileNameForPath;
9
+ var _mimeToExtension = require("./mimeToExtension");
10
+ /**
11
+ * Picks the best human-readable filename for a chat attachment - the
12
+ * single source of truth for every place a file name is rendered in the
13
+ * UI, saved to disk, shared, or downloaded.
14
+ *
15
+ * Priority: `originalName` (the sender's own file name, e.g. "test1.pdf")
16
+ * beats `fileName` (the server's stored/hashed name, e.g.
17
+ * "3f9a1c...c2.pdf") beats the last path segment of `location`. The
18
+ * stored hash name is only a fallback of last resort.
19
+ *
20
+ * Bug #40: display and save/share/download logic used to prefer the
21
+ * stored hash name over the original one, so an attachment sent as
22
+ * "test1.pdf" showed up (and got saved to the phone) as something like
23
+ * "3f9a1c...c2.pdf" - both directions (web -> RN and RN -> RN).
24
+ *
25
+ * Always returns a non-empty string with a valid extension: if the
26
+ * chosen candidate has no extension (a hash name can be `<hex>` with no
27
+ * extension at all, or `<hex>.<ext>`), one is appended from `mimetype`
28
+ * (or `.bin` as a last resort when the mime is unknown/missing too).
29
+ */
30
+ function getDisplayFileName(options) {
31
+ const candidate = options.originalName && options.originalName.trim() || options.fileName && options.fileName.trim() || (0, _mimeToExtension.filenameFromUrl)(options.location) || '';
32
+ return (0, _mimeToExtension.ensureFilenameHasExtension)(candidate, options.mimetype);
33
+ }
34
+
35
+ /**
36
+ * Makes a display name safe to use as an actual path segment when
37
+ * saving/sharing a file to the device: strips path separators (so an
38
+ * odd/hostile server-provided name can't escape the target directory)
39
+ * and control characters. Keeps the rest of the name - including the
40
+ * extension - intact.
41
+ */
42
+ function sanitizeFileNameForPath(name) {
43
+ const cleaned = (name || '').replace(/[\/\\]/g, '_')
44
+ // eslint-disable-next-line no-control-regex
45
+ .replace(/[\x00-\x1f\x7f]/g, '').trim();
46
+ return cleaned || 'file';
47
+ }
48
+
49
+ /**
50
+ * Resolves a filename that is safe to write into a target directory:
51
+ * sanitizes it, then - if `exists` reports a collision - inserts
52
+ * " (1)", " (2)", ... before the extension until a free name is found,
53
+ * so saving two different attachments that share a display name never
54
+ * silently overwrites the first one.
55
+ *
56
+ * `exists` is injected so callers can back it with whatever existence
57
+ * check makes sense for their storage API (expo-file-system,
58
+ * StorageAccessFramework directory listing, ...) - this function stays
59
+ * pure and easy to unit test.
60
+ */
61
+ async function getUniqueFileName(name, exists) {
62
+ const safeName = sanitizeFileNameForPath(name);
63
+ if (!(await exists(safeName))) {
64
+ return safeName;
65
+ }
66
+ const dotIndex = safeName.lastIndexOf('.');
67
+ const base = dotIndex > 0 ? safeName.slice(0, dotIndex) : safeName;
68
+ const ext = dotIndex > 0 ? safeName.slice(dotIndex) : '';
69
+ // 999 collisions is already a pathological case; fall back to a
70
+ // timestamp suffix rather than looping forever.
71
+ for (let i = 1; i < 1000; i += 1) {
72
+ const candidate = `${base} (${i})${ext}`;
73
+ if (!(await exists(candidate))) {
74
+ return candidate;
75
+ }
76
+ }
77
+ return `${base} (${Date.now()})${ext}`;
78
+ }
79
+ //# sourceMappingURL=getDisplayFileName.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_mimeToExtension","require","getDisplayFileName","options","candidate","originalName","trim","fileName","filenameFromUrl","location","ensureFilenameHasExtension","mimetype","sanitizeFileNameForPath","name","cleaned","replace","getUniqueFileName","exists","safeName","dotIndex","lastIndexOf","base","slice","ext","i","Date","now"],"sourceRoot":"../../../src","sources":["helpers/getDisplayFileName.ts"],"mappings":";;;;;;;;AAAA,IAAAA,gBAAA,GAAAC,OAAA;AASA;AACA;AACA;AACA;AACA;AACA;AAC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,CAAC,GAAG,EAAE;EACxD;EACA;EACA,KAAK,IAAIK,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAG,IAAI,EAAEA,CAAC,IAAI,CAAC,EAAE;IAChC,MAAMpB,SAAS,GAAG,GAAGiB,IAAI,KAAKG,CAAC,IAAID,GAAG,EAAE;IACxC,IAAI,EAAE,MAAMN,MAAM,CAACb,SAAS,CAAC,CAAC,EAAE;MAC9B,OAAOA,SAAS;IAClB;EACF;EACA,OAAO,GAAGiB,IAAI,KAAKI,IAAI,CAACC,GAAG,CAAC,CAAC,IAAIH,GAAG,EAAE;AACxC","ignoreList":[]}
@@ -0,0 +1,188 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.FUTURE_READ_MARKER_TOLERANCE_MS = void 0;
7
+ exports.getFlushBoundaryTs = getFlushBoundaryTs;
8
+ exports.getReadMarkerTimestamp = getReadMarkerTimestamp;
9
+ exports.getServerReadTimestamp = getServerReadTimestamp;
10
+ exports.isCorruptFutureReadMarker = isCorruptFutureReadMarker;
11
+ var _msgSortableMs = require("./msgSortableMs");
12
+ // A stored/stamped read marker more than this far past the newest
13
+ // message we actually know about for a room is not "the user is a
14
+ // little ahead" - it's a leftover from a device whose clock was wrong
15
+ // when it stamped the marker (bug #38). Generous on purpose: this value
16
+ // only controls when we're willing to treat an existing marker as
17
+ // corrupt and self-heal it, never how far off a legitimate new write can
18
+ // be, so a false positive here just means a bad value survives one extra
19
+ // cycle, not that a good value gets rejected.
20
+ const FUTURE_READ_MARKER_TOLERANCE_MS = exports.FUTURE_READ_MARKER_TOLERANCE_MS = 5 * 60 * 1000;
21
+ /**
22
+ * Resolve the "read up to here" marker for `room` using SERVER time,
23
+ * never the device clock.
24
+ *
25
+ * Bug #38: if the device clock is ahead when the user leaves a room, a
26
+ * `Date.now()` read marker lands in the future. The private-store merge
27
+ * (flushLastViewedToPrivateStore.ts) is forward-only ("if (prevNum >=
28
+ * ts) continue"), so once a future marker is written, no later
29
+ * *correct* write can ever replace it - the room's unread count is
30
+ * stuck wrong forever, on every device, from that point on. Anchoring
31
+ * to the newest SERVER-acknowledged message's own timestamp instead
32
+ * means the marker we write can never be ahead of what the server
33
+ * itself has recorded for the room.
34
+ *
35
+ * "Server-acknowledged" excludes:
36
+ * - a message still marked `pending` (the optimistic bubble shown
37
+ * while a send is in flight - it carries the DEVICE send time via
38
+ * `date`, not a server timestamp, until the server echoes it back
39
+ * and insertMessageWithDelimiter flips `pending` off);
40
+ * - a message id present in `heapState.messageHeap` (queued retry -
41
+ * used for offline media sends, see roomHeapSlice.ts) or
42
+ * `heapState.failedMessages` (a send that never reached the server
43
+ * at all).
44
+ *
45
+ * `msgSortableMs` (helpers/msgSortableMs.ts) reads the server-assigned microsecond
46
+ * timestamp encoded in the first 13 digits of the message id - the same
47
+ * source already used for message ordering and unread counting - so
48
+ * this stays consistent with the rest of the read/unread pipeline.
49
+ *
50
+ * Falls back to the room's existing `lastViewedTimestamp` (so leaving
51
+ * an empty or never-scrolled room doesn't regress the marker), then to
52
+ * `0` when there's truly nothing to anchor to yet (a brand new room
53
+ * with no history and no prior marker). Callers should treat `0` as
54
+ * "skip the write" rather than substituting a device-clock guess.
55
+ */
56
+ function getServerReadTimestamp(room, heapState) {
57
+ if (!room) {
58
+ return 0;
59
+ }
60
+ const heapIds = new Set((heapState?.messageHeap || []).filter(m => m && m.id != null).map(m => String(m.id)));
61
+ const failedIds = new Set(Object.keys(heapState?.failedMessages || {}));
62
+ let newest = 0;
63
+ const messages = room.messages || [];
64
+ for (const m of messages) {
65
+ if (!m || !m.id) {
66
+ continue;
67
+ }
68
+ const id = String(m.id);
69
+ if (id === 'delimiter-new' || id === 'delimiter-new-local') {
70
+ continue;
71
+ }
72
+ if (m.pending) {
73
+ continue;
74
+ }
75
+ if (heapIds.has(id) || failedIds.has(id)) {
76
+ continue;
77
+ }
78
+ const ts = (0, _msgSortableMs.msgSortableMs)(m);
79
+ if (ts > newest) {
80
+ newest = ts;
81
+ }
82
+ }
83
+ if (newest > 0) {
84
+ return newest;
85
+ }
86
+ if (room.lastViewedTimestamp && room.lastViewedTimestamp > 0) {
87
+ return room.lastViewedTimestamp;
88
+ }
89
+ return 0;
90
+ }
91
+
92
+ /**
93
+ * Is `marker` a leftover from a device whose clock was wrong when it
94
+ * stamped a read marker (bug #38)?
95
+ *
96
+ * TWO independent signals must agree before we're willing to throw a
97
+ * stored marker away, because "waive the forward-only guard" is a
98
+ * destructive operation:
99
+ *
100
+ * 1. it sits well past the newest message we know the room has, AND
101
+ * 2. it sits well past real time.
102
+ *
103
+ * Signal 1 alone is NOT enough, and that is the whole point of this
104
+ * function: a device whose local cache for a room is simply stale (very
105
+ * common - any room whose history hasn't been synced yet this session)
106
+ * sees a perfectly legitimate marker written by another device that HAS
107
+ * seen newer messages, and would happily "heal" it backwards, resurrecting
108
+ * already-read messages as unread on every device. A real timestamp can
109
+ * never be ahead of real time, so requiring signal 2 as well means a
110
+ * stale cache on its own can no longer trigger the self-heal.
111
+ *
112
+ * Signal 2 alone is not used either: it would let a device whose own
113
+ * clock is running SLOW mistake every correct marker for a corrupt one.
114
+ */
115
+ function isCorruptFutureReadMarker(marker, newestAckedMs) {
116
+ if (!Number.isFinite(marker) || marker <= 0) {
117
+ return false;
118
+ }
119
+ if (!(newestAckedMs > 0)) {
120
+ return false;
121
+ }
122
+ if (marker <= newestAckedMs + FUTURE_READ_MARKER_TOLERANCE_MS) {
123
+ return false;
124
+ }
125
+ return marker > Date.now() + FUTURE_READ_MARKER_TOLERANCE_MS;
126
+ }
127
+
128
+ /**
129
+ * Resolve the marker to STAMP (locally and to the server) for `room`,
130
+ * honouring an explicit read boundary when one is set.
131
+ *
132
+ * Bug #42 (a regression of #33, reintroduced by #38): #38 made every
133
+ * caller stamp the newest server-acknowledged message unconditionally.
134
+ * That is correct for a user who is at the bottom of the room, but wrong
135
+ * for a user who scrolled up, received messages, and left without
136
+ * scrolling back down - stamping "newest" there silently marks
137
+ * messages they never saw as read, both locally and (because the
138
+ * private-store merge is forward-only) permanently on the server.
139
+ *
140
+ * `boundaryTs` is the msgSortableMs of the newest message the user
141
+ * actually reached (see `readBoundaries` on `RoomMessagesState`,
142
+ * populated by MessageList's `onReadBoundaryChange`). When it's set and
143
+ * positive, it wins - but is still clamped to never exceed the newest
144
+ * server-acknowledged message, so a stale/corrupt boundary can't stamp a
145
+ * marker further ahead than the room's own history supports. When no
146
+ * boundary is set (the common case - the user is at the bottom), this is
147
+ * exactly `getServerReadTimestamp`.
148
+ *
149
+ * Never returns `Date.now()`, directly or indirectly - same rule as
150
+ * `getServerReadTimestamp` (bug #38).
151
+ */
152
+ function getReadMarkerTimestamp(room, heapState, boundaryTs) {
153
+ const newestAcked = getServerReadTimestamp(room, heapState);
154
+ if (typeof boundaryTs === 'number' && Number.isFinite(boundaryTs) && boundaryTs > 0) {
155
+ // `newestAcked === 0` means this room has NOTHING server-acked and no
156
+ // prior marker, so there is nothing to clamp the boundary against -
157
+ // and MessageList derives the boundary from the rendered list, which
158
+ // at that point can only contain pending/failed sends carrying the
159
+ // DEVICE clock via `date`. Returning it here would smuggle a
160
+ // device-clock marker back in through the boundary (bug #38). Return
161
+ // 0 = "nothing to anchor to, skip the write", same contract as
162
+ // getServerReadTimestamp.
163
+ return newestAcked > 0 ? Math.min(boundaryTs, newestAcked) : 0;
164
+ }
165
+ return newestAcked;
166
+ }
167
+
168
+ /**
169
+ * The value to hand `flushLastViewedToPrivateStore` as `visibleRoomTs`
170
+ * for a room being left, or `undefined` when no boundary applies (the
171
+ * flush then uses its own newest-acked default).
172
+ *
173
+ * Exists so the SERVER write goes through the SAME clamp as the local
174
+ * stamp. Passing the raw redux boundary straight through would bypass
175
+ * `getReadMarkerTimestamp`'s clamp on exactly the path where a bad value
176
+ * is permanent: the private-store merge is forward-only, so a boundary
177
+ * that (through a pending own message's device `date`, or a stale
178
+ * readBoundaries entry) sat ahead of the room's real history would be
179
+ * written verbatim and could never be corrected again (bug #38).
180
+ */
181
+ function getFlushBoundaryTs(room, heapState, boundaryTs) {
182
+ if (typeof boundaryTs !== 'number' || !Number.isFinite(boundaryTs) || boundaryTs <= 0) {
183
+ return undefined;
184
+ }
185
+ const clamped = getReadMarkerTimestamp(room, heapState, boundaryTs);
186
+ return clamped > 0 ? clamped : undefined;
187
+ }
188
+ //# sourceMappingURL=getServerReadTimestamp.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_msgSortableMs","require","FUTURE_READ_MARKER_TOLERANCE_MS","exports","getServerReadTimestamp","room","heapState","heapIds","Set","messageHeap","filter","m","id","map","String","failedIds","Object","keys","failedMessages","newest","messages","pending","has","ts","msgSortableMs","lastViewedTimestamp","isCorruptFutureReadMarker","marker","newestAckedMs","Number","isFinite","Date","now","getReadMarkerTimestamp","boundaryTs","newestAcked","Math","min","getFlushBoundaryTs","undefined","clamped"],"sourceRoot":"../../../src","sources":["helpers/getServerReadTimestamp.ts"],"mappings":";;;;;;;;;;AACA,IAAAA,cAAA,GAAAC,OAAA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMC,+BAA+B,GAAAC,OAAA,CAAAD,+BAAA,GAAG,CAAC,GAAG,EAAE,GAAG,IAAI;AAS5D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASE,sBAAsBA,CACpCC,IAA6C,EAC7CC,SAAyC,EACjC;EACR,IAAI,CAACD,IAAI,EAAE;IAAC,OAAO,CAAC;EAAC;EAErB,MAAME,OAAO,GAAG,IAAIC,GAAG,CACrB,CAACF,SAAS,EAAEG,WAAW,IAAI,EAAE,EAC1BC,MAAM,CAAEC,CAAC,IAAKA,CAAC,IAAIA,CAAC,CAACC,EAAE,IAAI,IAAI,CAAC,CAChCC,GAAG,CAAEF,CAAC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AAO,GAAG,CAAC,GAAGA,OAAO,GAAGD,SAAS;AAC1C","ignoreList":[]}
@@ -13,6 +13,13 @@ const DEFAULT_CONCURRENCY = 3;
13
13
  // `mergeHistoryIntoCache` rarely has to fall back to clear-and-replace.
14
14
  const DEFAULT_PAGE_SIZE = 20;
15
15
  const DEFAULT_RETRY_LIMIT = 2;
16
+ // When the first page is entirely unread (every fetched message is newer
17
+ // than `lastViewedTimestamp`), the true unread count could be far bigger
18
+ // than `pageSize` — `useUnread()` only ever sees what's been loaded. Page
19
+ // further back, up to this many extra fetches, until we either find the
20
+ // boundary or give up (`unreadCapped` then stays true so callers at least
21
+ // know the count is a floor, not exact). Customer-reported #34.
22
+ const MAX_UNREAD_CATCHUP_PAGES = 8;
16
23
  const sleep = ms => new Promise(resolve => setTimeout(resolve, ms));
17
24
  const messageTimestamp = m => {
18
25
  if (!m) {
@@ -184,11 +191,67 @@ const runHistoryPreloadScheduler = async options => {
184
191
  throw new Error('history_timeout');
185
192
  }
186
193
  const nextRoom = _roomStore.store.getState().rooms.rooms[item.jid];
187
- const unreadCapped = computeUnreadCapped(nextRoom, fetchedMessages || [], pageSize);
194
+ let combined = fetchedMessages || [];
195
+ const lastViewed = Number(nextRoom?.lastViewedTimestamp) || 0;
196
+
197
+ // The first page was entirely unread — keep paging older until
198
+ // we find a message at/before `lastViewedTimestamp` (the true
199
+ // boundary) or run out of catch-up budget, so the count isn't
200
+ // silently truncated at `pageSize`.
201
+ if (lastViewed > 0 && computeUnreadCapped(nextRoom, combined, pageSize)) {
202
+ let lastPageLen = combined.length;
203
+ let extraPages = 0;
204
+ while (extraPages < MAX_UNREAD_CATCHUP_PAGES && lastPageLen >= pageSize && !signal?.aborted) {
205
+ const oldestId = combined.reduce((min, m) => {
206
+ const idNum = Number(m?.id);
207
+ if (!Number.isFinite(idNum)) {
208
+ return min;
209
+ }
210
+ return min === null || idNum < min ? idNum : min;
211
+ }, null);
212
+ if (oldestId === null) {
213
+ break;
214
+ }
215
+ let older;
216
+ try {
217
+ older = await client.getHistoryStanza(item.jid, pageSize, oldestId, undefined, {
218
+ coalesceRoom: true,
219
+ skipIfPreloaded: !forceReload,
220
+ source: 'background'
221
+ });
222
+ } catch {
223
+ break;
224
+ }
225
+ if (!older || !older.length) {
226
+ break;
227
+ }
228
+ combined = [...older, ...combined];
229
+ lastPageLen = older.length;
230
+ extraPages++;
231
+ const oldestTs = combined.reduce((minTs, m) => {
232
+ const ts = messageTimestamp(m);
233
+ return ts > 0 ? Math.min(minTs, ts) : minTs;
234
+ }, Number.MAX_SAFE_INTEGER);
235
+ if (oldestTs !== Number.MAX_SAFE_INTEGER && oldestTs <= lastViewed) {
236
+ break;
237
+ }
238
+ }
239
+ }
240
+
241
+ // `mergeHistoryIntoCache` (roomsSlice) caps whatever we dispatch
242
+ // here to the newest RUNTIME_MESSAGE_LIMIT messages before it
243
+ // ever reaches `unreadMiddleware` — so a catch-up fetch that
244
+ // pulled the true boundary can still have it silently dropped
245
+ // by that cap, leaving a falsely-confident `unreadCapped:false`
246
+ // (bug #34's failure mode again, just one layer downstream).
247
+ // Simulate that cap here so the flag reflects what will
248
+ // actually survive, not just what this fetch retrieved.
249
+ const simulatedStored = combined.length > _roomsSlice.RUNTIME_MESSAGE_LIMIT ? combined.slice(-_roomsSlice.RUNTIME_MESSAGE_LIMIT) : combined;
250
+ const unreadCapped = computeUnreadCapped(nextRoom, simulatedStored, pageSize);
188
251
  _roomStore.store.dispatch((0, _roomsSlice.applyRoomsPreloadBatch)({
189
252
  rooms: [{
190
253
  jid: item.jid,
191
- messages: fetchedMessages || [],
254
+ messages: combined,
192
255
  unreadCapped,
193
256
  historyPreloadState: 'done'
194
257
  }]
@@ -1 +1 @@
1
- {"version":3,"names":["_reactNative","require","_roomStore","_roomsSlice","DEFAULT_CONCURRENCY","DEFAULT_PAGE_SIZE","DEFAULT_RETRY_LIMIT","sleep","ms","Promise","resolve","setTimeout","messageTimestamp","m","t","timestamp","Number","isFinite","id","getRoomLastActivityScore","room","messages","length","reduce","max","Math","computeUnreadCapped","pageSize","historyComplete","countable","filter","msg","pending","lastViewed","lastViewedTimestamp","oldestTs","minTs","ts","min","MAX_SAFE_INTEGER","getRoomPriority","jid","_room","selectedRoomJid","defaultRoomJids","has","shouldPauseForVisibility","AppState","currentState","runHistoryPreloadScheduler","options","client","signal","concurrency","retryLimit","roomLimit","forceReload","aborted","store","dispatch","setUnreadSyncing","state","getState","rooms","defaultSet","Set","sortedQueue","Object","entries","map","priority","activityScore","attempts","readyAt","Date","now","sort","a","b","localeCompare","queue","slice","inFlightByRoom","Map","consecutiveErrorCount","isActiveRoomGateOpen","readyItems","item","batch","preBatchPreloadStateByJid","historyPreloadState","applyRoomsPreloadBatch","all","queueIndex","findIndex","queued","splice","task","currentRoom","preState","get","fetchedMessages","getHistoryStanza","undefined","coalesceRoom","skipIfPreloaded","source","Error","nextRoom","unreadCapped","retries","canRetry","jitter","floor","random","backoff","push","set","finally","delete","r","exports","_default","default"],"sourceRoot":"../../../src","sources":["helpers/historyPreloadScheduler.ts"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAEA,IAAAC,UAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AAuBA,MAAMG,mBAAmB,GAAG,CAAC;AAC7B;AACA;AACA;AACA,MAAMC,iBAAiB,GAAG,EAAE;AAC5B,MAAMC,mBAAmB,GAAG,CAAC;AAE7B,MAAMC,KAAK,GAAIC,EAAU,IAAK,IAAIC,OAAO,CAAEC,OAAO,IAAKC,UAAU,CAACD,OAAO,EAAEF,EAAE,CAAC,CAAC;AAE/E,MAAMI,gBAAgB,GAAIC,CAAW,IAAa;EAChD,IAAI,CAACA,CAAC,EAAE;IAAC,OAAO,CAAC;EAAC;EAClB,MAAMC,CAAC,GAAID,CAAC,CAASE,SAAS;EAC9B,IAAIC,MAAM,CAACC,QAAQ,CAACH,CAAC,CAAC,IAAIA,CAAC,GAAG,CAAC,EAAE;IAAC,OAAOE,MA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B,GAAG,EAAE8C,IAAI,CAAC9C,GAAG;kBAAEiD,mBAAmB,EAAE;gBAAQ,CAAC;cACzD,CAAC,CACH,CAAC;YACH;YACAN,qBAAqB,IAAI,CAAC;YAC1B,IAAIA,qBAAqB,IAAI,CAAC,EAAE;cAC9B,MAAM7E,KAAK,CAAC,GAAG,CAAC;cAChB6E,qBAAqB,GAAG,CAAC;YAC3B;UACF;QACF,CAAC,EAAE,CAAC;QAEJF,cAAc,CAACmC,GAAG,CAAC9B,IAAI,CAAC9C,GAAG,EAAEwD,IAAI,CAAC;QAClC,MAAMA,IAAI,CAACqB,OAAO,CAAC,MAAMpC,cAAc,CAACqC,MAAM,CAAChC,IAAI,CAAC9C,GAAG,CAAC,CAAC;MAC3D,CAAC,CACH,CAAC;;MAED;MACA,MAAM,IAAIhC,OAAO,CAAE+G,CAAC,IAAK7G,UAAU,CAAC6G,CAAC,EAAE,CAAC,CAAC,CAAC;IAC5C;EACA,CAAC,SAAS;IACR9D,gBAAK,CAACC,QAAQ,CAAC,IAAAC,4BAAgB,EAAC,KAAK,CAAC,CAAC;EACzC;AACF,CAAC;AAAC6D,OAAA,CAAAxE,0BAAA,GAAAA,0BAAA;AAAA,IAAAyE,QAAA,GAAAD,OAAA,CAAAE,OAAA,GAEa1E,0BAA0B","ignoreList":[]}
1
+ {"version":3,"names":["_reactNative","require","_roomStore","_roomsSlice","DEFAULT_CONCURRENCY","DEFAULT_PAGE_SIZE","DEFAULT_RETRY_LIMIT","MAX_UNREAD_CATCHUP_PAGES","sleep","ms","Promise","resolve","setTimeout","messageTimestamp","m","t","timestamp","Number","isFinite","id","getRoomLastActivityScore","room","messages","length","reduce","max","Math","computeUnreadCapped","pageSize","historyComplete","countable","filter","msg","pending","lastViewed","lastViewedTimestamp","oldestTs","minTs","ts","min","MAX_SAFE_INTEGER","getRoomPriority","jid","_room","selectedRoomJid","defaultRoomJids","has","shouldPauseForVisibility","AppState","currentState","runHistoryPreloadScheduler","options","client","signal","concurrency","retryLimit","roomLimit","forceReload","aborted","store","dispatch","setUnreadSyncing","state","getState","rooms","defaultSet","Set","sortedQueue","Object","entries","map","priority","activityScore","attempts","readyAt","Date","now","sort","a","b","localeCompare","queue","slice","inFlightByRoom","Map","consecutiveErrorCount","isActiveRoomGateOpen","readyItems","item","batch","preBatchPreloadStateByJid","historyPreloadState","applyRoomsPreloadBatch","all","queueIndex","findIndex","queued","splice","task","currentRoom","preState","get","fetchedMessages","getHistoryStanza","undefined","coalesceRoom","skipIfPreloaded","source","Error","nextRoom","combined","lastPageLen","extraPages","oldestId","idNum","older","simulatedStored","RUNTIME_MESSAGE_LIMIT","unreadCapped","retries","canRetry","jitter","floor","random","backoff","push","set","finally","delete","r","exports","_default","default"],"sourceRoot":"../../../src","sources":["helpers/historyPreloadScheduler.ts"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAEA,IAAAC,UAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AA2BA,MAAMG,mBAAmB,GAAG,CAAC;AAC7B;AACA;AACA;AACA,MAAMC,iBAAiB,GAAG,EAAE;AAC5B,MAAMC,mBAAmB,GAAG,CAAC;AAC7B;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,wBAAwB,GAAG,CAAC;AAElC,MAAMC,KAAK,GAAIC,EAAU,IAAK,IAAIC,OAAO,CAAEC,OAAO,IAAKC,UAAU,CAACD,OAAO,EAAEF,EAAE,CAAC,CAAC;AAE/E,MAAMI,gBAAgB,GAAIC,CAAW,IAAa;EAChD,IAAI,CAACA,CAAC,EAAE;IAAC,OAAO,CAAC;EAAC;EAClB,MAAMC,CAAC,GAAID,CAAC,CAASE,SAAS;EAC9B,IAAIC,MAAM,CAACC,QAAQ,CAACH,CAAC,CAAC,IAAIA,CAAC,GAAG,CAAC,EAAE;IAAC,OAAOE,MAAM,CAACF,CAAC,CAAC;EAAC;EACnD,MAAMI,EAAE,GAAGF,MAAM,CAACH,CAAC,CAACK,EAAE,CAAC;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CAACC,QAAQ,CAAC,IAAAC,4BAAgB,EAAC,KAAK,CAAC,CAAC;EACzC;AACF,CAAC;AAACqE,OAAA,CAAAhF,0BAAA,GAAAA,0BAAA;AAAA,IAAAiF,QAAA,GAAAD,OAAA,CAAAE,OAAA,GAEalF,0BAA0B","ignoreList":[]}
@@ -5,9 +5,9 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
  var _roomsSlice = require("../roomStore/roomsSlice");
8
- var _updatedChatLastTimestamps = require("./updatedChatLastTimestamps");
9
8
  var _initRoomsPresence = require("./initRoomsPresence");
10
9
  var _roomStore = require("../roomStore");
10
+ var _authRefresh = require("../networking/authRefresh");
11
11
  const initXmppRooms = async (user, config, xmmpClient, rooms, roomJID) => {
12
12
  if (roomJID) {
13
13
  _roomStore.store.dispatch((0, _roomsSlice.setCurrentRoom)({
@@ -43,16 +43,22 @@ const initXmppRooms = async (user, config, xmmpClient, rooms, roomJID) => {
43
43
  console.log(res);
44
44
  }
45
45
 
46
- //@ts-ignore
47
- const roomTimestampObject = await xmmpClient.getChatsPrivateStoreRequestStanza();
48
- (0, _updatedChatLastTimestamps.updatedChatLastTimestamps)(roomTimestampObject, _roomStore.store.dispatch);
46
+ // getChatsPrivateStoreRequestStanza hydrates redux itself
47
+ // (dispatch(applyPrivateStoreMarkers(...)) internally, clamped +
48
+ // forward-only) - do not also apply the raw return value here. That
49
+ // used to double-dispatch via updatedChatLastTimestamps' unconditional
50
+ // setLastViewedTimestamp, which has neither the forward-only guard
51
+ // nor the future-marker clamp, so it could silently re-clobber a
52
+ // value the clamp had just corrected (bug #38).
53
+ await xmmpClient.getChatsPrivateStoreRequestStanza();
49
54
  } else {
50
- //@ts-ignore
51
- const roomTimestampObject = await xmmpClient.getChatsPrivateStoreRequestStanza();
52
- (0, _updatedChatLastTimestamps.updatedChatLastTimestamps)(roomTimestampObject, _roomStore.store.dispatch);
55
+ await xmmpClient.getChatsPrivateStoreRequestStanza();
53
56
  }
54
57
  if (config?.refreshTokens?.enabled) {
55
- config?.refreshTokens?.refreshFunction?.();
58
+ // Was a bare call to the consumer-supplied refreshFunction, i.e. a
59
+ // rotation completely outside the SDK's lock. Routed through the
60
+ // one rotation point, which calls that same function internally.
61
+ (0, _authRefresh.refreshAuthTokensQuietly)();
56
62
  }
57
63
  } catch (error) {
58
64
  console.error(error);
@@ -1 +1 @@
1
- {"version":3,"names":["_roomsSlice","require","_updatedChatLastTimestamps","_initRoomsPresence","_roomStore","initXmppRooms","user","config","xmmpClient","rooms","roomJID","store","dispatch","setCurrentRoom","defaultWallet","walletAddress","console","log","Object","keys","length","initRoomsPresence","newArch","res","getRoomsStanza","roomTimestampObject","getChatsPrivateStoreRequestStanza","updatedChatLastTimestamps","refreshTokens","enabled","refreshFunction","error","setIsLoading","loading","_default","exports","default"],"sourceRoot":"../../../src","sources":["helpers/initXmppRooms.tsx"],"mappings":";;;;;;AAAA,IAAAA,WAAA,GAAAC,OAAA;AACA,IAAAC,0BAAA,GAAAD,OAAA;AACA,IAAAE,kBAAA,GAAAF,OAAA;AAGA,IAAAG,UAAA,GAAAH,OAAA;AAEA,MAAMI,aAAa,GAAG,MAAAA,CACpBC,IAAU,EACVC,MAAe,EACfC,UAAsB,EACtBC,KAAgC,EAChCC,OAAgB,KACb;EACH,IAAIA,OAAO,EAAE;IACXC,gBAAK,CAACC,QAAQ,CAAC,IAAAC,0BAAc,EAAC;MAAEH,OAAO,EAAEA;IAAQ,CAAC,CAAC,CAAC;EACtD;EAEA,IAAI;IACF,IAAI,CAACJ,IAAI,CAACQ,aAAa,IAAI,CAACR,IAAI,CAACQ,aAAa,CAACC,aAAa,EAAE;MAC5DC,OAAO,CAACC,GAAG,CAAC,gBAAgB,CAAC;MAC7B;IACF;IAEA,IAAI,CAACT,UAAU,EAAE;MACfQ,OAAO,CAACC,GAAG,CAAC,iCAAiC,CAAC;MAE9C,IAAIR,KAAK,IAAIS,MAAM,CAACC,IAAI,CAACV,KAAK,CAAC,CAACW,MAAM,GAAG,CAAC,EAAE;QAC1C,MAAM,IAAAC,oCAAiB,EAACb,UAAU,EAAEC,KAAK,CAAC;MAC5C,CAAC,MAAM;QACL,IAAIF,MAAM,EAAEe,OAAO,EAAE;UACnB;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;QACF;QACA,MAAMC,GAAG,GAAG,MAAOf,UAAU,CAAuBgB,cAAc,CAAC,CAAC;QACpER,OAAO,CAACC,GAAG,CAACM,GAAG,CAAC;MAClB;;MAEA;MACA,MAAME,mBAAqD,GACzD,MAAOjB,UAAU,CAAuBkB,iCAAiC,CAAC,CAAC;MAC7E,IAAAC,oDAAyB,EAACF,mBAAmB,EAAEd,gBAAK,CAACC,QAAQ,CAAC;IAChE,CAAC,MAAM;MACL;MACA,MAAMa,mBAAqD,GACzD,MAAMjB,UAAU,CAACkB,iCAAiC,CAAC,CAAC;MACtD,IAAAC,oDAAyB,EAACF,mBAAmB,EAAEd,gBAAK,CAACC,QAAQ,CAAC;IAChE;IAEA,IAAIL,MAAM,EAAEqB,aAAa,EAAEC,OAAO,EAAE;MAClCtB,MAAM,EAAEqB,aAAa,EAAEE,eAAe,GAAG,CAAC;IAC5C;EACF,CAAC,CAAC,OAAOC,KAAK,EAAE;IACdf,OAAO,CAACe,KAAK,CAACA,KAAK,CAAC;EACtB,CAAC,SAAS;IACRpB,gBAAK,CAACC,QAAQ,CAAC,IAAAoB,wBAAY,EAAC;MAAEC,OAAO,EAAE;IAAM,CAAC,CAAC,CAAC;EAClD;AACF,CAAC;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEa/B,aAAa","ignoreList":[]}
1
+ {"version":3,"names":["_roomsSlice","require","_initRoomsPresence","_roomStore","_authRefresh","initXmppRooms","user","config","xmmpClient","rooms","roomJID","store","dispatch","setCurrentRoom","defaultWallet","walletAddress","console","log","Object","keys","length","initRoomsPresence","newArch","res","getRoomsStanza","getChatsPrivateStoreRequestStanza","refreshTokens","enabled","refreshAuthTokensQuietly","error","setIsLoading","loading","_default","exports","default"],"sourceRoot":"../../../src","sources":["helpers/initXmppRooms.tsx"],"mappings":";;;;;;AAAA,IAAAA,WAAA,GAAAC,OAAA;AACA,IAAAC,kBAAA,GAAAD,OAAA;AAGA,IAAAE,UAAA,GAAAF,OAAA;AACA,IAAAG,YAAA,GAAAH,OAAA;AAEA,MAAMI,aAAa,GAAG,MAAAA,CACpBC,IAAU,EACVC,MAAe,EACfC,UAAsB,EACtBC,KAAgC,EAChCC,OAAgB,KACb;EACH,IAAIA,OAAO,EAAE;IACXC,gBAAK,CAACC,QAAQ,CAAC,IAAAC,0BAAc,EAAC;MAAEH,OAAO,EAAEA;IAAQ,CAAC,CAAC,CAAC;EACtD;EAEA,IAAI;IACF,IAAI,CAACJ,IAAI,CAACQ,aAAa,IAAI,CAACR,IAAI,CAACQ,aAAa,CAACC,aAAa,EAAE;MAC5DC,OAAO,CAACC,GAAG,CAAC,gBAAgB,CAAC;MAC7B;IACF;IAEA,IAAI,CAACT,UAAU,EAAE;MACfQ,OAAO,CAACC,GAAG,CAAC,iCAAiC,CAAC;MAE9C,IAAIR,KAAK,IAAIS,MAAM,CAACC,IAAI,CAACV,KAAK,CAAC,CAACW,MAAM,GAAG,CAAC,EAAE;QAC1C,MAAM,IAAAC,oCAAiB,EAACb,UAAU,EAAEC,KAAK,CAAC;MAC5C,CAAC,MAAM;QACL,IAAIF,MAAM,EAAEe,OAAO,EAAE;UACnB;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;QACF;QACA,MAAMC,GAAG,GAAG,MAAOf,UAAU,CAAuBgB,cAAc,CAAC,CAAC;QACpER,OAAO,CAACC,GAAG,CAACM,GAAG,CAAC;MAClB;;MAEA;MACA;MACA;MACA;MACA;MACA;MACA;MACA,MAAOf,UAAU,CAAuBiB,iCAAiC,CAAC,CAAC;IAC7E,CAAC,MAAM;MACL,MAAMjB,UAAU,CAACiB,iCAAiC,CAAC,CAAC;IACtD;IAEA,IAAIlB,MAAM,EAAEmB,aAAa,EAAEC,OAAO,EAAE;MAClC;MACA;MACA;MACA,IAAAC,qCAAwB,EAAC,CAAC;IAC5B;EACF,CAAC,CAAC,OAAOC,KAAK,EAAE;IACdb,OAAO,CAACa,KAAK,CAACA,KAAK,CAAC;EACtB,CAAC,SAAS;IACRlB,gBAAK,CAACC,QAAQ,CAAC,IAAAkB,wBAAY,EAAC;MAAEC,OAAO,EAAE;IAAM,CAAC,CAAC,CAAC;EAClD;AACF,CAAC;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEa7B,aAAa","ignoreList":[]}
@@ -5,6 +5,37 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.insertMessageWithDelimiter = insertMessageWithDelimiter;
7
7
  var _dateComparison = require("./dateComparison");
8
+ var _msgSortableMs = require("./msgSortableMs");
9
+ // Robustly resolve a caller-supplied read marker to epoch milliseconds.
10
+ // Callers pass a plain number (the redux read boundary, or a room's
11
+ // lastViewedTimestamp), a Date object (older call sites), or occasionally
12
+ // a numeric string. These are NOT interchangeable through the Date
13
+ // constructor: `new Date(1757000000123)` (a number) reads as epoch-ms,
14
+ // but `new Date("1757000000123")` (a string) is parsed as a date STRING
15
+ // - a bare 13-digit string matches no recognized date format, so the
16
+ // result is silently Invalid Date and every comparison against it is
17
+ // `false`. Try Number() first so a numeric string/number is read as
18
+ // epoch-ms; only fall through to Date parsing for genuine date/ISO
19
+ // strings (e.g. a Date object's own `.toString()`). Never falls back to
20
+ // `Date.now()` - a marker we can't resolve is treated as "no marker",
21
+ // not "now" (bug #38).
22
+ function resolveMarkerMs(marker) {
23
+ if (marker == null) {
24
+ return 0;
25
+ }
26
+ if (typeof marker === 'number') {
27
+ return Number.isFinite(marker) ? marker : 0;
28
+ }
29
+ const raw = marker.toString();
30
+ if (raw.trim() !== '') {
31
+ const asNumber = Number(raw);
32
+ if (Number.isFinite(asNumber)) {
33
+ return asNumber;
34
+ }
35
+ }
36
+ const parsed = Date.parse(raw);
37
+ return Number.isFinite(parsed) ? parsed : 0;
38
+ }
8
39
  function deepMerge(target, source) {
9
40
  for (const key in source) {
10
41
  if (source[key] === undefined) {
@@ -66,21 +97,32 @@ function insertMessageWithDelimiter(roomMessages, message, lastViewedTimestamp)
66
97
  } else {
67
98
  roomMessages.push(message);
68
99
  }
69
- if (lastViewedTimestamp && !roomMessages.some(msg => msg.id === 'delimiter-new') && (0, _dateComparison.isDateAfter)(newMessageDate.toString(), lastViewedTimestamp.toString())) {
70
- const delimiterIndex = roomMessages.findIndex(msg => (0, _dateComparison.isDateAfter)(msg.date?.toString() ?? '', lastViewedTimestamp.toString()));
100
+ const lastViewedMs = resolveMarkerMs(lastViewedTimestamp);
101
+ const newMessageMs = (0, _msgSortableMs.msgSortableMs)(message);
102
+ if (lastViewedMs > 0 && newMessageMs > lastViewedMs && !roomMessages.some(msg => msg.id === 'delimiter-new')) {
103
+ // Find the first message STRICTLY newer than the marker, using the
104
+ // SAME timestamp source (msgSortableMs - the server id-encoded ms)
105
+ // as the unread middleware and countNewerMessages use to decide
106
+ // what counts as unread. Comparing against a DIFFERENT source (the
107
+ // old code compared `msg.date` strings) risks the boundary message
108
+ // itself landing on the wrong side of the cut: since bug #38 the
109
+ // marker can equal a real message's own timestamp exactly, and any
110
+ // drift between `date` and the id-encoded ms - or a raw numeric
111
+ // marker silently producing an Invalid Date via the Date
112
+ // constructor's string-parsing path - could count that message as
113
+ // unread, pushing the divider one message too early (ABOVE the
114
+ // last read message instead of directly below it). Customer #42.
115
+ const delimiterIndex = roomMessages.findIndex(msg => msg.id !== 'delimiter-new' && (0, _msgSortableMs.msgSortableMs)(msg) > lastViewedMs);
71
116
  if (delimiterIndex !== -1) {
72
117
  // The divider's date is what ORDERS it: roomsSlice re-sorts every
73
118
  // merged page by timestamp (see `byMs`), so a divider stamped with
74
- // `new Date()` — i.e. now — sorted past every real message and
119
+ // `new Date()` (i.e. now) sorted past every real message and
75
120
  // rendered at the very bottom, BELOW the new messages it is
76
121
  // supposed to introduce. Anchor it a hair before the first unread
77
122
  // instead, which is where it belongs and where any later sort keeps
78
- // it. Derived from that message rather than from
79
- // lastViewedTimestamp so it works whatever format the caller passes.
80
- const firstUnreadMs = Date.parse(String(roomMessages[delimiterIndex]?.date ?? ''));
81
- const rawLastViewed = lastViewedTimestamp.toString();
82
- const lastViewedMs = Date.parse(rawLastViewed) || Number(rawLastViewed) || Date.now();
83
- const anchorMs = Number.isFinite(firstUnreadMs) ? firstUnreadMs - 1 : lastViewedMs;
123
+ // it.
124
+ const firstUnreadMs = (0, _msgSortableMs.msgSortableMs)(roomMessages[delimiterIndex]);
125
+ const anchorMs = firstUnreadMs > 0 ? firstUnreadMs - 1 : lastViewedMs;
84
126
  roomMessages.splice(delimiterIndex, 0, {
85
127
  id: 'delimiter-new',
86
128
  user: {
@@ -1 +1 @@
1
- {"version":3,"names":["_dateComparison","require","deepMerge","target","source","key","undefined","Array","isArray","insertMessageWithDelimiter","roomMessages","message","lastViewedTimestamp","existingIndex","findIndex","msg","id","xmppId","existing","preservedUserId","user","merged","pending","newMessageDate","date","lastMessage","length","firstMessage","isDateAfter","toString","index","push","some","delimiterIndex","firstUnreadMs","Date","parse","String","rawLastViewed","lastViewedMs","Number","now","anchorMs","isFinite","splice","name","token","refreshToken","toISOString","body","roomJid","isDateBefore","unshift","i"],"sourceRoot":"../../../src","sources":["helpers/insertMessageWithDelimiter.ts"],"mappings":";;;;;;AACA,IAAAA,eAAA,GAAAC,OAAA;AAEA,SAASC,SAASA,CAACC,MAAW,EAAEC,MAAW,EAAO;EAChD,KAAK,MAAMC,GAAG,IAAID,MAAM,EAAE;IACxB,IAAIA,MAAM,CAACC,GAAG,CAAC,KAAKC,SAAS,EAAE;MAC7B;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MACA;IACF;IACA,IACEF,MAAM,CAACC,GAAG,CAAC,IACX,OAAOD,MAAM,CAACC,GAAG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AC,EAC/E;QACAnB,YAAY,CAACkC,MAAM,CAACS,CAAC,EAAE,CAAC,EAAE1C,OAAO,CAAC;QAClC;MACF;IACF;EACF;AACF","ignoreList":[]}
1
+ {"version":3,"names":["_dateComparison","require","_msgSortableMs","resolveMarkerMs","marker","Number","isFinite","raw","toString","trim","asNumber","parsed","Date","parse","deepMerge","target","source","key","undefined","Array","isArray","insertMessageWithDelimiter","roomMessages","message","lastViewedTimestamp","existingIndex","findIndex","msg","id","xmppId","existing","preservedUserId","user","merged","pending","newMessageDate","date","lastMessage","length","firstMessage","isDateAfter","index","push","lastViewedMs","newMessageMs","msgSortableMs","some","delimiterIndex","firstUnreadMs","anchorMs","splice","name","token","refreshToken","toISOString","body","roomJid","isDateBefore","unshift","i"],"sourceRoot":"../../../src","sources":["helpers/insertMessageWithDelimiter.ts"],"mappings":";;;;;;AACA,IAAAA,eAAA,GAAAC,OAAA;AACA,IAAAC,cAAA,GAAAD,OAAA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASE,eAAeA,CACtBC,MAA8D,EACtD;EACR,IAAIA,MAAM,IAAI,IAAI,EAAE;IAAC,OAAO,CAAC;EAAC;EAC9B,IAAI,OAAOA,MAAM,KAAK,QAAQ,EAAE;IAC9B,OAAOC,MAAM,CAACC,QAAQ,CAACF,MAAM,CAAC,GAAGA,MAAM,GAAG,CAAC;EAC7C;EACA,MAAMG,GAAG,GAAGH,MAAM,CAACI,QAAQ,CAAC,CAAC;EAC7B,IAAID,GAAG,CAACE,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE;IACrB,MAAMC,QAAQ,GAAGL,MAAM,CAACE,GAAG,CAAC;IAC5B,IAAIF,MAAM,CAACC,QAAQ,CAACI,QAAQ,CAAC,EAAE;MAAC,OAAOA,QAAQ;IAAC;EAClD;EACA,MAAMC,MAAM,GAAGC,IAAI,CAACC,KAAK,CAACN,GAAG,CAAC;EAC9B,OAAOF,MAAM,CAAC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