@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 @@
1
+ {"version":3,"names":["DEFAULT_CHAT_BACKGROUND","getChatBackgroundColor","config","backgroundChat","color"],"sourceRoot":"../../../src","sources":["helpers/getChatBackground.ts"],"mappings":";;AAAA;;AAIA;AACA;AACA,OAAO,MAAMA,uBAAuB,GAAG,SAAS;;AAEhD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,sBAAsB,GAAIC,MAAgB,IACrDA,MAAM,EAAEC,cAAc,EAAEC,KAAK,IAAIJ,uBAAuB","ignoreList":[]}
@@ -0,0 +1,73 @@
1
+ "use strict";
2
+
3
+ import { ensureFilenameHasExtension, filenameFromUrl } from './mimeToExtension';
4
+ /**
5
+ * Picks the best human-readable filename for a chat attachment - the
6
+ * single source of truth for every place a file name is rendered in the
7
+ * UI, saved to disk, shared, or downloaded.
8
+ *
9
+ * Priority: `originalName` (the sender's own file name, e.g. "test1.pdf")
10
+ * beats `fileName` (the server's stored/hashed name, e.g.
11
+ * "3f9a1c...c2.pdf") beats the last path segment of `location`. The
12
+ * stored hash name is only a fallback of last resort.
13
+ *
14
+ * Bug #40: display and save/share/download logic used to prefer the
15
+ * stored hash name over the original one, so an attachment sent as
16
+ * "test1.pdf" showed up (and got saved to the phone) as something like
17
+ * "3f9a1c...c2.pdf" - both directions (web -> RN and RN -> RN).
18
+ *
19
+ * Always returns a non-empty string with a valid extension: if the
20
+ * chosen candidate has no extension (a hash name can be `<hex>` with no
21
+ * extension at all, or `<hex>.<ext>`), one is appended from `mimetype`
22
+ * (or `.bin` as a last resort when the mime is unknown/missing too).
23
+ */
24
+ export function getDisplayFileName(options) {
25
+ const candidate = options.originalName && options.originalName.trim() || options.fileName && options.fileName.trim() || filenameFromUrl(options.location) || '';
26
+ return ensureFilenameHasExtension(candidate, options.mimetype);
27
+ }
28
+
29
+ /**
30
+ * Makes a display name safe to use as an actual path segment when
31
+ * saving/sharing a file to the device: strips path separators (so an
32
+ * odd/hostile server-provided name can't escape the target directory)
33
+ * and control characters. Keeps the rest of the name - including the
34
+ * extension - intact.
35
+ */
36
+ export function sanitizeFileNameForPath(name) {
37
+ const cleaned = (name || '').replace(/[\/\\]/g, '_')
38
+ // eslint-disable-next-line no-control-regex
39
+ .replace(/[\x00-\x1f\x7f]/g, '').trim();
40
+ return cleaned || 'file';
41
+ }
42
+
43
+ /**
44
+ * Resolves a filename that is safe to write into a target directory:
45
+ * sanitizes it, then - if `exists` reports a collision - inserts
46
+ * " (1)", " (2)", ... before the extension until a free name is found,
47
+ * so saving two different attachments that share a display name never
48
+ * silently overwrites the first one.
49
+ *
50
+ * `exists` is injected so callers can back it with whatever existence
51
+ * check makes sense for their storage API (expo-file-system,
52
+ * StorageAccessFramework directory listing, ...) - this function stays
53
+ * pure and easy to unit test.
54
+ */
55
+ export async function getUniqueFileName(name, exists) {
56
+ const safeName = sanitizeFileNameForPath(name);
57
+ if (!(await exists(safeName))) {
58
+ return safeName;
59
+ }
60
+ const dotIndex = safeName.lastIndexOf('.');
61
+ const base = dotIndex > 0 ? safeName.slice(0, dotIndex) : safeName;
62
+ const ext = dotIndex > 0 ? safeName.slice(dotIndex) : '';
63
+ // 999 collisions is already a pathological case; fall back to a
64
+ // timestamp suffix rather than looping forever.
65
+ for (let i = 1; i < 1000; i += 1) {
66
+ const candidate = `${base} (${i})${ext}`;
67
+ if (!(await exists(candidate))) {
68
+ return candidate;
69
+ }
70
+ }
71
+ return `${base} (${Date.now()})${ext}`;
72
+ }
73
+ //# sourceMappingURL=getDisplayFileName.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["ensureFilenameHasExtension","filenameFromUrl","getDisplayFileName","options","candidate","originalName","trim","fileName","location","mimetype","sanitizeFileNameForPath","name","cleaned","replace","getUniqueFileName","exists","safeName","dotIndex","lastIndexOf","base","slice","ext","i","Date","now"],"sourceRoot":"../../../src","sources":["helpers/getDisplayFileName.ts"],"mappings":";;AAAA,SAASA,0BAA0B,EAAEC,eAAe,QAAQ,mBAAmB;AAS/E;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,kBAAkBA,CAACC,OAA+B,EAAU;EAC1E,MAAMC,SAAS,GACZD,OAAO,CAACE,YAAY,IAAIF,OAAO,CAACE,YAAY,CAACC,IAAI,CAAC,CAAC,IACnDH,OAAO,CAACI,QAAQ,IAAIJ,OAAO,CAACI,QAAQ,CAACD,IAAI,CAAC,CAAE,IAC7CL,eAAe,CAACE,OAAO,CAACK,QAAQ,CAAC,IACjC,EAAE;EACJ,OAAOR,0BAA0B,CAACI,SAAS,EAAED,OAAO,CAACM,QAAQ,CAAC;AAChE;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,uBAAuBA,CAACC,IAAY,EAAU;EAC5D,MAAMC,OAAO,GAAG,CAACD,IAAI,IAAI,EAAE,EACxBE,OAAO,CAAC,SAAS,EAAE,GAAG;EACvB;EAAA,CACCA,OAAO,CAAC,kBAAkB,EAAE,EAAE,CAAC,CAC/BP,IAAI,CAAC,CAAC;EACT,OAAOM,OAAO,IAAI,MAAM;AAC1B;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,eAAeE,iBAAiBA,CACrCH,IAAY,EACZI,MAAmD,EAClC;EACjB,MAAMC,QAAQ,GAAGN,uBAAuB,CAACC,IAAI,CAAC;EAC9C,IAAI,EAAE,MAAMI,MAAM,CAACC,QAAQ,CAAC,CAAC,EAAE;IAC7B,OAAOA,QAAQ;EACjB;EACA,MAAMC,QAAQ,GAAGD,QAAQ,CAACE,WAAW,CAAC,GAAG,CAAC;EAC1C,MAAMC,IAAI,GAAGF,QAAQ,GAAG,CAAC,GAAGD,QAAQ,CAACI,KAAK,CAAC,CAAC,EAAEH,QAAQ,CAAC,GAAGD,QAAQ;EAClE,MAAMK,GAAG,GAAGJ,QAAQ,GAAG,CAAC,GAAGD,QAAQ,CAACI,KAAK,CAACH,QAAQ,CAAC,GAAG,EAAE;EACxD;EACA;EACA,KAAK,IAAIK,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAG,IAAI,EAAEA,CAAC,IAAI,CAAC,EAAE;IAChC,MAAMlB,SAAS,GAAG,GAAGe,IAAI,KAAKG,CAAC,IAAID,GAAG,EAAE;IACxC,IAAI,EAAE,MAAMN,MAAM,CAACX,SAAS,CAAC,CAAC,EAAE;MAC9B,OAAOA,SAAS;IAClB;EACF;EACA,OAAO,GAAGe,IAAI,KAAKI,IAAI,CAACC,GAAG,CAAC,CAAC,IAAIH,GAAG,EAAE;AACxC","ignoreList":[]}
@@ -0,0 +1,181 @@
1
+ "use strict";
2
+
3
+ import { msgSortableMs } from './msgSortableMs';
4
+
5
+ // A stored/stamped read marker more than this far past the newest
6
+ // message we actually know about for a room is not "the user is a
7
+ // little ahead" - it's a leftover from a device whose clock was wrong
8
+ // when it stamped the marker (bug #38). Generous on purpose: this value
9
+ // only controls when we're willing to treat an existing marker as
10
+ // corrupt and self-heal it, never how far off a legitimate new write can
11
+ // be, so a false positive here just means a bad value survives one extra
12
+ // cycle, not that a good value gets rejected.
13
+ export const FUTURE_READ_MARKER_TOLERANCE_MS = 5 * 60 * 1000;
14
+ /**
15
+ * Resolve the "read up to here" marker for `room` using SERVER time,
16
+ * never the device clock.
17
+ *
18
+ * Bug #38: if the device clock is ahead when the user leaves a room, a
19
+ * `Date.now()` read marker lands in the future. The private-store merge
20
+ * (flushLastViewedToPrivateStore.ts) is forward-only ("if (prevNum >=
21
+ * ts) continue"), so once a future marker is written, no later
22
+ * *correct* write can ever replace it - the room's unread count is
23
+ * stuck wrong forever, on every device, from that point on. Anchoring
24
+ * to the newest SERVER-acknowledged message's own timestamp instead
25
+ * means the marker we write can never be ahead of what the server
26
+ * itself has recorded for the room.
27
+ *
28
+ * "Server-acknowledged" excludes:
29
+ * - a message still marked `pending` (the optimistic bubble shown
30
+ * while a send is in flight - it carries the DEVICE send time via
31
+ * `date`, not a server timestamp, until the server echoes it back
32
+ * and insertMessageWithDelimiter flips `pending` off);
33
+ * - a message id present in `heapState.messageHeap` (queued retry -
34
+ * used for offline media sends, see roomHeapSlice.ts) or
35
+ * `heapState.failedMessages` (a send that never reached the server
36
+ * at all).
37
+ *
38
+ * `msgSortableMs` (helpers/msgSortableMs.ts) reads the server-assigned microsecond
39
+ * timestamp encoded in the first 13 digits of the message id - the same
40
+ * source already used for message ordering and unread counting - so
41
+ * this stays consistent with the rest of the read/unread pipeline.
42
+ *
43
+ * Falls back to the room's existing `lastViewedTimestamp` (so leaving
44
+ * an empty or never-scrolled room doesn't regress the marker), then to
45
+ * `0` when there's truly nothing to anchor to yet (a brand new room
46
+ * with no history and no prior marker). Callers should treat `0` as
47
+ * "skip the write" rather than substituting a device-clock guess.
48
+ */
49
+ export function getServerReadTimestamp(room, heapState) {
50
+ if (!room) {
51
+ return 0;
52
+ }
53
+ const heapIds = new Set((heapState?.messageHeap || []).filter(m => m && m.id != null).map(m => String(m.id)));
54
+ const failedIds = new Set(Object.keys(heapState?.failedMessages || {}));
55
+ let newest = 0;
56
+ const messages = room.messages || [];
57
+ for (const m of messages) {
58
+ if (!m || !m.id) {
59
+ continue;
60
+ }
61
+ const id = String(m.id);
62
+ if (id === 'delimiter-new' || id === 'delimiter-new-local') {
63
+ continue;
64
+ }
65
+ if (m.pending) {
66
+ continue;
67
+ }
68
+ if (heapIds.has(id) || failedIds.has(id)) {
69
+ continue;
70
+ }
71
+ const ts = msgSortableMs(m);
72
+ if (ts > newest) {
73
+ newest = ts;
74
+ }
75
+ }
76
+ if (newest > 0) {
77
+ return newest;
78
+ }
79
+ if (room.lastViewedTimestamp && room.lastViewedTimestamp > 0) {
80
+ return room.lastViewedTimestamp;
81
+ }
82
+ return 0;
83
+ }
84
+
85
+ /**
86
+ * Is `marker` a leftover from a device whose clock was wrong when it
87
+ * stamped a read marker (bug #38)?
88
+ *
89
+ * TWO independent signals must agree before we're willing to throw a
90
+ * stored marker away, because "waive the forward-only guard" is a
91
+ * destructive operation:
92
+ *
93
+ * 1. it sits well past the newest message we know the room has, AND
94
+ * 2. it sits well past real time.
95
+ *
96
+ * Signal 1 alone is NOT enough, and that is the whole point of this
97
+ * function: a device whose local cache for a room is simply stale (very
98
+ * common - any room whose history hasn't been synced yet this session)
99
+ * sees a perfectly legitimate marker written by another device that HAS
100
+ * seen newer messages, and would happily "heal" it backwards, resurrecting
101
+ * already-read messages as unread on every device. A real timestamp can
102
+ * never be ahead of real time, so requiring signal 2 as well means a
103
+ * stale cache on its own can no longer trigger the self-heal.
104
+ *
105
+ * Signal 2 alone is not used either: it would let a device whose own
106
+ * clock is running SLOW mistake every correct marker for a corrupt one.
107
+ */
108
+ export function isCorruptFutureReadMarker(marker, newestAckedMs) {
109
+ if (!Number.isFinite(marker) || marker <= 0) {
110
+ return false;
111
+ }
112
+ if (!(newestAckedMs > 0)) {
113
+ return false;
114
+ }
115
+ if (marker <= newestAckedMs + FUTURE_READ_MARKER_TOLERANCE_MS) {
116
+ return false;
117
+ }
118
+ return marker > Date.now() + FUTURE_READ_MARKER_TOLERANCE_MS;
119
+ }
120
+
121
+ /**
122
+ * Resolve the marker to STAMP (locally and to the server) for `room`,
123
+ * honouring an explicit read boundary when one is set.
124
+ *
125
+ * Bug #42 (a regression of #33, reintroduced by #38): #38 made every
126
+ * caller stamp the newest server-acknowledged message unconditionally.
127
+ * That is correct for a user who is at the bottom of the room, but wrong
128
+ * for a user who scrolled up, received messages, and left without
129
+ * scrolling back down - stamping "newest" there silently marks
130
+ * messages they never saw as read, both locally and (because the
131
+ * private-store merge is forward-only) permanently on the server.
132
+ *
133
+ * `boundaryTs` is the msgSortableMs of the newest message the user
134
+ * actually reached (see `readBoundaries` on `RoomMessagesState`,
135
+ * populated by MessageList's `onReadBoundaryChange`). When it's set and
136
+ * positive, it wins - but is still clamped to never exceed the newest
137
+ * server-acknowledged message, so a stale/corrupt boundary can't stamp a
138
+ * marker further ahead than the room's own history supports. When no
139
+ * boundary is set (the common case - the user is at the bottom), this is
140
+ * exactly `getServerReadTimestamp`.
141
+ *
142
+ * Never returns `Date.now()`, directly or indirectly - same rule as
143
+ * `getServerReadTimestamp` (bug #38).
144
+ */
145
+ export function getReadMarkerTimestamp(room, heapState, boundaryTs) {
146
+ const newestAcked = getServerReadTimestamp(room, heapState);
147
+ if (typeof boundaryTs === 'number' && Number.isFinite(boundaryTs) && boundaryTs > 0) {
148
+ // `newestAcked === 0` means this room has NOTHING server-acked and no
149
+ // prior marker, so there is nothing to clamp the boundary against -
150
+ // and MessageList derives the boundary from the rendered list, which
151
+ // at that point can only contain pending/failed sends carrying the
152
+ // DEVICE clock via `date`. Returning it here would smuggle a
153
+ // device-clock marker back in through the boundary (bug #38). Return
154
+ // 0 = "nothing to anchor to, skip the write", same contract as
155
+ // getServerReadTimestamp.
156
+ return newestAcked > 0 ? Math.min(boundaryTs, newestAcked) : 0;
157
+ }
158
+ return newestAcked;
159
+ }
160
+
161
+ /**
162
+ * The value to hand `flushLastViewedToPrivateStore` as `visibleRoomTs`
163
+ * for a room being left, or `undefined` when no boundary applies (the
164
+ * flush then uses its own newest-acked default).
165
+ *
166
+ * Exists so the SERVER write goes through the SAME clamp as the local
167
+ * stamp. Passing the raw redux boundary straight through would bypass
168
+ * `getReadMarkerTimestamp`'s clamp on exactly the path where a bad value
169
+ * is permanent: the private-store merge is forward-only, so a boundary
170
+ * that (through a pending own message's device `date`, or a stale
171
+ * readBoundaries entry) sat ahead of the room's real history would be
172
+ * written verbatim and could never be corrected again (bug #38).
173
+ */
174
+ export function getFlushBoundaryTs(room, heapState, boundaryTs) {
175
+ if (typeof boundaryTs !== 'number' || !Number.isFinite(boundaryTs) || boundaryTs <= 0) {
176
+ return undefined;
177
+ }
178
+ const clamped = getReadMarkerTimestamp(room, heapState, boundaryTs);
179
+ return clamped > 0 ? clamped : undefined;
180
+ }
181
+ //# sourceMappingURL=getServerReadTimestamp.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["msgSortableMs","FUTURE_READ_MARKER_TOLERANCE_MS","getServerReadTimestamp","room","heapState","heapIds","Set","messageHeap","filter","m","id","map","String","failedIds","Object","keys","failedMessages","newest","messages","pending","has","ts","lastViewedTimestamp","isCorruptFutureReadMarker","marker","newestAckedMs","Number","isFinite","Date","now","getReadMarkerTimestamp","boundaryTs","newestAcked","Math","min","getFlushBoundaryTs","undefined","clamped"],"sourceRoot":"../../../src","sources":["helpers/getServerReadTimestamp.ts"],"mappings":";;AACA,SAASA,aAAa,QAAQ,iBAAiB;;AAE/C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,+BAA+B,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;AACA,OAAO,SAASC,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,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ACA,OAAOK,SAAS;EAClB;EACA,MAAMC,OAAO,GAAGP,sBAAsB,CAAC3B,IAAI,EAAEC,SAAS,EAAE2B,UAAU,CAAC;EACnE,OAAOM,OAAO,GAAG,CAAC,GAAGA,OAAO,GAAGD,SAAS;AAC1C","ignoreList":[]}
@@ -2,13 +2,20 @@
2
2
 
3
3
  import { AppState } from 'react-native';
4
4
  import { store } from '../roomStore';
5
- import { applyRoomsPreloadBatch, setUnreadSyncing } from '../roomStore/roomsSlice';
5
+ import { applyRoomsPreloadBatch, setUnreadSyncing, RUNTIME_MESSAGE_LIMIT } from '../roomStore/roomsSlice';
6
6
  const DEFAULT_CONCURRENCY = 3;
7
7
  // Fetch the most recent ~20 on re-entry (mirrors web). A larger first page
8
8
  // also means more id-overlap with cache, so the merge in
9
9
  // `mergeHistoryIntoCache` rarely has to fall back to clear-and-replace.
10
10
  const DEFAULT_PAGE_SIZE = 20;
11
11
  const DEFAULT_RETRY_LIMIT = 2;
12
+ // When the first page is entirely unread (every fetched message is newer
13
+ // than `lastViewedTimestamp`), the true unread count could be far bigger
14
+ // than `pageSize` — `useUnread()` only ever sees what's been loaded. Page
15
+ // further back, up to this many extra fetches, until we either find the
16
+ // boundary or give up (`unreadCapped` then stays true so callers at least
17
+ // know the count is a floor, not exact). Customer-reported #34.
18
+ const MAX_UNREAD_CATCHUP_PAGES = 8;
12
19
  const sleep = ms => new Promise(resolve => setTimeout(resolve, ms));
13
20
  const messageTimestamp = m => {
14
21
  if (!m) {
@@ -180,11 +187,67 @@ export const runHistoryPreloadScheduler = async options => {
180
187
  throw new Error('history_timeout');
181
188
  }
182
189
  const nextRoom = store.getState().rooms.rooms[item.jid];
183
- const unreadCapped = computeUnreadCapped(nextRoom, fetchedMessages || [], pageSize);
190
+ let combined = fetchedMessages || [];
191
+ const lastViewed = Number(nextRoom?.lastViewedTimestamp) || 0;
192
+
193
+ // The first page was entirely unread — keep paging older until
194
+ // we find a message at/before `lastViewedTimestamp` (the true
195
+ // boundary) or run out of catch-up budget, so the count isn't
196
+ // silently truncated at `pageSize`.
197
+ if (lastViewed > 0 && computeUnreadCapped(nextRoom, combined, pageSize)) {
198
+ let lastPageLen = combined.length;
199
+ let extraPages = 0;
200
+ while (extraPages < MAX_UNREAD_CATCHUP_PAGES && lastPageLen >= pageSize && !signal?.aborted) {
201
+ const oldestId = combined.reduce((min, m) => {
202
+ const idNum = Number(m?.id);
203
+ if (!Number.isFinite(idNum)) {
204
+ return min;
205
+ }
206
+ return min === null || idNum < min ? idNum : min;
207
+ }, null);
208
+ if (oldestId === null) {
209
+ break;
210
+ }
211
+ let older;
212
+ try {
213
+ older = await client.getHistoryStanza(item.jid, pageSize, oldestId, undefined, {
214
+ coalesceRoom: true,
215
+ skipIfPreloaded: !forceReload,
216
+ source: 'background'
217
+ });
218
+ } catch {
219
+ break;
220
+ }
221
+ if (!older || !older.length) {
222
+ break;
223
+ }
224
+ combined = [...older, ...combined];
225
+ lastPageLen = older.length;
226
+ extraPages++;
227
+ const oldestTs = combined.reduce((minTs, m) => {
228
+ const ts = messageTimestamp(m);
229
+ return ts > 0 ? Math.min(minTs, ts) : minTs;
230
+ }, Number.MAX_SAFE_INTEGER);
231
+ if (oldestTs !== Number.MAX_SAFE_INTEGER && oldestTs <= lastViewed) {
232
+ break;
233
+ }
234
+ }
235
+ }
236
+
237
+ // `mergeHistoryIntoCache` (roomsSlice) caps whatever we dispatch
238
+ // here to the newest RUNTIME_MESSAGE_LIMIT messages before it
239
+ // ever reaches `unreadMiddleware` — so a catch-up fetch that
240
+ // pulled the true boundary can still have it silently dropped
241
+ // by that cap, leaving a falsely-confident `unreadCapped:false`
242
+ // (bug #34's failure mode again, just one layer downstream).
243
+ // Simulate that cap here so the flag reflects what will
244
+ // actually survive, not just what this fetch retrieved.
245
+ const simulatedStored = combined.length > RUNTIME_MESSAGE_LIMIT ? combined.slice(-RUNTIME_MESSAGE_LIMIT) : combined;
246
+ const unreadCapped = computeUnreadCapped(nextRoom, simulatedStored, pageSize);
184
247
  store.dispatch(applyRoomsPreloadBatch({
185
248
  rooms: [{
186
249
  jid: item.jid,
187
- messages: fetchedMessages || [],
250
+ messages: combined,
188
251
  unreadCapped,
189
252
  historyPreloadState: 'done'
190
253
  }]
@@ -1 +1 @@
1
- {"version":3,"names":["AppState","store","applyRoomsPreloadBatch","setUnreadSyncing","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","currentState","runHistoryPreloadScheduler","options","client","signal","concurrency","retryLimit","roomLimit","forceReload","aborted","dispatch","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","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"],"sourceRoot":"../../../src","sources":["helpers/historyPreloadScheduler.ts"],"mappings":";;AAAA,SAASA,QAAQ,QAAQ,cAAc;AAEvC,SAASC,KAAK,QAAQ,cAAc;AACpC,SAASC,sBAAsB,EAAEC,gBAAgB,QAAQ,yBAAyB;AAuBlF,MAAMC,mBAAmB,GAAG,CAAC;AAC7B;AACA;AACA;AACA,MAAMC,iBAAiB,GAAG,EAAE;AAC5B,MAAMC,mBAAmB,GAAG,CAAC;AAE7B,MAAMC,KAAK,GAAIC,EAAU,IAA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CAACf,QAAQ,CAAC,GAAGuC,MAAM;cACjE/B,KAAK,CAACmC,IAAI,CAAC;gBACT,GAAG5B,IAAI;gBACPf,QAAQ,EAAEqC,OAAO;gBACjBpC,OAAO,EAAEC,IAAI,CAACC,GAAG,CAAC,CAAC,GAAGuC;cACxB,CAAC,CAAC;YACJ,CAAC,MAAM;cACL9G,KAAK,CAACwD,QAAQ,CACZvD,sBAAsB,CAAC;gBACrB0D,KAAK,EAAE,CAAC;kBAAEnB,GAAG,EAAE2C,IAAI,CAAC3C,GAAG;kBAAE8C,mBAAmB,EAAE;gBAAQ,CAAC;cACzD,CAAC,CACH,CAAC;YACH;YACAN,qBAAqB,IAAI,CAAC;YAC1B,IAAIA,qBAAqB,IAAI,CAAC,EAAE;cAC9B,MAAM1E,KAAK,CAAC,GAAG,CAAC;cAChB0E,qBAAqB,GAAG,CAAC;YAC3B;UACF;QACF,CAAC,EAAE,CAAC;QAEJF,cAAc,CAACkC,GAAG,CAAC7B,IAAI,CAAC3C,GAAG,EAAEoD,IAAI,CAAC;QAClC,MAAMA,IAAI,CAACqB,OAAO,CAAC,MAAMnC,cAAc,CAACoC,MAAM,CAAC/B,IAAI,CAAC3C,GAAG,CAAC,CAAC;MAC3D,CAAC,CACH,CAAC;;MAED;MACA,MAAM,IAAIhC,OAAO,CAAE2G,CAAC,IAAKzG,UAAU,CAACyG,CAAC,EAAE,CAAC,CAAC,CAAC;IAC5C;EACA,CAAC,SAAS;IACRnH,KAAK,CAACwD,QAAQ,CAACtD,gBAAgB,CAAC,KAAK,CAAC,CAAC;EACzC;AACF,CAAC;AAED,eAAe6C,0BAA0B","ignoreList":[]}
1
+ {"version":3,"names":["AppState","store","applyRoomsPreloadBatch","setUnreadSyncing","RUNTIME_MESSAGE_LIMIT","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","currentState","runHistoryPreloadScheduler","options","client","signal","concurrency","retryLimit","roomLimit","forceReload","aborted","dispatch","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","all","queueIndex","findIndex","queued","splice","task","currentRoom","preState","get","fetchedMessages","getHistoryStanza","undefined","coalesceRoom","skipIfPreloaded","source","Error","nextRoom","combined","lastPageLen","extraPages","oldestId","idNum","older","simulatedStored","unreadCapped","retries","canRetry","jitter","floor","random","backoff","push","set","finally","delete","r"],"sourceRoot":"../../../src","sources":["helpers/historyPreloadScheduler.ts"],"mappings":";;AAAA,SAASA,QAAQ,QAAQ,cAAc;AAEvC,SAASC,KAAK,QAAQ,cAAc;AACpC,SACEC,sBAAsB,EACtBC,gBAAgB,EAChBC,qBAAqB,QAChB,yBAAyB;AAuBhC,MAAMC,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,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,IAAI,CAAC3C,GAAG,CAAC,CAAC;MAC3D,CAAC,CACH,CAAC;;MAED;MACA,MAAM,IAAIhC,OAAO,CAAEkH,CAAC,IAAKhH,UAAU,CAACgH,CAAC,EAAE,CAAC,CAAC,CAAC;IAC5C;EACA,CAAC,SAAS;IACR5H,KAAK,CAAC0D,QAAQ,CAACxD,gBAAgB,CAAC,KAAK,CAAC,CAAC;EACzC;AACF,CAAC;AAED,eAAe+C,0BAA0B","ignoreList":[]}
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
 
3
3
  import { setCurrentRoom, setIsLoading } from '../roomStore/roomsSlice';
4
- import { updatedChatLastTimestamps } from './updatedChatLastTimestamps';
5
4
  import { initRoomsPresence } from './initRoomsPresence';
6
5
  import { store } from '../roomStore';
6
+ import { refreshAuthTokensQuietly } from '../networking/authRefresh';
7
7
  const initXmppRooms = async (user, config, xmmpClient, rooms, roomJID) => {
8
8
  if (roomJID) {
9
9
  store.dispatch(setCurrentRoom({
@@ -39,16 +39,22 @@ const initXmppRooms = async (user, config, xmmpClient, rooms, roomJID) => {
39
39
  console.log(res);
40
40
  }
41
41
 
42
- //@ts-ignore
43
- const roomTimestampObject = await xmmpClient.getChatsPrivateStoreRequestStanza();
44
- updatedChatLastTimestamps(roomTimestampObject, store.dispatch);
42
+ // getChatsPrivateStoreRequestStanza hydrates redux itself
43
+ // (dispatch(applyPrivateStoreMarkers(...)) internally, clamped +
44
+ // forward-only) - do not also apply the raw return value here. That
45
+ // used to double-dispatch via updatedChatLastTimestamps' unconditional
46
+ // setLastViewedTimestamp, which has neither the forward-only guard
47
+ // nor the future-marker clamp, so it could silently re-clobber a
48
+ // value the clamp had just corrected (bug #38).
49
+ await xmmpClient.getChatsPrivateStoreRequestStanza();
45
50
  } else {
46
- //@ts-ignore
47
- const roomTimestampObject = await xmmpClient.getChatsPrivateStoreRequestStanza();
48
- updatedChatLastTimestamps(roomTimestampObject, store.dispatch);
51
+ await xmmpClient.getChatsPrivateStoreRequestStanza();
49
52
  }
50
53
  if (config?.refreshTokens?.enabled) {
51
- config?.refreshTokens?.refreshFunction?.();
54
+ // Was a bare call to the consumer-supplied refreshFunction, i.e. a
55
+ // rotation completely outside the SDK's lock. Routed through the
56
+ // one rotation point, which calls that same function internally.
57
+ refreshAuthTokensQuietly();
52
58
  }
53
59
  } catch (error) {
54
60
  console.error(error);
@@ -1 +1 @@
1
- {"version":3,"names":["setCurrentRoom","setIsLoading","updatedChatLastTimestamps","initRoomsPresence","store","initXmppRooms","user","config","xmmpClient","rooms","roomJID","dispatch","defaultWallet","walletAddress","console","log","Object","keys","length","newArch","res","getRoomsStanza","roomTimestampObject","getChatsPrivateStoreRequestStanza","refreshTokens","enabled","refreshFunction","error","loading"],"sourceRoot":"../../../src","sources":["helpers/initXmppRooms.tsx"],"mappings":";;AAAA,SAASA,cAAc,EAAEC,YAAY,QAAQ,yBAAyB;AACtE,SAASC,yBAAyB,QAAQ,6BAA6B;AACvE,SAASC,iBAAiB,QAAQ,qBAAqB;AAGvD,SAASC,KAAK,QAAQ,cAAc;AAEpC,MAAMC,aAAa,GAAG,MAAAA,CACpBC,IAAU,EACVC,MAAe,EACfC,UAAsB,EACtBC,KAAgC,EAChCC,OAAgB,KACb;EACH,IAAIA,OAAO,EAAE;IACXN,KAAK,CAACO,QAAQ,CAACX,cAAc,CAAC;MAAEU,OAAO,EAAEA;IAAQ,CAAC,CAAC,CAAC;EACtD;EAEA,IAAI;IACF,IAAI,CAACJ,IAAI,CAACM,aAAa,IAAI,CAACN,IAAI,CAACM,aAAa,CAACC,aAAa,EAAE;MAC5DC,OAAO,CAACC,GAAG,CAAC,gBAAgB,CAAC;MAC7B;IACF;IAEA,IAAI,CAACP,UAAU,EAAE;MACfM,OAAO,CAACC,GAAG,CAAC,iCAAiC,CAAC;MAE9C,IAAIN,KAAK,IAAIO,MAAM,CAACC,IAAI,CAACR,KAAK,CAAC,CAACS,MAAM,GAAG,CAAC,EAAE;QAC1C,MAAMf,iBAAiB,CAACK,UAAU,EAAEC,KAAK,CAAC;MAC5C,CAAC,MAAM;QACL,IAAIF,MAAM,EAAEY,OAAO,EAAE;UACnB;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;QACF;QACA,MAAMC,GAAG,GAAG,MAAOZ,UAAU,CAAuBa,cAAc,CAAC,CAAC;QACpEP,OAAO,CAACC,GAAG,CAACK,GAAG,CAAC;MAClB;;MAEA;MACA,MAAME,mBAAqD,GACzD,MAAOd,UAAU,CAAuBe,iCAAiC,CAAC,CAAC;MAC7ErB,yBAAyB,CAACoB,mBAAmB,EAAElB,KAAK,CAACO,QAAQ,CAAC;IAChE,CAAC,MAAM;MACL;MACA,MAAMW,mBAAqD,GACzD,MAAMd,UAAU,CAACe,iCAAiC,CAAC,CAAC;MACtDrB,yBAAyB,CAACoB,mBAAmB,EAAElB,KAAK,CAACO,QAAQ,CAAC;IAChE;IAEA,IAAIJ,MAAM,EAAEiB,aAAa,EAAEC,OAAO,EAAE;MAClClB,MAAM,EAAEiB,aAAa,EAAEE,eAAe,GAAG,CAAC;IAC5C;EACF,CAAC,CAAC,OAAOC,KAAK,EAAE;IACdb,OAAO,CAACa,KAAK,CAACA,KAAK,CAAC;EACtB,CAAC,SAAS;IACRvB,KAAK,CAACO,QAAQ,CAACV,YAAY,CAAC;MAAE2B,OAAO,EAAE;IAAM,CAAC,CAAC,CAAC;EAClD;AACF,CAAC;AAED,eAAevB,aAAa","ignoreList":[]}
1
+ {"version":3,"names":["setCurrentRoom","setIsLoading","initRoomsPresence","store","refreshAuthTokensQuietly","initXmppRooms","user","config","xmmpClient","rooms","roomJID","dispatch","defaultWallet","walletAddress","console","log","Object","keys","length","newArch","res","getRoomsStanza","getChatsPrivateStoreRequestStanza","refreshTokens","enabled","error","loading"],"sourceRoot":"../../../src","sources":["helpers/initXmppRooms.tsx"],"mappings":";;AAAA,SAASA,cAAc,EAAEC,YAAY,QAAQ,yBAAyB;AACtE,SAASC,iBAAiB,QAA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AACW,KAAK,CAACA,KAAK,CAAC;EACtB,CAAC,SAAS;IACRtB,KAAK,CAACQ,QAAQ,CAACV,YAAY,CAAC;MAAEyB,OAAO,EAAE;IAAM,CAAC,CAAC,CAAC;EAClD;AACF,CAAC;AAED,eAAerB,aAAa","ignoreList":[]}
@@ -1,6 +1,38 @@
1
1
  "use strict";
2
2
 
3
3
  import { isDateAfter, isDateBefore } from './dateComparison';
4
+ import { msgSortableMs } from './msgSortableMs';
5
+
6
+ // Robustly resolve a caller-supplied read marker to epoch milliseconds.
7
+ // Callers pass a plain number (the redux read boundary, or a room's
8
+ // lastViewedTimestamp), a Date object (older call sites), or occasionally
9
+ // a numeric string. These are NOT interchangeable through the Date
10
+ // constructor: `new Date(1757000000123)` (a number) reads as epoch-ms,
11
+ // but `new Date("1757000000123")` (a string) is parsed as a date STRING
12
+ // - a bare 13-digit string matches no recognized date format, so the
13
+ // result is silently Invalid Date and every comparison against it is
14
+ // `false`. Try Number() first so a numeric string/number is read as
15
+ // epoch-ms; only fall through to Date parsing for genuine date/ISO
16
+ // strings (e.g. a Date object's own `.toString()`). Never falls back to
17
+ // `Date.now()` - a marker we can't resolve is treated as "no marker",
18
+ // not "now" (bug #38).
19
+ function resolveMarkerMs(marker) {
20
+ if (marker == null) {
21
+ return 0;
22
+ }
23
+ if (typeof marker === 'number') {
24
+ return Number.isFinite(marker) ? marker : 0;
25
+ }
26
+ const raw = marker.toString();
27
+ if (raw.trim() !== '') {
28
+ const asNumber = Number(raw);
29
+ if (Number.isFinite(asNumber)) {
30
+ return asNumber;
31
+ }
32
+ }
33
+ const parsed = Date.parse(raw);
34
+ return Number.isFinite(parsed) ? parsed : 0;
35
+ }
4
36
  function deepMerge(target, source) {
5
37
  for (const key in source) {
6
38
  if (source[key] === undefined) {
@@ -62,21 +94,32 @@ export function insertMessageWithDelimiter(roomMessages, message, lastViewedTime
62
94
  } else {
63
95
  roomMessages.push(message);
64
96
  }
65
- if (lastViewedTimestamp && !roomMessages.some(msg => msg.id === 'delimiter-new') && isDateAfter(newMessageDate.toString(), lastViewedTimestamp.toString())) {
66
- const delimiterIndex = roomMessages.findIndex(msg => isDateAfter(msg.date?.toString() ?? '', lastViewedTimestamp.toString()));
97
+ const lastViewedMs = resolveMarkerMs(lastViewedTimestamp);
98
+ const newMessageMs = msgSortableMs(message);
99
+ if (lastViewedMs > 0 && newMessageMs > lastViewedMs && !roomMessages.some(msg => msg.id === 'delimiter-new')) {
100
+ // Find the first message STRICTLY newer than the marker, using the
101
+ // SAME timestamp source (msgSortableMs - the server id-encoded ms)
102
+ // as the unread middleware and countNewerMessages use to decide
103
+ // what counts as unread. Comparing against a DIFFERENT source (the
104
+ // old code compared `msg.date` strings) risks the boundary message
105
+ // itself landing on the wrong side of the cut: since bug #38 the
106
+ // marker can equal a real message's own timestamp exactly, and any
107
+ // drift between `date` and the id-encoded ms - or a raw numeric
108
+ // marker silently producing an Invalid Date via the Date
109
+ // constructor's string-parsing path - could count that message as
110
+ // unread, pushing the divider one message too early (ABOVE the
111
+ // last read message instead of directly below it). Customer #42.
112
+ const delimiterIndex = roomMessages.findIndex(msg => msg.id !== 'delimiter-new' && msgSortableMs(msg) > lastViewedMs);
67
113
  if (delimiterIndex !== -1) {
68
114
  // The divider's date is what ORDERS it: roomsSlice re-sorts every
69
115
  // merged page by timestamp (see `byMs`), so a divider stamped with
70
- // `new Date()` — i.e. now — sorted past every real message and
116
+ // `new Date()` (i.e. now) sorted past every real message and
71
117
  // rendered at the very bottom, BELOW the new messages it is
72
118
  // supposed to introduce. Anchor it a hair before the first unread
73
119
  // instead, which is where it belongs and where any later sort keeps
74
- // it. Derived from that message rather than from
75
- // lastViewedTimestamp so it works whatever format the caller passes.
76
- const firstUnreadMs = Date.parse(String(roomMessages[delimiterIndex]?.date ?? ''));
77
- const rawLastViewed = lastViewedTimestamp.toString();
78
- const lastViewedMs = Date.parse(rawLastViewed) || Number(rawLastViewed) || Date.now();
79
- const anchorMs = Number.isFinite(firstUnreadMs) ? firstUnreadMs - 1 : lastViewedMs;
120
+ // it.
121
+ const firstUnreadMs = msgSortableMs(roomMessages[delimiterIndex]);
122
+ const anchorMs = firstUnreadMs > 0 ? firstUnreadMs - 1 : lastViewedMs;
80
123
  roomMessages.splice(delimiterIndex, 0, {
81
124
  id: 'delimiter-new',
82
125
  user: {
@@ -1 +1 @@
1
- {"version":3,"names":["isDateAfter","isDateBefore","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","toString","index","push","some","delimiterIndex","firstUnreadMs","Date","parse","String","rawLastViewed","lastViewedMs","Number","now","anchorMs","isFinite","splice","name","token","refreshToken","toISOString","body","roomJid","unshift","i"],"sourceRoot":"../../../src","sources":["helpers/insertMessageWithDelimiter.ts"],"mappings":";;AACA,SAASA,WAAW,EAAEC,YAAY,QAAQ,kBAAkB;AAE5D,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,CAAC,KAAK,QAAQ,IAC/B,CAACE,KAAK,CAACC,OAAO,CAACJ,MAAM,CAACC,GAAG,CAAC,CAAC,EAC3B;MACAF,MAAM,CAACE,GAAG,CAAC,GAAGH,SAAS,CAACC,MAAM,CAACE,GAAG,CAAC,IAAI,CAAC,CAAC,EAAED,MAAM,CAACC,GAAG,CAAC,CAAC;IACzD,CAAC,MAAM;MACLF,MAAM,CAACE,GAAG,CAAC,GAAGD,MAAM,CAACC,GAAG,CAAC;IAC3B;EACF;EACA,OAAOF,MAAM;AACf;AAEA,OAAO,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G,CAAC,GACjBK,YAAY;QAEhB5B,YAAY,CAACiC,MAAM,CAACX,cAAc,EAAE,CAAC,EAAE;UACrChB,EAAE,EAAE,eAAe;UACnBI,IAAI,EAAE;YACJJ,EAAE,EAAE,QAAQ;YACZ4B,IAAI,EAAEtC,SAAS;YACfuC,KAAK,EAAE,EAAE;YACTC,YAAY,EAAE;UAChB,CAAC;UACDtB,IAAI,EAAE,IAAIU,IAAI,CAACO,QAAQ,CAAC,CAACM,WAAW,CAAC,CAAC;UACtCC,IAAI,EAAE,cAAc;UACpBC,OAAO,EAAE;QACX,CAAC,CAAC;MACJ;IACA;EACJ,CAAC,MAAM,IACLhD,YAAY,CAACsB,cAAc,CAACK,QAAQ,CAAC,CAAC,EAAED,YAAY,EAAEH,IAAI,EAAEI,QAAQ,CAAC,CAAC,IAAI,EAAE,CAAC,EAC7E;IACAlB,YAAY,CAACwC,OAAO,CAACvC,OAAO,CAAC;EAC/B,CAAC,MAAM;IACL,KAAK,IAAIwC,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGzC,YAAY,CAACgB,MAAM,EAAEyB,CAAC,EAAE,EAAE;MAC5C,IACElD,YAAY,CAACsB,cAAc,CAACK,QAAQ,CAAC,CAAC,EAAElB,YAAY,CAACyC,CAAC,CAAC,CAAC3B,IAAI,EAAEI,QAAQ,CAAC,CAAC,IAAI,EAAE,CAAC,EAC/E;QACAlB,YAAY,CAACiC,MAAM,CAACQ,CAAC,EAAE,CAAC,EAAExC,OAAO,CAAC;QAClC;MACF;IACF;EACF;AACF","ignoreList":[]}
1
+ {"version":3,"names":["isDateAfter","isDateBefore","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","index","push","lastViewedMs","newMessageMs","some","delimiterIndex","firstUnreadMs","anchorMs","splice","name","token","refreshToken","toISOString","body","roomJid","unshift","i"],"sourceRoot":"../../../src","sources":["helpers/insertMessageWithDelimiter.ts"],"mappings":";;AACA,SAASA,WAAW,EAAEC,YAAY,QAAQ,kBAAkB;AAC5D,SAASC,aAAa,QAAQ,iBAAiB;;AAE/C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,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,CAACC,QAAQ,CAACK,MAAM,CAAC,GAAGA,MAAM,GAAG,CAAC;AAC7C;AAEA,SAASG,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,CAAC,KAAK,QAAQ,IAC/B,CAACE,KAAK,CAACC,OAAO,CAACJ,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