@ethora/chat-component-rn 26.8.5 → 26.8.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +26 -0
- package/README.md +95 -0
- package/lib/commonjs/assets/emojiData.js +40 -0
- package/lib/commonjs/assets/emojiData.js.map +1 -0
- package/lib/commonjs/assets/icons.js +5 -3
- package/lib/commonjs/assets/icons.js.map +1 -1
- package/lib/commonjs/components/MainComponents/ChatHeader.js +35 -15
- package/lib/commonjs/components/MainComponents/ChatHeader.js.map +1 -1
- package/lib/commonjs/components/MainComponents/ChatRoom.js +33 -24
- package/lib/commonjs/components/MainComponents/ChatRoom.js.map +1 -1
- package/lib/commonjs/components/MainComponents/ChatWrapper.js +22 -16
- package/lib/commonjs/components/MainComponents/ChatWrapper.js.map +1 -1
- package/lib/commonjs/components/MainComponents/EncryptedSendNotice.js +47 -0
- package/lib/commonjs/components/MainComponents/EncryptedSendNotice.js.map +1 -0
- package/lib/commonjs/components/MainComponents/EncryptionCard.js +286 -0
- package/lib/commonjs/components/MainComponents/EncryptionCard.js.map +1 -0
- package/lib/commonjs/components/MainComponents/MediaMessage.js +7 -0
- package/lib/commonjs/components/MainComponents/MediaMessage.js.map +1 -1
- package/lib/commonjs/components/MainComponents/MessageContainer.js +4 -12
- package/lib/commonjs/components/MainComponents/MessageContainer.js.map +1 -1
- package/lib/commonjs/components/MainComponents/MessageList.js +110 -35
- package/lib/commonjs/components/MainComponents/MessageList.js.map +1 -1
- package/lib/commonjs/components/MainComponents/ReduxWrapper.js +5 -0
- package/lib/commonjs/components/MainComponents/ReduxWrapper.js.map +1 -1
- package/lib/commonjs/components/MainComponents/RoomList.js +32 -29
- package/lib/commonjs/components/MainComponents/RoomList.js.map +1 -1
- package/lib/commonjs/components/MainComponents/RoomStack.js +133 -65
- package/lib/commonjs/components/MainComponents/RoomStack.js.map +1 -1
- package/lib/commonjs/components/MainComponents/SealedAttachment.js +231 -0
- package/lib/commonjs/components/MainComponents/SealedAttachment.js.map +1 -0
- package/lib/commonjs/components/MainComponents/SystemMessage.js +6 -2
- package/lib/commonjs/components/MainComponents/SystemMessage.js.map +1 -1
- package/lib/commonjs/components/MessageBubble/Avatar.js +5 -1
- package/lib/commonjs/components/MessageBubble/Avatar.js.map +1 -1
- package/lib/commonjs/components/MessageBubble/BottomReplyContainer.js +18 -21
- package/lib/commonjs/components/MessageBubble/BottomReplyContainer.js.map +1 -1
- package/lib/commonjs/components/MessageBubble/EmojiPickerSheet.js +447 -0
- package/lib/commonjs/components/MessageBubble/EmojiPickerSheet.js.map +1 -0
- package/lib/commonjs/components/MessageBubble/Message.js +264 -136
- package/lib/commonjs/components/MessageBubble/Message.js.map +1 -1
- package/lib/commonjs/components/MessageBubble/MessageInteractions.js +215 -13
- package/lib/commonjs/components/MessageBubble/MessageInteractions.js.map +1 -1
- package/lib/commonjs/components/MessageBubble/MessageReaction.js +113 -94
- package/lib/commonjs/components/MessageBubble/MessageReaction.js.map +1 -1
- package/lib/commonjs/components/MessageBubble/MessageReply.js +66 -24
- package/lib/commonjs/components/MessageBubble/MessageReply.js.map +1 -1
- package/lib/commonjs/components/Modals/ChatProfileModal/ChatProfileModal.js +7 -4
- package/lib/commonjs/components/Modals/ChatProfileModal/ChatProfileModal.js.map +1 -1
- package/lib/commonjs/components/Modals/FilePreviewModal/FilePreviewModal.js +159 -16
- package/lib/commonjs/components/Modals/FilePreviewModal/FilePreviewModal.js.map +1 -1
- package/lib/commonjs/components/Modals/FilePreviewModal/PdfView.js +4 -0
- package/lib/commonjs/components/Modals/FilePreviewModal/PdfView.js.map +1 -1
- package/lib/commonjs/components/Modals/Modal/SwipeBackLayer.js +76 -44
- package/lib/commonjs/components/Modals/Modal/SwipeBackLayer.js.map +1 -1
- package/lib/commonjs/components/Modals/UserProfileModal/UserProfileModal.js +29 -6
- package/lib/commonjs/components/Modals/UserProfileModal/UserProfileModal.js.map +1 -1
- package/lib/commonjs/components/Modals/UserSettingsModal/UserSettingsModal.js +5 -1
- package/lib/commonjs/components/Modals/UserSettingsModal/UserSettingsModal.js.map +1 -1
- package/lib/commonjs/components/RoomComponents/ChatRoomItem.js +37 -13
- package/lib/commonjs/components/RoomComponents/ChatRoomItem.js.map +1 -1
- package/lib/commonjs/components/RoomComponents/LastMessageItem.js +6 -0
- package/lib/commonjs/components/RoomComponents/LastMessageItem.js.map +1 -1
- package/lib/commonjs/components/RoomComponents/styled/LastAudioMessage.js +2 -2
- package/lib/commonjs/components/RoomComponents/styled/LastAudioMessage.js.map +1 -1
- package/lib/commonjs/components/RoomComponents/styled/LastMessageEmoji.js +8 -9
- package/lib/commonjs/components/RoomComponents/styled/LastMessageEmoji.js.map +1 -1
- package/lib/commonjs/components/RoomComponents/styled/LastMessageFile.js +4 -6
- package/lib/commonjs/components/RoomComponents/styled/LastMessageFile.js.map +1 -1
- package/lib/commonjs/components/RoomComponents/styled/LastMessagePhoto.js +2 -2
- package/lib/commonjs/components/RoomComponents/styled/LastMessagePhoto.js.map +1 -1
- package/lib/commonjs/components/RoomComponents/styled/LastMessageSealed.js +41 -0
- package/lib/commonjs/components/RoomComponents/styled/LastMessageSealed.js.map +1 -0
- package/lib/commonjs/components/RoomComponents/styled/LastMessageVideo.js +2 -2
- package/lib/commonjs/components/RoomComponents/styled/LastMessageVideo.js.map +1 -1
- package/lib/commonjs/components/Thread/ThreadWrapper.js +273 -152
- package/lib/commonjs/components/Thread/ThreadWrapper.js.map +1 -1
- package/lib/commonjs/components/UsersList/UsersList.js +2 -1
- package/lib/commonjs/components/UsersList/UsersList.js.map +1 -1
- package/lib/commonjs/components/styled/DateLabel.js +6 -3
- package/lib/commonjs/components/styled/DateLabel.js.map +1 -1
- package/lib/commonjs/components/styled/SendInput.js +4 -2
- package/lib/commonjs/components/styled/SendInput.js.map +1 -1
- package/lib/commonjs/context/MessageNotificationContext.js +188 -9
- package/lib/commonjs/context/MessageNotificationContext.js.map +1 -1
- package/lib/commonjs/context/xmppProvider.js +22 -7
- package/lib/commonjs/context/xmppProvider.js.map +1 -1
- package/lib/commonjs/e2ee/crypto.js +207 -0
- package/lib/commonjs/e2ee/crypto.js.map +1 -0
- package/lib/commonjs/e2ee/deviceStore.js +84 -0
- package/lib/commonjs/e2ee/deviceStore.js.map +1 -0
- package/lib/commonjs/e2ee/fileCipher.js +95 -0
- package/lib/commonjs/e2ee/fileCipher.js.map +1 -0
- package/lib/commonjs/e2ee/fileEnvelope.js +79 -0
- package/lib/commonjs/e2ee/fileEnvelope.js.map +1 -0
- package/lib/commonjs/e2ee/index.js +210 -0
- package/lib/commonjs/e2ee/index.js.map +1 -0
- package/lib/commonjs/e2ee/limits.js +9 -0
- package/lib/commonjs/e2ee/limits.js.map +1 -0
- package/lib/commonjs/e2ee/ns.js +8 -0
- package/lib/commonjs/e2ee/ns.js.map +1 -0
- package/lib/commonjs/e2ee/omemo.js +622 -0
- package/lib/commonjs/e2ee/omemo.js.map +1 -0
- package/lib/commonjs/e2ee/protobuf.js +149 -0
- package/lib/commonjs/e2ee/protobuf.js.map +1 -0
- package/lib/commonjs/e2ee/ratchet.js +238 -0
- package/lib/commonjs/e2ee/ratchet.js.map +1 -0
- package/lib/commonjs/e2ee/sealedBody.js +23 -0
- package/lib/commonjs/e2ee/sealedBody.js.map +1 -0
- package/lib/commonjs/e2ee/sealedFiles.js +174 -0
- package/lib/commonjs/e2ee/sealedFiles.js.map +1 -0
- package/lib/commonjs/e2ee/send.js +54 -0
- package/lib/commonjs/e2ee/send.js.map +1 -0
- package/lib/commonjs/e2ee/stanza.js +114 -0
- package/lib/commonjs/e2ee/stanza.js.map +1 -0
- package/lib/commonjs/e2ee/store.js +43 -0
- package/lib/commonjs/e2ee/store.js.map +1 -0
- package/lib/commonjs/helpers/accountName.js +23 -0
- package/lib/commonjs/helpers/accountName.js.map +1 -0
- package/lib/commonjs/helpers/createMessageFromXml.js +19 -4
- package/lib/commonjs/helpers/createMessageFromXml.js.map +1 -1
- package/lib/commonjs/helpers/createRoomFromApi.js +36 -2
- package/lib/commonjs/helpers/createRoomFromApi.js.map +1 -1
- package/lib/commonjs/helpers/createUserNameFromSetUser.js +2 -1
- package/lib/commonjs/helpers/createUserNameFromSetUser.js.map +1 -1
- package/lib/commonjs/helpers/displayName.js +16 -0
- package/lib/commonjs/helpers/displayName.js.map +1 -0
- package/lib/commonjs/helpers/emoji.js +51 -0
- package/lib/commonjs/helpers/emoji.js.map +1 -0
- package/lib/commonjs/helpers/haptics.js +29 -0
- package/lib/commonjs/helpers/haptics.js.map +1 -0
- package/lib/commonjs/helpers/historyPreloadScheduler.js +32 -66
- package/lib/commonjs/helpers/historyPreloadScheduler.js.map +1 -1
- package/lib/commonjs/helpers/insertMessageWithDelimiter.js +21 -12
- package/lib/commonjs/helpers/insertMessageWithDelimiter.js.map +1 -1
- package/lib/commonjs/helpers/mamReactions.js +57 -0
- package/lib/commonjs/helpers/mamReactions.js.map +1 -0
- package/lib/commonjs/helpers/parseMessageReference.js +42 -0
- package/lib/commonjs/helpers/parseMessageReference.js.map +1 -0
- package/lib/commonjs/helpers/persistCrypto.js +5 -0
- package/lib/commonjs/helpers/persistCrypto.js.map +1 -1
- package/lib/commonjs/helpers/reactionsConfig.js +17 -0
- package/lib/commonjs/helpers/reactionsConfig.js.map +1 -0
- package/lib/commonjs/helpers/secureKeyValue.js +20 -0
- package/lib/commonjs/helpers/secureKeyValue.js.map +1 -1
- package/lib/commonjs/helpers/updateMessagesTillLast.js +17 -2
- package/lib/commonjs/helpers/updateMessagesTillLast.js.map +1 -1
- package/lib/commonjs/helpers/videoCache.js +136 -0
- package/lib/commonjs/helpers/videoCache.js.map +1 -0
- package/lib/commonjs/hooks/useHeapSender.js +3 -1
- package/lib/commonjs/hooks/useHeapSender.js.map +1 -1
- package/lib/commonjs/hooks/useLogout.js +8 -0
- package/lib/commonjs/hooks/useLogout.js.map +1 -1
- package/lib/commonjs/hooks/useMessageHeapState.js +3 -2
- package/lib/commonjs/hooks/useMessageHeapState.js.map +1 -1
- package/lib/commonjs/hooks/useRoomInitialization.js +16 -7
- package/lib/commonjs/hooks/useRoomInitialization.js.map +1 -1
- package/lib/commonjs/hooks/useSendMessage.js +85 -15
- package/lib/commonjs/hooks/useSendMessage.js.map +1 -1
- package/lib/commonjs/hooks/useUnreadMessagesCounter.js +1 -1
- package/lib/commonjs/hooks/useUnreadMessagesCounter.js.map +1 -1
- package/lib/commonjs/i18n/strings.js +180 -0
- package/lib/commonjs/i18n/strings.js.map +1 -1
- package/lib/commonjs/main.js +13 -0
- package/lib/commonjs/main.js.map +1 -1
- package/lib/commonjs/networking/api-requests/auth.api.js +4 -1
- package/lib/commonjs/networking/api-requests/auth.api.js.map +1 -1
- package/lib/commonjs/networking/api-requests/rooms.api.js +111 -17
- package/lib/commonjs/networking/api-requests/rooms.api.js.map +1 -1
- package/lib/commonjs/networking/stanzaHandlers.js +106 -50
- package/lib/commonjs/networking/stanzaHandlers.js.map +1 -1
- package/lib/commonjs/networking/xmpp/getHistory.xmpp.js +29 -74
- package/lib/commonjs/networking/xmpp/getHistory.xmpp.js.map +1 -1
- package/lib/commonjs/networking/xmpp/handleStanzas.xmpp.js +44 -0
- package/lib/commonjs/networking/xmpp/handleStanzas.xmpp.js.map +1 -1
- package/lib/commonjs/networking/xmpp/mamRouter.js +186 -0
- package/lib/commonjs/networking/xmpp/mamRouter.js.map +1 -0
- package/lib/commonjs/networking/xmpp/presenceInRoom.xmpp.js +41 -4
- package/lib/commonjs/networking/xmpp/presenceInRoom.xmpp.js.map +1 -1
- package/lib/commonjs/networking/xmpp/sendMediaMessage.xmpp.js +16 -3
- package/lib/commonjs/networking/xmpp/sendMediaMessage.xmpp.js.map +1 -1
- package/lib/commonjs/networking/xmpp/sendTextMessage.xmpp.js +13 -6
- package/lib/commonjs/networking/xmpp/sendTextMessage.xmpp.js.map +1 -1
- package/lib/commonjs/networking/xmpp/sendTextMessageWithTranslateTag.xmpp.js +14 -6
- package/lib/commonjs/networking/xmpp/sendTextMessageWithTranslateTag.xmpp.js.map +1 -1
- package/lib/commonjs/networking/xmppClient.js +104 -23
- package/lib/commonjs/networking/xmppClient.js.map +1 -1
- package/lib/commonjs/roomStore/Middleware/newMessageMidlleware.js +29 -34
- package/lib/commonjs/roomStore/Middleware/newMessageMidlleware.js.map +1 -1
- package/lib/commonjs/roomStore/Middleware/perfMiddleware.js +51 -0
- package/lib/commonjs/roomStore/Middleware/perfMiddleware.js.map +1 -0
- package/lib/commonjs/roomStore/Middleware/reactionsMiddleware.js +66 -43
- package/lib/commonjs/roomStore/Middleware/reactionsMiddleware.js.map +1 -1
- package/lib/commonjs/roomStore/Middleware/unreadMidlleware.js +88 -68
- package/lib/commonjs/roomStore/Middleware/unreadMidlleware.js.map +1 -1
- package/lib/commonjs/roomStore/index.js +18 -14
- package/lib/commonjs/roomStore/index.js.map +1 -1
- package/lib/commonjs/roomStore/persistBackend.js +93 -0
- package/lib/commonjs/roomStore/persistBackend.js.map +1 -0
- package/lib/commonjs/roomStore/persistence.js +253 -51
- package/lib/commonjs/roomStore/persistence.js.map +1 -1
- package/lib/commonjs/roomStore/roomsSlice.js +282 -136
- package/lib/commonjs/roomStore/roomsSlice.js.map +1 -1
- package/lib/commonjs/theme/theme.js +3 -0
- package/lib/commonjs/theme/theme.js.map +1 -1
- package/lib/commonjs/utils/devLogger.js +14 -0
- package/lib/commonjs/utils/devLogger.js.map +1 -1
- package/lib/commonjs/version.js +1 -1
- package/lib/module/assets/emojiData.js +36 -0
- package/lib/module/assets/emojiData.js.map +1 -0
- package/lib/module/assets/icons.js +4 -2
- package/lib/module/assets/icons.js.map +1 -1
- package/lib/module/components/MainComponents/ChatHeader.js +37 -17
- package/lib/module/components/MainComponents/ChatHeader.js.map +1 -1
- package/lib/module/components/MainComponents/ChatRoom.js +34 -25
- package/lib/module/components/MainComponents/ChatRoom.js.map +1 -1
- package/lib/module/components/MainComponents/ChatWrapper.js +23 -17
- package/lib/module/components/MainComponents/ChatWrapper.js.map +1 -1
- package/lib/module/components/MainComponents/EncryptedSendNotice.js +42 -0
- package/lib/module/components/MainComponents/EncryptedSendNotice.js.map +1 -0
- package/lib/module/components/MainComponents/EncryptionCard.js +281 -0
- package/lib/module/components/MainComponents/EncryptionCard.js.map +1 -0
- package/lib/module/components/MainComponents/MediaMessage.js +7 -0
- package/lib/module/components/MainComponents/MediaMessage.js.map +1 -1
- package/lib/module/components/MainComponents/MessageContainer.js +7 -14
- package/lib/module/components/MainComponents/MessageContainer.js.map +1 -1
- package/lib/module/components/MainComponents/MessageList.js +110 -35
- package/lib/module/components/MainComponents/MessageList.js.map +1 -1
- package/lib/module/components/MainComponents/ReduxWrapper.js +5 -0
- package/lib/module/components/MainComponents/ReduxWrapper.js.map +1 -1
- package/lib/module/components/MainComponents/RoomList.js +32 -29
- package/lib/module/components/MainComponents/RoomList.js.map +1 -1
- package/lib/module/components/MainComponents/RoomStack.js +131 -63
- package/lib/module/components/MainComponents/RoomStack.js.map +1 -1
- package/lib/module/components/MainComponents/SealedAttachment.js +224 -0
- package/lib/module/components/MainComponents/SealedAttachment.js.map +1 -0
- package/lib/module/components/MainComponents/SystemMessage.js +6 -2
- package/lib/module/components/MainComponents/SystemMessage.js.map +1 -1
- package/lib/module/components/MessageBubble/Avatar.js +5 -1
- package/lib/module/components/MessageBubble/Avatar.js.map +1 -1
- package/lib/module/components/MessageBubble/BottomReplyContainer.js +19 -22
- package/lib/module/components/MessageBubble/BottomReplyContainer.js.map +1 -1
- package/lib/module/components/MessageBubble/EmojiPickerSheet.js +438 -0
- package/lib/module/components/MessageBubble/EmojiPickerSheet.js.map +1 -0
- package/lib/module/components/MessageBubble/Message.js +269 -140
- package/lib/module/components/MessageBubble/Message.js.map +1 -1
- package/lib/module/components/MessageBubble/MessageInteractions.js +217 -15
- package/lib/module/components/MessageBubble/MessageInteractions.js.map +1 -1
- package/lib/module/components/MessageBubble/MessageReaction.js +115 -94
- package/lib/module/components/MessageBubble/MessageReaction.js.map +1 -1
- package/lib/module/components/MessageBubble/MessageReply.js +65 -24
- package/lib/module/components/MessageBubble/MessageReply.js.map +1 -1
- package/lib/module/components/Modals/ChatProfileModal/ChatProfileModal.js +7 -4
- package/lib/module/components/Modals/ChatProfileModal/ChatProfileModal.js.map +1 -1
- package/lib/module/components/Modals/FilePreviewModal/FilePreviewModal.js +161 -18
- package/lib/module/components/Modals/FilePreviewModal/FilePreviewModal.js.map +1 -1
- package/lib/module/components/Modals/FilePreviewModal/PdfView.js +4 -0
- package/lib/module/components/Modals/FilePreviewModal/PdfView.js.map +1 -1
- package/lib/module/components/Modals/Modal/SwipeBackLayer.js +76 -44
- package/lib/module/components/Modals/Modal/SwipeBackLayer.js.map +1 -1
- package/lib/module/components/Modals/UserProfileModal/UserProfileModal.js +32 -8
- package/lib/module/components/Modals/UserProfileModal/UserProfileModal.js.map +1 -1
- package/lib/module/components/Modals/UserSettingsModal/UserSettingsModal.js +4 -0
- package/lib/module/components/Modals/UserSettingsModal/UserSettingsModal.js.map +1 -1
- package/lib/module/components/RoomComponents/ChatRoomItem.js +37 -13
- package/lib/module/components/RoomComponents/ChatRoomItem.js.map +1 -1
- package/lib/module/components/RoomComponents/LastMessageItem.js +6 -0
- package/lib/module/components/RoomComponents/LastMessageItem.js.map +1 -1
- package/lib/module/components/RoomComponents/styled/LastAudioMessage.js +2 -2
- package/lib/module/components/RoomComponents/styled/LastAudioMessage.js.map +1 -1
- package/lib/module/components/RoomComponents/styled/LastMessageEmoji.js +8 -9
- package/lib/module/components/RoomComponents/styled/LastMessageEmoji.js.map +1 -1
- package/lib/module/components/RoomComponents/styled/LastMessageFile.js +4 -6
- package/lib/module/components/RoomComponents/styled/LastMessageFile.js.map +1 -1
- package/lib/module/components/RoomComponents/styled/LastMessagePhoto.js +2 -2
- package/lib/module/components/RoomComponents/styled/LastMessagePhoto.js.map +1 -1
- package/lib/module/components/RoomComponents/styled/LastMessageSealed.js +36 -0
- package/lib/module/components/RoomComponents/styled/LastMessageSealed.js.map +1 -0
- package/lib/module/components/RoomComponents/styled/LastMessageVideo.js +2 -2
- package/lib/module/components/RoomComponents/styled/LastMessageVideo.js.map +1 -1
- package/lib/module/components/Thread/ThreadWrapper.js +273 -153
- package/lib/module/components/Thread/ThreadWrapper.js.map +1 -1
- package/lib/module/components/UsersList/UsersList.js +2 -1
- package/lib/module/components/UsersList/UsersList.js.map +1 -1
- package/lib/module/components/styled/DateLabel.js +6 -3
- package/lib/module/components/styled/DateLabel.js.map +1 -1
- package/lib/module/components/styled/SendInput.js +4 -2
- package/lib/module/components/styled/SendInput.js.map +1 -1
- package/lib/module/context/MessageNotificationContext.js +190 -11
- package/lib/module/context/MessageNotificationContext.js.map +1 -1
- package/lib/module/context/xmppProvider.js +22 -7
- package/lib/module/context/xmppProvider.js.map +1 -1
- package/lib/module/e2ee/crypto.js +170 -0
- package/lib/module/e2ee/crypto.js.map +1 -0
- package/lib/module/e2ee/deviceStore.js +77 -0
- package/lib/module/e2ee/deviceStore.js.map +1 -0
- package/lib/module/e2ee/fileCipher.js +90 -0
- package/lib/module/e2ee/fileCipher.js.map +1 -0
- package/lib/module/e2ee/fileEnvelope.js +66 -0
- package/lib/module/e2ee/fileEnvelope.js.map +1 -0
- package/lib/module/e2ee/index.js +185 -0
- package/lib/module/e2ee/index.js.map +1 -0
- package/lib/module/e2ee/limits.js +5 -0
- package/lib/module/e2ee/limits.js.map +1 -0
- package/lib/module/e2ee/ns.js +4 -0
- package/lib/module/e2ee/ns.js.map +1 -0
- package/lib/module/e2ee/omemo.js +610 -0
- package/lib/module/e2ee/omemo.js.map +1 -0
- package/lib/module/e2ee/protobuf.js +140 -0
- package/lib/module/e2ee/protobuf.js.map +1 -0
- package/lib/module/e2ee/ratchet.js +228 -0
- package/lib/module/e2ee/ratchet.js.map +1 -0
- package/lib/module/e2ee/sealedBody.js +19 -0
- package/lib/module/e2ee/sealedBody.js.map +1 -0
- package/lib/module/e2ee/sealedFiles.js +154 -0
- package/lib/module/e2ee/sealedFiles.js.map +1 -0
- package/lib/module/e2ee/send.js +48 -0
- package/lib/module/e2ee/send.js.map +1 -0
- package/lib/module/e2ee/stanza.js +107 -0
- package/lib/module/e2ee/stanza.js.map +1 -0
- package/lib/module/e2ee/store.js +35 -0
- package/lib/module/e2ee/store.js.map +1 -0
- package/lib/module/helpers/accountName.js +18 -0
- package/lib/module/helpers/accountName.js.map +1 -0
- package/lib/module/helpers/createMessageFromXml.js +19 -4
- package/lib/module/helpers/createMessageFromXml.js.map +1 -1
- package/lib/module/helpers/createRoomFromApi.js +36 -2
- package/lib/module/helpers/createRoomFromApi.js.map +1 -1
- package/lib/module/helpers/createUserNameFromSetUser.js +3 -1
- package/lib/module/helpers/createUserNameFromSetUser.js.map +1 -1
- package/lib/module/helpers/displayName.js +11 -0
- package/lib/module/helpers/displayName.js.map +1 -0
- package/lib/module/helpers/emoji.js +44 -0
- package/lib/module/helpers/emoji.js.map +1 -0
- package/lib/module/helpers/haptics.js +24 -0
- package/lib/module/helpers/haptics.js.map +1 -0
- package/lib/module/helpers/historyPreloadScheduler.js +32 -66
- package/lib/module/helpers/historyPreloadScheduler.js.map +1 -1
- package/lib/module/helpers/insertMessageWithDelimiter.js +21 -12
- package/lib/module/helpers/insertMessageWithDelimiter.js.map +1 -1
- package/lib/module/helpers/mamReactions.js +51 -0
- package/lib/module/helpers/mamReactions.js.map +1 -0
- package/lib/module/helpers/parseMessageReference.js +37 -0
- package/lib/module/helpers/parseMessageReference.js.map +1 -0
- package/lib/module/helpers/persistCrypto.js +4 -0
- package/lib/module/helpers/persistCrypto.js.map +1 -1
- package/lib/module/helpers/reactionsConfig.js +10 -0
- package/lib/module/helpers/reactionsConfig.js.map +1 -0
- package/lib/module/helpers/secureKeyValue.js +19 -0
- package/lib/module/helpers/secureKeyValue.js.map +1 -1
- package/lib/module/helpers/updateMessagesTillLast.js +17 -2
- package/lib/module/helpers/updateMessagesTillLast.js.map +1 -1
- package/lib/module/helpers/videoCache.js +125 -0
- package/lib/module/helpers/videoCache.js.map +1 -0
- package/lib/module/hooks/useHeapSender.js +3 -1
- package/lib/module/hooks/useHeapSender.js.map +1 -1
- package/lib/module/hooks/useLogout.js +8 -0
- package/lib/module/hooks/useLogout.js.map +1 -1
- package/lib/module/hooks/useMessageHeapState.js +3 -2
- package/lib/module/hooks/useMessageHeapState.js.map +1 -1
- package/lib/module/hooks/useRoomInitialization.js +17 -8
- package/lib/module/hooks/useRoomInitialization.js.map +1 -1
- package/lib/module/hooks/useSendMessage.js +85 -15
- package/lib/module/hooks/useSendMessage.js.map +1 -1
- package/lib/module/hooks/useUnreadMessagesCounter.js +1 -1
- package/lib/module/hooks/useUnreadMessagesCounter.js.map +1 -1
- package/lib/module/i18n/strings.js +180 -0
- package/lib/module/i18n/strings.js.map +1 -1
- package/lib/module/main.js +1 -0
- package/lib/module/main.js.map +1 -1
- package/lib/module/networking/api-requests/auth.api.js +4 -1
- package/lib/module/networking/api-requests/auth.api.js.map +1 -1
- package/lib/module/networking/api-requests/rooms.api.js +109 -18
- package/lib/module/networking/api-requests/rooms.api.js.map +1 -1
- package/lib/module/networking/stanzaHandlers.js +107 -51
- package/lib/module/networking/stanzaHandlers.js.map +1 -1
- package/lib/module/networking/xmpp/getHistory.xmpp.js +29 -74
- package/lib/module/networking/xmpp/getHistory.xmpp.js.map +1 -1
- package/lib/module/networking/xmpp/handleStanzas.xmpp.js +42 -0
- package/lib/module/networking/xmpp/handleStanzas.xmpp.js.map +1 -1
- package/lib/module/networking/xmpp/mamRouter.js +175 -0
- package/lib/module/networking/xmpp/mamRouter.js.map +1 -0
- package/lib/module/networking/xmpp/presenceInRoom.xmpp.js +38 -2
- package/lib/module/networking/xmpp/presenceInRoom.xmpp.js.map +1 -1
- package/lib/module/networking/xmpp/sendMediaMessage.xmpp.js +16 -3
- package/lib/module/networking/xmpp/sendMediaMessage.xmpp.js.map +1 -1
- package/lib/module/networking/xmpp/sendTextMessage.xmpp.js +13 -6
- package/lib/module/networking/xmpp/sendTextMessage.xmpp.js.map +1 -1
- package/lib/module/networking/xmpp/sendTextMessageWithTranslateTag.xmpp.js +14 -6
- package/lib/module/networking/xmpp/sendTextMessageWithTranslateTag.xmpp.js.map +1 -1
- package/lib/module/networking/xmppClient.js +105 -24
- package/lib/module/networking/xmppClient.js.map +1 -1
- package/lib/module/roomStore/Middleware/newMessageMidlleware.js +29 -34
- package/lib/module/roomStore/Middleware/newMessageMidlleware.js.map +1 -1
- package/lib/module/roomStore/Middleware/perfMiddleware.js +45 -0
- package/lib/module/roomStore/Middleware/perfMiddleware.js.map +1 -0
- package/lib/module/roomStore/Middleware/reactionsMiddleware.js +66 -43
- package/lib/module/roomStore/Middleware/reactionsMiddleware.js.map +1 -1
- package/lib/module/roomStore/Middleware/unreadMidlleware.js +89 -69
- package/lib/module/roomStore/Middleware/unreadMidlleware.js.map +1 -1
- package/lib/module/roomStore/index.js +19 -15
- package/lib/module/roomStore/index.js.map +1 -1
- package/lib/module/roomStore/persistBackend.js +86 -0
- package/lib/module/roomStore/persistBackend.js.map +1 -0
- package/lib/module/roomStore/persistence.js +253 -49
- package/lib/module/roomStore/persistence.js.map +1 -1
- package/lib/module/roomStore/roomsSlice.js +275 -134
- package/lib/module/roomStore/roomsSlice.js.map +1 -1
- package/lib/module/theme/theme.js +3 -0
- package/lib/module/theme/theme.js.map +1 -1
- package/lib/module/utils/devLogger.js +13 -0
- package/lib/module/utils/devLogger.js.map +1 -1
- package/lib/module/version.js +1 -1
- package/lib/typescript/assets/emojiData.d.ts +8 -0
- package/lib/typescript/assets/emojiData.d.ts.map +1 -0
- package/lib/typescript/assets/icons.d.ts +8 -0
- package/lib/typescript/assets/icons.d.ts.map +1 -1
- package/lib/typescript/components/MainComponents/ChatHeader.d.ts.map +1 -1
- package/lib/typescript/components/MainComponents/ChatRoom.d.ts.map +1 -1
- package/lib/typescript/components/MainComponents/ChatWrapper.d.ts.map +1 -1
- package/lib/typescript/components/MainComponents/EncryptedSendNotice.d.ts +4 -0
- package/lib/typescript/components/MainComponents/EncryptedSendNotice.d.ts.map +1 -0
- package/lib/typescript/components/MainComponents/EncryptionCard.d.ts +10 -0
- package/lib/typescript/components/MainComponents/EncryptionCard.d.ts.map +1 -0
- package/lib/typescript/components/MainComponents/MediaMessage.d.ts.map +1 -1
- package/lib/typescript/components/MainComponents/MessageContainer.d.ts +2 -2
- package/lib/typescript/components/MainComponents/MessageContainer.d.ts.map +1 -1
- package/lib/typescript/components/MainComponents/MessageList.d.ts.map +1 -1
- package/lib/typescript/components/MainComponents/ReduxWrapper.d.ts.map +1 -1
- package/lib/typescript/components/MainComponents/RoomList.d.ts.map +1 -1
- package/lib/typescript/components/MainComponents/RoomStack.d.ts +7 -2
- package/lib/typescript/components/MainComponents/RoomStack.d.ts.map +1 -1
- package/lib/typescript/components/MainComponents/SealedAttachment.d.ts +13 -0
- package/lib/typescript/components/MainComponents/SealedAttachment.d.ts.map +1 -0
- package/lib/typescript/components/MainComponents/SystemMessage.d.ts.map +1 -1
- package/lib/typescript/components/MessageBubble/Avatar.d.ts +2 -0
- package/lib/typescript/components/MessageBubble/Avatar.d.ts.map +1 -1
- package/lib/typescript/components/MessageBubble/BottomReplyContainer.d.ts.map +1 -1
- package/lib/typescript/components/MessageBubble/EmojiPickerSheet.d.ts +11 -0
- package/lib/typescript/components/MessageBubble/EmojiPickerSheet.d.ts.map +1 -0
- package/lib/typescript/components/MessageBubble/Message.d.ts +2 -2
- package/lib/typescript/components/MessageBubble/Message.d.ts.map +1 -1
- package/lib/typescript/components/MessageBubble/MessageInteractions.d.ts +2 -0
- package/lib/typescript/components/MessageBubble/MessageInteractions.d.ts.map +1 -1
- package/lib/typescript/components/MessageBubble/MessageReaction.d.ts +1 -0
- package/lib/typescript/components/MessageBubble/MessageReaction.d.ts.map +1 -1
- package/lib/typescript/components/MessageBubble/MessageReply.d.ts +7 -7
- package/lib/typescript/components/MessageBubble/MessageReply.d.ts.map +1 -1
- package/lib/typescript/components/Modals/ChatProfileModal/ChatProfileModal.d.ts.map +1 -1
- package/lib/typescript/components/Modals/FilePreviewModal/FilePreviewModal.d.ts.map +1 -1
- package/lib/typescript/components/Modals/FilePreviewModal/PdfView.d.ts.map +1 -1
- package/lib/typescript/components/Modals/Modal/SwipeBackLayer.d.ts +2 -1
- package/lib/typescript/components/Modals/Modal/SwipeBackLayer.d.ts.map +1 -1
- package/lib/typescript/components/Modals/UserProfileModal/UserProfileModal.d.ts.map +1 -1
- package/lib/typescript/components/Modals/UserSettingsModal/UserSettingsModal.d.ts.map +1 -1
- package/lib/typescript/components/RoomComponents/ChatRoomItem.d.ts +2 -2
- package/lib/typescript/components/RoomComponents/ChatRoomItem.d.ts.map +1 -1
- package/lib/typescript/components/RoomComponents/LastMessageItem.d.ts.map +1 -1
- package/lib/typescript/components/RoomComponents/styled/LastAudioMessage.d.ts.map +1 -1
- package/lib/typescript/components/RoomComponents/styled/LastMessageEmoji.d.ts +3 -6
- package/lib/typescript/components/RoomComponents/styled/LastMessageEmoji.d.ts.map +1 -1
- package/lib/typescript/components/RoomComponents/styled/LastMessageSealed.d.ts +7 -0
- package/lib/typescript/components/RoomComponents/styled/LastMessageSealed.d.ts.map +1 -0
- package/lib/typescript/components/Thread/ThreadWrapper.d.ts +7 -1
- package/lib/typescript/components/Thread/ThreadWrapper.d.ts.map +1 -1
- package/lib/typescript/components/UsersList/UsersList.d.ts.map +1 -1
- package/lib/typescript/components/styled/DateLabel.d.ts +1 -0
- package/lib/typescript/components/styled/DateLabel.d.ts.map +1 -1
- package/lib/typescript/components/styled/SendInput.d.ts +1 -0
- package/lib/typescript/components/styled/SendInput.d.ts.map +1 -1
- package/lib/typescript/context/MessageNotificationContext.d.ts.map +1 -1
- package/lib/typescript/context/xmppProvider.d.ts.map +1 -1
- package/lib/typescript/e2ee/crypto.d.ts +28 -0
- package/lib/typescript/e2ee/crypto.d.ts.map +1 -0
- package/lib/typescript/e2ee/deviceStore.d.ts +4 -0
- package/lib/typescript/e2ee/deviceStore.d.ts.map +1 -0
- package/lib/typescript/e2ee/fileCipher.d.ts +7 -0
- package/lib/typescript/e2ee/fileCipher.d.ts.map +1 -0
- package/lib/typescript/e2ee/fileEnvelope.d.ts +27 -0
- package/lib/typescript/e2ee/fileEnvelope.d.ts.map +1 -0
- package/lib/typescript/e2ee/index.d.ts +23 -0
- package/lib/typescript/e2ee/index.d.ts.map +1 -0
- package/lib/typescript/e2ee/limits.d.ts +3 -0
- package/lib/typescript/e2ee/limits.d.ts.map +1 -0
- package/lib/typescript/e2ee/ns.d.ts +2 -0
- package/lib/typescript/e2ee/ns.d.ts.map +1 -0
- package/lib/typescript/e2ee/omemo.d.ts +64 -0
- package/lib/typescript/e2ee/omemo.d.ts.map +1 -0
- package/lib/typescript/e2ee/protobuf.d.ts +25 -0
- package/lib/typescript/e2ee/protobuf.d.ts.map +1 -0
- package/lib/typescript/e2ee/ratchet.d.ts +39 -0
- package/lib/typescript/e2ee/ratchet.d.ts.map +1 -0
- package/lib/typescript/e2ee/sealedBody.d.ts +2 -0
- package/lib/typescript/e2ee/sealedBody.d.ts.map +1 -0
- package/lib/typescript/e2ee/sealedFiles.d.ts +31 -0
- package/lib/typescript/e2ee/sealedFiles.d.ts.map +1 -0
- package/lib/typescript/e2ee/send.d.ts +6 -0
- package/lib/typescript/e2ee/send.d.ts.map +1 -0
- package/lib/typescript/e2ee/stanza.d.ts +8 -0
- package/lib/typescript/e2ee/stanza.d.ts.map +1 -0
- package/lib/typescript/e2ee/store.d.ts +16 -0
- package/lib/typescript/e2ee/store.d.ts.map +1 -0
- package/lib/typescript/helpers/accountName.d.ts +7 -0
- package/lib/typescript/helpers/accountName.d.ts.map +1 -0
- package/lib/typescript/helpers/createMessageFromXml.d.ts.map +1 -1
- package/lib/typescript/helpers/createRoomFromApi.d.ts.map +1 -1
- package/lib/typescript/helpers/createUserNameFromSetUser.d.ts.map +1 -1
- package/lib/typescript/helpers/displayName.d.ts +2 -0
- package/lib/typescript/helpers/displayName.d.ts.map +1 -0
- package/lib/typescript/helpers/emoji.d.ts +6 -0
- package/lib/typescript/helpers/emoji.d.ts.map +1 -0
- package/lib/typescript/helpers/haptics.d.ts +3 -0
- package/lib/typescript/helpers/haptics.d.ts.map +1 -0
- package/lib/typescript/helpers/historyPreloadScheduler.d.ts +1 -0
- package/lib/typescript/helpers/historyPreloadScheduler.d.ts.map +1 -1
- package/lib/typescript/helpers/insertMessageWithDelimiter.d.ts.map +1 -1
- package/lib/typescript/helpers/mamReactions.d.ts +13 -0
- package/lib/typescript/helpers/mamReactions.d.ts.map +1 -0
- package/lib/typescript/helpers/parseMessageReference.d.ts +16 -0
- package/lib/typescript/helpers/parseMessageReference.d.ts.map +1 -0
- package/lib/typescript/helpers/persistCrypto.d.ts +1 -0
- package/lib/typescript/helpers/persistCrypto.d.ts.map +1 -1
- package/lib/typescript/helpers/reactionsConfig.d.ts +5 -0
- package/lib/typescript/helpers/reactionsConfig.d.ts.map +1 -0
- package/lib/typescript/helpers/secureKeyValue.d.ts +4 -0
- package/lib/typescript/helpers/secureKeyValue.d.ts.map +1 -1
- package/lib/typescript/helpers/updateMessagesTillLast.d.ts.map +1 -1
- package/lib/typescript/helpers/videoCache.d.ts +19 -0
- package/lib/typescript/helpers/videoCache.d.ts.map +1 -0
- package/lib/typescript/hooks/useHeapSender.d.ts.map +1 -1
- package/lib/typescript/hooks/useLogout.d.ts.map +1 -1
- package/lib/typescript/hooks/useMessageHeapState.d.ts.map +1 -1
- package/lib/typescript/hooks/useRoomInitialization.d.ts +2 -2
- package/lib/typescript/hooks/useRoomInitialization.d.ts.map +1 -1
- package/lib/typescript/hooks/useSendMessage.d.ts.map +1 -1
- package/lib/typescript/i18n/strings.d.ts.map +1 -1
- package/lib/typescript/main.d.ts +2 -0
- package/lib/typescript/main.d.ts.map +1 -1
- package/lib/typescript/networking/api-requests/auth.api.d.ts +4 -1
- package/lib/typescript/networking/api-requests/auth.api.d.ts.map +1 -1
- package/lib/typescript/networking/api-requests/rooms.api.d.ts +22 -1
- package/lib/typescript/networking/api-requests/rooms.api.d.ts.map +1 -1
- package/lib/typescript/networking/stanzaHandlers.d.ts +4 -2
- package/lib/typescript/networking/stanzaHandlers.d.ts.map +1 -1
- package/lib/typescript/networking/xmpp/getHistory.xmpp.d.ts +3 -1
- package/lib/typescript/networking/xmpp/getHistory.xmpp.d.ts.map +1 -1
- package/lib/typescript/networking/xmpp/handleStanzas.xmpp.d.ts +1 -0
- package/lib/typescript/networking/xmpp/handleStanzas.xmpp.d.ts.map +1 -1
- package/lib/typescript/networking/xmpp/mamRouter.d.ts +23 -0
- package/lib/typescript/networking/xmpp/mamRouter.d.ts.map +1 -0
- package/lib/typescript/networking/xmpp/presenceInRoom.xmpp.d.ts +1 -0
- package/lib/typescript/networking/xmpp/presenceInRoom.xmpp.d.ts.map +1 -1
- package/lib/typescript/networking/xmpp/sendMediaMessage.xmpp.d.ts.map +1 -1
- package/lib/typescript/networking/xmpp/sendTextMessage.xmpp.d.ts.map +1 -1
- package/lib/typescript/networking/xmpp/sendTextMessageWithTranslateTag.xmpp.d.ts.map +1 -1
- package/lib/typescript/networking/xmppClient.d.ts +22 -1
- package/lib/typescript/networking/xmppClient.d.ts.map +1 -1
- package/lib/typescript/roomStore/Middleware/newMessageMidlleware.d.ts.map +1 -1
- package/lib/typescript/roomStore/Middleware/perfMiddleware.d.ts +4 -0
- package/lib/typescript/roomStore/Middleware/perfMiddleware.d.ts.map +1 -0
- package/lib/typescript/roomStore/Middleware/reactionsMiddleware.d.ts +9 -0
- package/lib/typescript/roomStore/Middleware/reactionsMiddleware.d.ts.map +1 -1
- package/lib/typescript/roomStore/Middleware/unreadMidlleware.d.ts.map +1 -1
- package/lib/typescript/roomStore/index.d.ts.map +1 -1
- package/lib/typescript/roomStore/persistBackend.d.ts +11 -0
- package/lib/typescript/roomStore/persistBackend.d.ts.map +1 -0
- package/lib/typescript/roomStore/persistence.d.ts +5 -6
- package/lib/typescript/roomStore/persistence.d.ts.map +1 -1
- package/lib/typescript/roomStore/roomsSlice.d.ts +41 -1
- package/lib/typescript/roomStore/roomsSlice.d.ts.map +1 -1
- package/lib/typescript/theme/theme.d.ts +4 -1
- package/lib/typescript/theme/theme.d.ts.map +1 -1
- package/lib/typescript/types/models/message.model.d.ts +9 -0
- package/lib/typescript/types/models/message.model.d.ts.map +1 -1
- package/lib/typescript/types/models/room.model.d.ts +21 -0
- package/lib/typescript/types/models/room.model.d.ts.map +1 -1
- package/lib/typescript/types/models/xmpp.model.d.ts +6 -1
- package/lib/typescript/types/models/xmpp.model.d.ts.map +1 -1
- package/lib/typescript/types/types.d.ts +19 -3
- package/lib/typescript/types/types.d.ts.map +1 -1
- package/lib/typescript/utils/devLogger.d.ts +8 -0
- package/lib/typescript/utils/devLogger.d.ts.map +1 -1
- package/lib/typescript/version.d.ts +1 -1
- package/package.json +14 -1
- package/src/assets/emojiData.ts +2146 -0
- package/src/assets/icons.tsx +32 -5
- package/src/components/MainComponents/ChatHeader.tsx +46 -16
- package/src/components/MainComponents/ChatRoom.tsx +46 -30
- package/src/components/MainComponents/ChatWrapper.tsx +28 -10
- package/src/components/MainComponents/EncryptedSendNotice.tsx +35 -0
- package/src/components/MainComponents/EncryptionCard.tsx +287 -0
- package/src/components/MainComponents/MediaMessage.tsx +5 -0
- package/src/components/MainComponents/MessageContainer.tsx +7 -15
- package/src/components/MainComponents/MessageList.tsx +96 -43
- package/src/components/MainComponents/ReduxWrapper.tsx +5 -0
- package/src/components/MainComponents/RoomList.tsx +28 -29
- package/src/components/MainComponents/RoomStack.tsx +156 -83
- package/src/components/MainComponents/SealedAttachment.tsx +251 -0
- package/src/components/MainComponents/SystemMessage.tsx +6 -2
- package/src/components/MessageBubble/Avatar.tsx +7 -1
- package/src/components/MessageBubble/BottomReplyContainer.tsx +20 -21
- package/src/components/MessageBubble/EmojiPickerSheet.tsx +468 -0
- package/src/components/MessageBubble/Message.tsx +242 -93
- package/src/components/MessageBubble/MessageInteractions.tsx +215 -15
- package/src/components/MessageBubble/MessageReaction.tsx +120 -96
- package/src/components/MessageBubble/MessageReply.tsx +65 -32
- package/src/components/Modals/ChatProfileModal/ChatProfileModal.tsx +7 -4
- package/src/components/Modals/FilePreviewModal/FilePreviewModal.tsx +181 -35
- package/src/components/Modals/FilePreviewModal/PdfView.tsx +4 -0
- package/src/components/Modals/Modal/SwipeBackLayer.tsx +114 -63
- package/src/components/Modals/UserProfileModal/UserProfileModal.tsx +53 -8
- package/src/components/Modals/UserSettingsModal/UserSettingsModal.tsx +5 -0
- package/src/components/RoomComponents/ChatRoomItem.tsx +34 -15
- package/src/components/RoomComponents/LastMessageItem.tsx +5 -0
- package/src/components/RoomComponents/styled/LastAudioMessage.tsx +3 -1
- package/src/components/RoomComponents/styled/LastMessageEmoji.tsx +7 -8
- package/src/components/RoomComponents/styled/LastMessageFile.tsx +2 -2
- package/src/components/RoomComponents/styled/LastMessagePhoto.tsx +1 -1
- package/src/components/RoomComponents/styled/LastMessageSealed.tsx +31 -0
- package/src/components/RoomComponents/styled/LastMessageVideo.tsx +1 -1
- package/src/components/Thread/ThreadWrapper.tsx +287 -198
- package/src/components/UsersList/UsersList.tsx +2 -1
- package/src/components/styled/DateLabel.tsx +7 -3
- package/src/components/styled/SendInput.tsx +5 -2
- package/src/context/MessageNotificationContext.tsx +205 -7
- package/src/context/xmppProvider.tsx +29 -9
- package/src/e2ee/crypto.ts +194 -0
- package/src/e2ee/deviceStore.ts +80 -0
- package/src/e2ee/fileCipher.ts +86 -0
- package/src/e2ee/fileEnvelope.ts +115 -0
- package/src/e2ee/index.ts +192 -0
- package/src/e2ee/limits.ts +2 -0
- package/src/e2ee/ns.ts +1 -0
- package/src/e2ee/omemo.ts +802 -0
- package/src/e2ee/protobuf.ts +188 -0
- package/src/e2ee/ratchet.ts +271 -0
- package/src/e2ee/sealedBody.ts +17 -0
- package/src/e2ee/sealedFiles.ts +181 -0
- package/src/e2ee/send.ts +70 -0
- package/src/e2ee/stanza.ts +133 -0
- package/src/e2ee/store.ts +54 -0
- package/src/helpers/accountName.ts +15 -0
- package/src/helpers/createMessageFromXml.ts +31 -6
- package/src/helpers/createRoomFromApi.tsx +37 -1
- package/src/helpers/createUserNameFromSetUser.ts +2 -1
- package/src/helpers/displayName.ts +9 -0
- package/src/helpers/emoji.ts +39 -0
- package/src/helpers/haptics.ts +19 -0
- package/src/helpers/historyPreloadScheduler.ts +37 -69
- package/src/helpers/insertMessageWithDelimiter.ts +23 -16
- package/src/helpers/mamReactions.ts +59 -0
- package/src/helpers/parseMessageReference.ts +38 -0
- package/src/helpers/persistCrypto.ts +5 -0
- package/src/helpers/reactionsConfig.ts +13 -0
- package/src/helpers/secureKeyValue.ts +15 -0
- package/src/helpers/updateMessagesTillLast.tsx +14 -2
- package/src/helpers/videoCache.ts +138 -0
- package/src/hooks/useHeapSender.tsx +3 -2
- package/src/hooks/useLogout.tsx +9 -0
- package/src/hooks/useMessageHeapState.tsx +6 -2
- package/src/hooks/useRoomInitialization.tsx +32 -15
- package/src/hooks/useSendMessage.tsx +89 -16
- package/src/hooks/useUnreadMessagesCounter.ts +1 -1
- package/src/i18n/strings.ts +180 -0
- package/src/main.ts +2 -0
- package/src/networking/api-requests/auth.api.ts +9 -1
- package/src/networking/api-requests/rooms.api.ts +121 -18
- package/src/networking/stanzaHandlers.ts +116 -60
- package/src/networking/xmpp/getHistory.xmpp.ts +44 -106
- package/src/networking/xmpp/handleStanzas.xmpp.ts +51 -0
- package/src/networking/xmpp/mamRouter.ts +176 -0
- package/src/networking/xmpp/presenceInRoom.xmpp.ts +46 -3
- package/src/networking/xmpp/sendMediaMessage.xmpp.ts +19 -1
- package/src/networking/xmpp/sendTextMessage.xmpp.ts +17 -10
- package/src/networking/xmpp/sendTextMessageWithTranslateTag.xmpp.ts +23 -10
- package/src/networking/xmppClient.ts +111 -20
- package/src/roomStore/Middleware/newMessageMidlleware.tsx +35 -38
- package/src/roomStore/Middleware/perfMiddleware.ts +50 -0
- package/src/roomStore/Middleware/reactionsMiddleware.tsx +53 -52
- package/src/roomStore/Middleware/unreadMidlleware.tsx +92 -80
- package/src/roomStore/index.ts +28 -27
- package/src/roomStore/persistBackend.ts +93 -0
- package/src/roomStore/persistence.ts +295 -73
- package/src/roomStore/roomsSlice.ts +304 -155
- package/src/theme/theme.ts +10 -1
- package/src/types/models/message.model.ts +9 -0
- package/src/types/models/room.model.ts +22 -0
- package/src/types/models/xmpp.model.ts +4 -2
- package/src/types/types.ts +19 -3
- package/src/utils/devLogger.ts +16 -0
- package/src/version.ts +1 -1
|
@@ -1,9 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
import { updateRoom } from '../roomsSlice';
|
|
4
|
-
|
|
4
|
+
/**
|
|
5
|
+
* Keeps the room-list preview in step with reactions (as on web): the
|
|
6
|
+
* newest event in a room being a reaction shows "Ann: 👍"; a reactor
|
|
7
|
+
* clearing theirs puts the last real message back.
|
|
8
|
+
*
|
|
9
|
+
* Timestamps here are the server's stanza ids, the same unit as
|
|
10
|
+
* `lastMessageTimestamp` (set from message ids in the reducer), so a
|
|
11
|
+
* reaction older than the room's latest message never takes the preview.
|
|
12
|
+
*/
|
|
5
13
|
export const reactionsMiddleware = storeAPI => next => action => {
|
|
6
|
-
if (action
|
|
14
|
+
if (action?.type !== 'roomMessages/setReactions') {
|
|
7
15
|
return next(action);
|
|
8
16
|
}
|
|
9
17
|
if (!action.payload || typeof action.payload !== 'object') {
|
|
@@ -11,53 +19,68 @@ export const reactionsMiddleware = storeAPI => next => action => {
|
|
|
11
19
|
return next(action);
|
|
12
20
|
}
|
|
13
21
|
const result = next(action);
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
22
|
+
try {
|
|
23
|
+
const payload = action.payload || {};
|
|
24
|
+
const {
|
|
25
|
+
roomJID,
|
|
26
|
+
reactions,
|
|
27
|
+
latestReactionTimestamp,
|
|
28
|
+
data
|
|
29
|
+
} = payload;
|
|
30
|
+
const room = storeAPI.getState().rooms?.rooms?.[roomJID];
|
|
31
|
+
if (!room) {
|
|
32
|
+
return result;
|
|
33
|
+
}
|
|
34
|
+
const ts = Number(latestReactionTimestamp) || 0;
|
|
35
|
+
const roomTs = Number(room.lastMessageTimestamp) || 0;
|
|
36
|
+
if (Array.isArray(reactions) && reactions[0]) {
|
|
37
|
+
// Only the newest event in the room may become the preview.
|
|
38
|
+
if (!ts || ts < roomTs) {
|
|
39
|
+
return result;
|
|
40
|
+
}
|
|
41
|
+
const name = `${data?.senderFirstName || ''} ${data?.senderLastName || ''}`.trim();
|
|
26
42
|
storeAPI.dispatch(updateRoom({
|
|
27
43
|
jid: roomJID,
|
|
28
44
|
updates: {
|
|
29
|
-
lastMessageTimestamp:
|
|
30
|
-
lastMessage:
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
user: {
|
|
41
|
-
name: `${data.senderFirstName} ${data.senderLastName}`,
|
|
42
|
-
id: `emoji-${new Date().toString()}`
|
|
43
|
-
},
|
|
44
|
-
date: new Date(nanoToMs(latestReactionTimestamp) ?? 0).toISOString()
|
|
45
|
+
lastMessageTimestamp: ts,
|
|
46
|
+
lastMessage: {
|
|
47
|
+
id: `reaction-${ts}`,
|
|
48
|
+
body: reactions[0],
|
|
49
|
+
emoji: reactions[0],
|
|
50
|
+
user: {
|
|
51
|
+
id: `emoji-${ts}`,
|
|
52
|
+
name
|
|
53
|
+
},
|
|
54
|
+
date: new Date(Math.floor(ts / 1000)).toISOString()
|
|
55
|
+
}
|
|
45
56
|
}
|
|
46
|
-
};
|
|
47
|
-
storeAPI.dispatch(updateRoom({
|
|
48
|
-
jid: roomJID,
|
|
49
|
-
updates: updates
|
|
50
57
|
}));
|
|
58
|
+
return result;
|
|
51
59
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
60
|
+
|
|
61
|
+
// A reaction was cleared: if the preview was a reaction, fall back to
|
|
62
|
+
// the newest real message (the room may have none loaded yet).
|
|
63
|
+
if (!room.lastMessage?.emoji) {
|
|
64
|
+
return result;
|
|
65
|
+
}
|
|
66
|
+
const messages = room.messages || [];
|
|
67
|
+
let last;
|
|
68
|
+
for (let i = messages.length - 1; i >= 0; i--) {
|
|
69
|
+
const m = messages[i];
|
|
70
|
+
if (m && m.id !== 'delimiter-new' && !m.isDeleted) {
|
|
71
|
+
last = m;
|
|
72
|
+
break;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
storeAPI.dispatch(updateRoom({
|
|
76
|
+
jid: roomJID,
|
|
77
|
+
updates: {
|
|
78
|
+
lastMessage: last ?? undefined
|
|
79
|
+
}
|
|
80
|
+
}));
|
|
81
|
+
} catch (e) {
|
|
82
|
+
// A preview update must never break the action that carried it.
|
|
83
|
+
console.warn('reactionsMiddleware: preview update failed', e);
|
|
61
84
|
}
|
|
62
85
|
return result;
|
|
63
86
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["updateRoom","
|
|
1
|
+
{"version":3,"names":["updateRoom","reactionsMiddleware","storeAPI","next","action","type","payload","console","error","result","roomJID","reactions","latestReactionTimestamp","data","room","getState","rooms","ts","Number","roomTs","lastMessageTimestamp","Array","isArray","name","senderFirstName","senderLastName","trim","dispatch","jid","updates","lastMessage","id","body","emoji","user","date","Date","Math","floor","toISOString","messages","last","i","length","m","isDeleted","undefined","e","warn"],"sourceRoot":"../../../../src","sources":["roomStore/Middleware/reactionsMiddleware.tsx"],"mappings":";;AACA,SAASA,UAAU,QAAQ,eAAe;AAG1C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,mBAA+B,GACzCC,QAAQ,IAAMC,IAAI,IAAMC,MAAW,IAAK;EACvC,IAAIA,MAAM,EAAEC,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
|
3
|
+
import { setUnreadCounts, msgSortableMs } from '../roomsSlice';
|
|
4
4
|
// Per-room cache so we only recompute when something that affects the
|
|
5
5
|
// count actually changed. The fingerprint is `<messages.length>|<lastViewed>`
|
|
6
6
|
// — switching just the lastViewedTimestamp (e.g. user re-opens a room)
|
|
@@ -55,7 +55,7 @@ const isOwnMessage = (msg, selfXmpp, selfWallet) => {
|
|
|
55
55
|
// events, typing-indicator setComposing, etc. — and walked every room's
|
|
56
56
|
// messages array looking for a count delta that almost never came. For
|
|
57
57
|
// 50 rooms × 100 messages that's 5000 Date() parses per modal click.
|
|
58
|
-
const TRIGGER_ACTIONS = new Set(['roomMessages/addRoomMessage', 'roomMessages/setRoomMessages', 'roomMessages/editRoomMessage', 'roomMessages/setLastViewedTimestamp',
|
|
58
|
+
const TRIGGER_ACTIONS = new Set(['roomMessages/addRoomMessage', 'roomMessages/addRoomMessages', 'roomMessages/addRooms', 'roomMessages/setRoomMessages', 'roomMessages/editRoomMessage', 'roomMessages/setLastViewedTimestamp',
|
|
59
59
|
// Hydrating server-side read markers can move several rooms' baselines
|
|
60
60
|
// at once; recompute so the badges reflect the freshly-applied markers
|
|
61
61
|
// (with own-message filtering this middleware adds on top).
|
|
@@ -65,6 +65,38 @@ const TRIGGER_ACTIONS = new Set(['roomMessages/addRoomMessage', 'roomMessages/se
|
|
|
65
65
|
// app was away (the per-room fingerprint cache below skips no-op batches,
|
|
66
66
|
// e.g. the 'loading' marker dispatch that carries no messages).
|
|
67
67
|
'roomMessages/applyRoomsPreloadBatch']);
|
|
68
|
+
|
|
69
|
+
// Which rooms an action can have changed the unread count of. Walking
|
|
70
|
+
// every room on every message (the previous behaviour) made each incoming
|
|
71
|
+
// message cost O(rooms); `'all'` is reserved for the few actions that move
|
|
72
|
+
// several rooms' baselines at once.
|
|
73
|
+
const touchedRooms = action => {
|
|
74
|
+
const p = action?.payload;
|
|
75
|
+
switch (action?.type) {
|
|
76
|
+
case 'roomMessages/addRoomMessage':
|
|
77
|
+
case 'roomMessages/addRoomMessages':
|
|
78
|
+
case 'roomMessages/setRoomMessages':
|
|
79
|
+
case 'roomMessages/editRoomMessage':
|
|
80
|
+
return p?.roomJID ? [p.roomJID] : [];
|
|
81
|
+
case 'roomMessages/setLastViewedTimestamp':
|
|
82
|
+
return p?.chatJID ? [p.chatJID] : [];
|
|
83
|
+
case 'roomMessages/addRoom':
|
|
84
|
+
return p?.roomData?.jid ? [p.roomData.jid] : [];
|
|
85
|
+
case 'roomMessages/addRooms':
|
|
86
|
+
case 'roomMessages/applyRoomsPreloadBatch':
|
|
87
|
+
return Array.isArray(p?.rooms) ? p.rooms.map(r => r?.jid).filter(Boolean) : [];
|
|
88
|
+
case 'roomMessages/updateRoom':
|
|
89
|
+
{
|
|
90
|
+
// The counts this middleware writes itself, and the room-list
|
|
91
|
+
// ordering stamp, never change what is unread.
|
|
92
|
+
const keys = Object.keys(p?.updates || {});
|
|
93
|
+
const relevant = keys.some(k => k !== 'unreadMessages' && k !== 'lastMessageTimestamp');
|
|
94
|
+
return relevant && p?.jid ? [p.jid] : [];
|
|
95
|
+
}
|
|
96
|
+
default:
|
|
97
|
+
return 'all';
|
|
98
|
+
}
|
|
99
|
+
};
|
|
68
100
|
export const unreadMiddleware = storeAPI => next => action => {
|
|
69
101
|
if (!action || !action.type) {
|
|
70
102
|
console.error('Invalid action in unreadMiddleware:', action);
|
|
@@ -89,80 +121,68 @@ export const unreadMiddleware = storeAPI => next => action => {
|
|
|
89
121
|
}
|
|
90
122
|
const state = storeAPI.getState();
|
|
91
123
|
const rooms = state.rooms.rooms;
|
|
124
|
+
if (!rooms) {
|
|
125
|
+
return result;
|
|
126
|
+
}
|
|
92
127
|
const visibleRoomJID = state.rooms.visibleRoomJID;
|
|
93
128
|
const selfUser = state.chatSettingStore?.user;
|
|
94
129
|
const selfXmpp = selfUser?.xmppUsername || '';
|
|
95
130
|
const selfWallet = selfUser?.walletAddress || '';
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
jid,
|
|
112
|
-
updates: {
|
|
113
|
-
unreadMessages: 0
|
|
114
|
-
}
|
|
115
|
-
}));
|
|
116
|
-
}
|
|
117
|
-
return;
|
|
118
|
-
}
|
|
119
|
-
if (!(room.lastViewedTimestamp > 0)) {
|
|
120
|
-
return;
|
|
121
|
-
}
|
|
122
|
-
const msgs = room.messages;
|
|
123
|
-
const currentMessagesLength = msgs?.length || 0;
|
|
124
|
-
const firstId = currentMessagesLength ? String(msgs[0]?.id ?? '') : '';
|
|
125
|
-
const lastId = currentMessagesLength ? String(msgs[currentMessagesLength - 1]?.id ?? '') : '';
|
|
126
|
-
const fingerprint = `${currentMessagesLength}|${room.lastViewedTimestamp || 0}|${firstId}|${lastId}`;
|
|
127
|
-
if (triggerCache[jid] === fingerprint) {
|
|
128
|
-
return;
|
|
131
|
+
const touched = touchedRooms(action);
|
|
132
|
+
const jids = touched === 'all' ? Object.keys(rooms) : touched;
|
|
133
|
+
if (jids.length === 0) {
|
|
134
|
+
return result;
|
|
135
|
+
}
|
|
136
|
+
const counts = {};
|
|
137
|
+
for (const jid of jids) {
|
|
138
|
+
const room = rooms[jid];
|
|
139
|
+
if (!room) {
|
|
140
|
+
continue;
|
|
141
|
+
}
|
|
142
|
+
// The room the user is looking at never carries a badge.
|
|
143
|
+
if (jid === visibleRoomJID) {
|
|
144
|
+
if (room.unreadMessages !== 0) {
|
|
145
|
+
counts[jid] = 0;
|
|
129
146
|
}
|
|
130
|
-
|
|
147
|
+
continue;
|
|
148
|
+
}
|
|
149
|
+
// No reference point (undefined / null / 0): after logout→login,
|
|
150
|
+
// hydrated rooms come back without lastViewedTimestamp, and treating
|
|
151
|
+
// that as 0 made every history message count as unread.
|
|
152
|
+
if (!(room.lastViewedTimestamp > 0)) {
|
|
153
|
+
continue;
|
|
154
|
+
}
|
|
155
|
+
const msgs = room.messages;
|
|
156
|
+
const currentMessagesLength = msgs?.length || 0;
|
|
157
|
+
const firstId = currentMessagesLength ? String(msgs[0]?.id ?? '') : '';
|
|
158
|
+
const lastId = currentMessagesLength ? String(msgs[currentMessagesLength - 1]?.id ?? '') : '';
|
|
159
|
+
const fingerprint = `${currentMessagesLength}|${room.lastViewedTimestamp || 0}|${firstId}|${lastId}`;
|
|
160
|
+
if (triggerCache[jid] === fingerprint) {
|
|
161
|
+
continue;
|
|
162
|
+
}
|
|
163
|
+
triggerCache[jid] = fingerprint;
|
|
131
164
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
jid,
|
|
143
|
-
selfXmpp,
|
|
144
|
-
selfWallet,
|
|
145
|
-
newerByTs: newerByTs.length,
|
|
146
|
-
unreadAfterOwnFilter: unreadMessagesCount,
|
|
147
|
-
sample: {
|
|
148
|
-
id: s.id,
|
|
149
|
-
userId: s?.user?.id,
|
|
150
|
-
userJID: s?.user?.userJID,
|
|
151
|
-
xmppUsername: s?.user?.xmppUsername,
|
|
152
|
-
xmppFrom: s?.xmppFrom,
|
|
153
|
-
senderJID: s?.senderJID
|
|
154
|
-
}
|
|
155
|
-
});
|
|
165
|
+
// Ignore the "delimiter-new" sentinel + locally-pending sends
|
|
166
|
+
// so the two unread-counting paths (this middleware + the
|
|
167
|
+
// reducer's countNewerMessages) never disagree. Also exclude
|
|
168
|
+
// own messages so MAM-replayed sends on re-login don't bump
|
|
169
|
+
// the user's own badge.
|
|
170
|
+
const since = room.lastViewedTimestamp || 0;
|
|
171
|
+
let unreadMessagesCount = 0;
|
|
172
|
+
for (const msg of msgs || []) {
|
|
173
|
+
if (msg.id !== 'delimiter-new' && !msg.pending && msgSortableMs(msg) > since && !isOwnMessage(msg, selfXmpp, selfWallet)) {
|
|
174
|
+
unreadMessagesCount += 1;
|
|
156
175
|
}
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
176
|
+
}
|
|
177
|
+
if (room.unreadMessages !== unreadMessagesCount) {
|
|
178
|
+
counts[jid] = unreadMessagesCount;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
// One action for every room that changed — and one that is not itself
|
|
183
|
+
// a trigger, so the chain stops here.
|
|
184
|
+
if (Object.keys(counts).length > 0) {
|
|
185
|
+
storeAPI.dispatch(setUnreadCounts(counts));
|
|
166
186
|
}
|
|
167
187
|
return result;
|
|
168
188
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["setUnreadCounts","msgSortableMs","triggerCache","norm","s","v","String","toLowerCase","split","replace","isOwnMessage","msg","selfXmpp","selfWallet","candidates","user","id","userJID","xmppUsername","filter","Boolean","length","self","Set","c","has","TRIGGER_ACTIONS","touchedRooms","action","p","payload","type","roomJID","chatJID","roomData","jid","Array","isArray","rooms","map","r","keys","Object","updates","relevant","some","k","unreadMiddleware","storeAPI","next","console","error","result","state","getState","visibleRoomJID","selfUser","chatSettingStore","walletAddress","touched","jids","counts","room","unreadMessages","lastViewedTimestamp","msgs","messages","currentMessagesLength","firstId","lastId","fingerprint","since","unreadMessagesCount","pending","dispatch"],"sourceRoot":"../../../../src","sources":["roomStore/Middleware/unreadMidlleware.tsx"],"mappings":";;AACA,SAASA,eAAe,EAAEC,aAAa,QAAQ,eAAe;AAG9D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAIC,YAAuC,GAAG,CAAC,CAAC;;AAEhD;AACA;AACA;AACA;AACA,MAAMC,IAAI,GAAIC,CAAM,IAAa;EAC/B,IAAIA,CAAC,IAAI,IAAI,EAAE;IAAC,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AACiC,GAAG,CAAC,GAAGmC,WAAW;;IAE/B;IACA;IACA;IACA;IACA;IACA,MAAMC,KAAK,GAAGT,IAAI,CAACE,mBAAmB,IAAI,CAAC;IAC3C,IAAIQ,mBAAmB,GAAG,CAAC;IAC3B,KAAK,MAAM7D,GAAG,IAAIsD,IAAI,IAAI,EAAE,EAAE;MAC5B,IACEtD,GAAG,CAACK,EAAE,KAAK,eAAe,IAC1B,CAACL,GAAG,CAAC8D,OAAO,IACZxE,aAAa,CAACU,GAAG,CAAC,GAAG4D,KAAK,IAC1B,CAAC7D,YAAY,CAACC,GAAG,EAAEC,QAAQ,EAAEC,UAAU,CAAC,EACxC;QACA2D,mBAAmB,IAAI,CAAC;MAC1B;IACF;IAEA,IAAIV,IAAI,CAACC,cAAc,KAAKS,mBAAmB,EAAE;MAC/CX,MAAM,CAAC1B,GAAG,CAAC,GAAGqC,mBAAmB;IACnC;EACF;;EAEA;EACA;EACA,IAAI9B,MAAM,CAACD,IAAI,CAACoB,MAAM,CAAC,CAACxC,MAAM,GAAG,CAAC,EAAE;IAClC2B,QAAQ,CAAC0B,QAAQ,CAAC1E,eAAe,CAAC6D,MAAM,CAAC,CAAC;EAC5C;EAEA,OAAOT,MAAM;AACf,CAAC","ignoreList":[]}
|
|
@@ -2,13 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
import { configureStore, combineReducers } from '@reduxjs/toolkit';
|
|
4
4
|
import chatSettingsReducer, { setUser } from './chatSettingsSlice';
|
|
5
|
-
import roomsSlice, {
|
|
5
|
+
import roomsSlice, { addRooms } from './roomsSlice';
|
|
6
6
|
import { roomHeapSlice, markMessageFailed } from './roomHeapSlice';
|
|
7
7
|
import callReducer from './callSlice';
|
|
8
8
|
import { unreadMiddleware } from './Middleware/unreadMidlleware';
|
|
9
9
|
import { logoutMiddleware } from './Middleware/logoutMiddleware';
|
|
10
10
|
import { newMessageMidlleware } from './Middleware/newMessageMidlleware';
|
|
11
11
|
import { reactionsMiddleware } from './Middleware/reactionsMiddleware';
|
|
12
|
+
import { isPerfProfilingEnabled, perfMiddleware } from './Middleware/perfMiddleware';
|
|
12
13
|
import { persistenceMiddleware, readPersistedState, computeBootTimeFailures } from './persistence';
|
|
13
14
|
const rootReducer = combineReducers({
|
|
14
15
|
chatSettingStore: chatSettingsReducer,
|
|
@@ -21,14 +22,19 @@ const rootReducer = combineReducers({
|
|
|
21
22
|
});
|
|
22
23
|
const createChatStore = () => configureStore({
|
|
23
24
|
reducer: rootReducer,
|
|
24
|
-
middleware: getDefaultMiddleware =>
|
|
25
|
-
|
|
26
|
-
//
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
25
|
+
middleware: getDefaultMiddleware => {
|
|
26
|
+
const base = getDefaultMiddleware({
|
|
27
|
+
// Both dev-only invariant checks walk the WHOLE state on every
|
|
28
|
+
// action. With rooms + message history in the store that took
|
|
29
|
+
// 60-80 ms per dispatch (RTK's own "took Xms" warning), blocking
|
|
30
|
+
// the JS thread long enough to make taps feel dead in dev builds.
|
|
31
|
+
// Production builds never ran them.
|
|
32
|
+
serializableCheck: false,
|
|
33
|
+
immutableCheck: false
|
|
34
|
+
});
|
|
35
|
+
const chain = [unreadMiddleware, newMessageMidlleware, reactionsMiddleware, logoutMiddleware, persistenceMiddleware];
|
|
36
|
+
return isPerfProfilingEnabled() ? base.concat(perfMiddleware, ...chain) : base.concat(...chain);
|
|
37
|
+
}
|
|
32
38
|
});
|
|
33
39
|
const globalScope = globalThis;
|
|
34
40
|
export const store = globalScope.__CHAT_STORE__ || (globalScope.__CHAT_STORE__ = createChatStore());
|
|
@@ -49,12 +55,10 @@ export const persistorReady = globalScope.__CHAT_PERSISTOR_READY__ || (globalSco
|
|
|
49
55
|
store.dispatch(setUser(chat.user));
|
|
50
56
|
}
|
|
51
57
|
if (rooms?.rooms) {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
store.dispatch(addRoom({
|
|
57
|
-
roomData: room
|
|
58
|
+
const restored = Object.entries(rooms.rooms).filter(([jid, room]) => !!jid && !!room).map(([, room]) => room);
|
|
59
|
+
if (restored.length) {
|
|
60
|
+
store.dispatch(addRooms({
|
|
61
|
+
rooms: restored
|
|
58
62
|
}));
|
|
59
63
|
}
|
|
60
64
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["configureStore","combineReducers","chatSettingsReducer","setUser","roomsSlice","
|
|
1
|
+
{"version":3,"names":["configureStore","combineReducers","chatSettingsReducer","setUser","roomsSlice","addRooms","roomHeapSlice","markMessageFailed","callReducer","unreadMiddleware","logoutMiddleware","newMessageMidlleware","reactionsMiddleware","isPerfProfilingEnabled","perfMiddleware","persistenceMiddleware","readPersistedState","computeBootTimeFailures","rootReducer","chatSettingStore","rooms","reducer","call","createChatStore","middleware","getDefaultMiddleware","base","serializableCheck","immutableCheck","chain","concat","globalScope","globalThis","store","__CHAT_STORE__","getActiveRoom","state","roomMessagesState","activeRoomJID","persistorReady","__CHAT_PERSISTOR_READY__","chat","heap","user","walletAddress","dispatch","restored","Object","entries","filter","jid","room","map","length","restoredFailed","failedMessages","payload","values","stillRendered","roomJID","messages","some","m","id","bootFailures"],"sourceRoot":"../../../src","sources":["roomStore/index.ts"],"mappings":";;AAAA,SAASA,cAAc,EAAEC,eAAe,QAAQ,kBAAkB;AAClE,OAAOC,mBAAmB,IAAIC,OAAO,QAAQ,qBAAqB;AAClE,OAAOC,UAAU,IAAIC,QAAQ,QAAQ,cAAc;AACnD,SAASC,aAAa,EAAEC,iBAAiB,QAAQ,iBAAiB;AAClE,OAAOC,WAAW,MAAM,aAAa;AAErC,SAASC,gBAAgB,QAAQ,+BAA+B;AAChE,SAASC,gBAAgB,QAAQ,+BAA+B;AAChE,SAASC,oBAAoB,QAAQ,mCAAmC;AACxE,SAASC,mBAAmB,QAAQ,kCAAkC;AACtE,SAASC,sBAAsB,EAAEC,cAAc,QAAQ,6BAA6B;AACpF,SACEC,qBAA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ACA;EACA,MAAMQ,YAAY,GAAG/C,uBAAuB,CAACG,KAAK,EAAEA,KAAK,EAAEkC,cAAc,CAAC;EAC1E,KAAK,MAAME,OAAO,IAAIQ,YAAY,EAAE;IAClC/B,KAAK,CAACY,QAAQ,CAACtC,iBAAiB,CAACiD,OAAO,CAAC,CAAC;EAC5C;AACF,CAAC,EAAE,CAAC,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import AsyncStorage from '@react-native-async-storage/async-storage';
|
|
4
|
+
import { secureGetOrCreate } from '../helpers/secureKeyValue';
|
|
5
|
+
import { encryptForPersist, decryptFromPersist } from '../helpers/persistCrypto';
|
|
6
|
+
const MMKV_INSTANCE_ID = 'ethora-chat-persist';
|
|
7
|
+
const MMKV_KEY_STORE_KEY = 'ethora_persist_mmkv_key';
|
|
8
|
+
const MMKV_KEY_LENGTH = 16;
|
|
9
|
+
const randomKey = length => {
|
|
10
|
+
const alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
|
11
|
+
const bytes = new Uint8Array(length);
|
|
12
|
+
globalThis.crypto.getRandomValues(bytes);
|
|
13
|
+
let out = '';
|
|
14
|
+
for (let i = 0; i < length; i++) {
|
|
15
|
+
out += alphabet[bytes[i] % alphabet.length];
|
|
16
|
+
}
|
|
17
|
+
return out;
|
|
18
|
+
};
|
|
19
|
+
const createMmkvBackend = async () => {
|
|
20
|
+
let MMKV;
|
|
21
|
+
try {
|
|
22
|
+
MMKV = require('react-native-mmkv').MMKV;
|
|
23
|
+
} catch {
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
if (typeof MMKV !== 'function') {
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
try {
|
|
30
|
+
const key = await secureGetOrCreate(MMKV_KEY_STORE_KEY, () => randomKey(MMKV_KEY_LENGTH));
|
|
31
|
+
if (!key) {
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
// Throws when the native module is missing from the binary.
|
|
35
|
+
const storage = new MMKV({
|
|
36
|
+
id: MMKV_INSTANCE_ID,
|
|
37
|
+
encryptionKey: key.value
|
|
38
|
+
});
|
|
39
|
+
if (key.created) {
|
|
40
|
+
storage.clearAll();
|
|
41
|
+
}
|
|
42
|
+
return {
|
|
43
|
+
name: 'mmkv',
|
|
44
|
+
getMany: async keys => keys.map(k => storage.getString(k) ?? null),
|
|
45
|
+
setMany: async pairs => {
|
|
46
|
+
for (const [k, v] of pairs) {
|
|
47
|
+
storage.set(k, v);
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
removeMany: async keys => {
|
|
51
|
+
for (const k of keys) {
|
|
52
|
+
storage.delete(k);
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
allKeys: async () => storage.getAllKeys()
|
|
56
|
+
};
|
|
57
|
+
} catch (e) {
|
|
58
|
+
console.warn('[persist] react-native-mmkv present but unusable, falling back', e);
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
const asyncStorageBackend = {
|
|
63
|
+
name: 'async-storage',
|
|
64
|
+
getMany: async keys => {
|
|
65
|
+
const pairs = await AsyncStorage.multiGet(keys);
|
|
66
|
+
return Promise.all(pairs.map(([, raw]) => raw ? decryptFromPersist(raw) : Promise.resolve(null)));
|
|
67
|
+
},
|
|
68
|
+
setMany: async pairs => {
|
|
69
|
+
const encrypted = await Promise.all(pairs.map(async ([k, v]) => [k, await encryptForPersist(v)]));
|
|
70
|
+
await AsyncStorage.multiSet(encrypted);
|
|
71
|
+
},
|
|
72
|
+
removeMany: keys => AsyncStorage.multiRemove(keys),
|
|
73
|
+
allKeys: async () => [...(await AsyncStorage.getAllKeys())]
|
|
74
|
+
};
|
|
75
|
+
let backendPromise = null;
|
|
76
|
+
export const getPersistBackend = () => {
|
|
77
|
+
if (!backendPromise) {
|
|
78
|
+
backendPromise = createMmkvBackend().then(mmkv => mmkv ?? asyncStorageBackend);
|
|
79
|
+
}
|
|
80
|
+
return backendPromise;
|
|
81
|
+
};
|
|
82
|
+
export const legacyAsyncStorageBackend = asyncStorageBackend;
|
|
83
|
+
export const __resetPersistBackend = () => {
|
|
84
|
+
backendPromise = null;
|
|
85
|
+
};
|
|
86
|
+
//# sourceMappingURL=persistBackend.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["AsyncStorage","secureGetOrCreate","encryptForPersist","decryptFromPersist","MMKV_INSTANCE_ID","MMKV_KEY_STORE_KEY","MMKV_KEY_LENGTH","randomKey","length","alphabet","bytes","Uint8Array","globalThis","crypto","getRandomValues","out","i","createMmkvBackend","MMKV","require","key","storage","id","encryptionKey","value","created","clearAll","name","getMany","keys","map","k","getString","setMany","pairs","v","set","removeMany","delete","allKeys","getAllKeys","e","console","warn","asyncStorageBackend","multiGet","Promise","all","raw","resolve","encrypted","multiSet","multiRemove","backendPromise","getPersistBackend","then","mmkv","legacyAsyncStorageBackend","__resetPersistBackend"],"sourceRoot":"../../../src","sources":["roomStore/persistBackend.ts"],"mappings":";;AAAA,OAAOA,YAAY,MAAM,2CAA2C;AACpE,SAASC,iBAAiB,QAAQ,2BAA2B;AAC7D,SAASC,iBAAiB,EAAEC,kBAAkB,QAAQ,0BAA0B;AAWhF,MAAMC,gBAAgB,GAAG,qBAAqB;AAC9C,MAAMC,kBAAkB,GAAG,yBAAyB;AACpD,MAAMC,eAAe,GAAG,EAAE;AAE1B,MAAMC,SAAS,GAAIC,MAAc,IAAa;EAC5C,MAAMC,QAAQ,GACZ,gEAAgE;EAClE,MAAMC,KAAK,GAAG,IAAIC,UAAU,CAACH,MAAM,CAAC;EACnCI,UAAU,CAASC,MAAM,CAACC,eAAe,CAACJ,KAAK,CAAC;EACjD,IAAIK,GAAG,GAAG,EAAE;EACZ,KAAK,IAAIC,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGR,MAAM,EAAEQ,CAAC,EAAE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