@ethora/chat-component-rn 26.10.9 → 26.10.11
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 +17 -0
- package/README.md +126 -1
- package/lib/commonjs/booking/index.js +44 -0
- package/lib/commonjs/booking/index.js.map +1 -0
- package/lib/commonjs/booking/pendingScheduledCall.js +275 -0
- package/lib/commonjs/booking/pendingScheduledCall.js.map +1 -0
- package/lib/commonjs/booking/scheduleForm.js +91 -0
- package/lib/commonjs/booking/scheduleForm.js.map +1 -0
- package/lib/commonjs/booking/scheduledCall.js +141 -0
- package/lib/commonjs/booking/scheduledCall.js.map +1 -0
- package/lib/commonjs/booking/scheduledCallActions.js +128 -0
- package/lib/commonjs/booking/scheduledCallActions.js.map +1 -0
- package/lib/commonjs/booking/scheduledCallLink.js +143 -0
- package/lib/commonjs/booking/scheduledCallLink.js.map +1 -0
- package/lib/commonjs/booking/scheduledCallStore.js +64 -0
- package/lib/commonjs/booking/scheduledCallStore.js.map +1 -0
- package/lib/commonjs/booking/startRoomCall.js +84 -0
- package/lib/commonjs/booking/startRoomCall.js.map +1 -0
- package/lib/commonjs/calls/callBusy.js +18 -0
- package/lib/commonjs/calls/callBusy.js.map +1 -0
- package/lib/commonjs/calls/callDisplay.js +73 -0
- package/lib/commonjs/calls/callDisplay.js.map +1 -0
- package/lib/commonjs/calls/callMode.js +175 -0
- package/lib/commonjs/calls/callMode.js.map +1 -0
- package/lib/commonjs/calls/declineReport.js +20 -0
- package/lib/commonjs/calls/declineReport.js.map +1 -0
- package/lib/commonjs/calls/p2p/P2PCallController.js +724 -0
- package/lib/commonjs/calls/p2p/P2PCallController.js.map +1 -0
- package/lib/commonjs/calls/p2p/icePolicy.js +107 -0
- package/lib/commonjs/calls/p2p/icePolicy.js.map +1 -0
- package/lib/commonjs/calls/p2p/negotiator.js +202 -0
- package/lib/commonjs/calls/p2p/negotiator.js.map +1 -0
- package/lib/commonjs/calls/p2p/p2pRuntime.js +147 -0
- package/lib/commonjs/calls/p2p/p2pRuntime.js.map +1 -0
- package/lib/commonjs/calls/p2p/signalInbox.js +98 -0
- package/lib/commonjs/calls/p2p/signalInbox.js.map +1 -0
- package/lib/commonjs/calls/p2p/signalStanza.js +141 -0
- package/lib/commonjs/calls/p2p/signalStanza.js.map +1 -0
- package/lib/commonjs/calls/p2p/webrtcRuntime.js +53 -0
- package/lib/commonjs/calls/p2p/webrtcRuntime.js.map +1 -0
- package/lib/commonjs/calls/senderTrust.js +43 -0
- package/lib/commonjs/calls/senderTrust.js.map +1 -0
- package/lib/commonjs/calls/startCall.js +51 -0
- package/lib/commonjs/calls/startCall.js.map +1 -0
- package/lib/commonjs/components/Booking/BookingIcons.js +55 -0
- package/lib/commonjs/components/Booking/BookingIcons.js.map +1 -0
- package/lib/commonjs/components/Booking/ScheduleCallButton.js +64 -0
- package/lib/commonjs/components/Booking/ScheduleCallButton.js.map +1 -0
- package/lib/commonjs/components/Booking/ScheduleCallSheet.js +351 -0
- package/lib/commonjs/components/Booking/ScheduleCallSheet.js.map +1 -0
- package/lib/commonjs/components/Booking/ScheduledCallCard.js +203 -0
- package/lib/commonjs/components/Booking/ScheduledCallCard.js.map +1 -0
- package/lib/commonjs/components/Booking/ScheduledCallHost.js +23 -0
- package/lib/commonjs/components/Booking/ScheduledCallHost.js.map +1 -0
- package/lib/commonjs/components/Booking/ScheduledCallMessage.js +55 -0
- package/lib/commonjs/components/Booking/ScheduledCallMessage.js.map +1 -0
- package/lib/commonjs/components/Booking/ScheduledCallPreJoin.js +235 -0
- package/lib/commonjs/components/Booking/ScheduledCallPreJoin.js.map +1 -0
- package/lib/commonjs/components/Booking/bookingShared.js +305 -0
- package/lib/commonjs/components/Booking/bookingShared.js.map +1 -0
- package/lib/commonjs/components/MainComponents/AlbumGrid.js +6 -2
- package/lib/commonjs/components/MainComponents/AlbumGrid.js.map +1 -1
- package/lib/commonjs/components/MainComponents/ChatHeader.js +18 -12
- package/lib/commonjs/components/MainComponents/ChatHeader.js.map +1 -1
- package/lib/commonjs/components/MainComponents/LanguageSelectorButton.js +5 -2
- package/lib/commonjs/components/MainComponents/LanguageSelectorButton.js.map +1 -1
- package/lib/commonjs/components/MainComponents/LanguageSelectorModal.js +6 -3
- package/lib/commonjs/components/MainComponents/LanguageSelectorModal.js.map +1 -1
- package/lib/commonjs/components/MainComponents/MediaMessage.js +13 -0
- package/lib/commonjs/components/MainComponents/MediaMessage.js.map +1 -1
- package/lib/commonjs/components/MainComponents/MessageContainer.js +13 -0
- package/lib/commonjs/components/MainComponents/MessageContainer.js.map +1 -1
- package/lib/commonjs/components/MainComponents/ReduxWrapper.js +10 -0
- package/lib/commonjs/components/MainComponents/ReduxWrapper.js.map +1 -1
- package/lib/commonjs/components/MainComponents/RoomList.js +7 -16
- package/lib/commonjs/components/MainComponents/RoomList.js.map +1 -1
- package/lib/commonjs/components/MessageBubble/Message.js +27 -1
- package/lib/commonjs/components/MessageBubble/Message.js.map +1 -1
- package/lib/commonjs/components/Modals/ChatProfileModal/ChatMediaGrid.js +159 -0
- package/lib/commonjs/components/Modals/ChatProfileModal/ChatMediaGrid.js.map +1 -0
- package/lib/commonjs/components/Modals/ChatProfileModal/ChatProfileModal.js +203 -134
- package/lib/commonjs/components/Modals/ChatProfileModal/ChatProfileModal.js.map +1 -1
- package/lib/commonjs/components/Modals/ChatProfileModal/LeaveChatModal.js +180 -0
- package/lib/commonjs/components/Modals/ChatProfileModal/LeaveChatModal.js.map +1 -0
- package/lib/commonjs/components/Modals/ChatProfileModal/ReportChatModal.js +19 -15
- package/lib/commonjs/components/Modals/ChatProfileModal/ReportChatModal.js.map +1 -1
- package/lib/commonjs/components/Modals/FilePreviewModal/FilePreviewModal.js +100 -162
- package/lib/commonjs/components/Modals/FilePreviewModal/FilePreviewModal.js.map +1 -1
- package/lib/commonjs/components/Modals/FilePreviewModal/MediaViewer.js +824 -0
- package/lib/commonjs/components/Modals/FilePreviewModal/MediaViewer.js.map +1 -0
- package/lib/commonjs/components/Modals/FilePreviewModal/useSaveFile.js +179 -0
- package/lib/commonjs/components/Modals/FilePreviewModal/useSaveFile.js.map +1 -0
- package/lib/commonjs/components/Modals/MessageSearchModal/MessageSearchModal.js +22 -5
- package/lib/commonjs/components/Modals/MessageSearchModal/MessageSearchModal.js.map +1 -1
- package/lib/commonjs/components/Modals/UserProfileModal/UserProfileModal.js +15 -8
- package/lib/commonjs/components/Modals/UserProfileModal/UserProfileModal.js.map +1 -1
- package/lib/commonjs/components/Modals/UserSettingsModal/LanguageCard.js +1 -1
- package/lib/commonjs/components/Modals/UserSettingsModal/LanguageCard.js.map +1 -1
- package/lib/commonjs/components/VideoCalls/ActiveCallBar.js +3 -2
- package/lib/commonjs/components/VideoCalls/ActiveCallBar.js.map +1 -1
- package/lib/commonjs/components/VideoCalls/CallButtons.js +19 -11
- package/lib/commonjs/components/VideoCalls/CallButtons.js.map +1 -1
- package/lib/commonjs/components/VideoCalls/CallControlBar.js +119 -0
- package/lib/commonjs/components/VideoCalls/CallControlBar.js.map +1 -0
- package/lib/commonjs/components/VideoCalls/CallVideo.js +49 -0
- package/lib/commonjs/components/VideoCalls/CallVideo.js.map +1 -0
- package/lib/commonjs/components/VideoCalls/GroupCallView.js +281 -0
- package/lib/commonjs/components/VideoCalls/GroupCallView.js.map +1 -0
- package/lib/commonjs/components/VideoCalls/P2PCallRunner.js +151 -0
- package/lib/commonjs/components/VideoCalls/P2PCallRunner.js.map +1 -0
- package/lib/commonjs/components/VideoCalls/VideoCallOverlay.js +38 -14
- package/lib/commonjs/components/VideoCalls/VideoCallOverlay.js.map +1 -1
- package/lib/commonjs/components/VideoCalls/VideoCallSession.js +57 -128
- package/lib/commonjs/components/VideoCalls/VideoCallSession.js.map +1 -1
- package/lib/commonjs/components/VideoCalls/callActions.js +3 -0
- package/lib/commonjs/components/VideoCalls/callActions.js.map +1 -1
- package/lib/commonjs/components/VideoCalls/callElapsed.js +38 -0
- package/lib/commonjs/components/VideoCalls/callElapsed.js.map +1 -0
- package/lib/commonjs/components/VideoCalls/callLive.js +15 -0
- package/lib/commonjs/components/VideoCalls/callLive.js.map +1 -0
- package/lib/commonjs/components/VideoCalls/callSessionController.js +81 -24
- package/lib/commonjs/components/VideoCalls/callSessionController.js.map +1 -1
- package/lib/commonjs/components/VideoCalls/callSessionTypes.js +41 -0
- package/lib/commonjs/components/VideoCalls/callSessionTypes.js.map +1 -0
- package/lib/commonjs/components/VideoCalls/groupLayout.js +43 -0
- package/lib/commonjs/components/VideoCalls/groupLayout.js.map +1 -0
- package/lib/commonjs/components/VideoCalls/p2pCallSession.js +272 -0
- package/lib/commonjs/components/VideoCalls/p2pCallSession.js.map +1 -0
- package/lib/commonjs/components/VideoCalls/useCallKeep.js +7 -2
- package/lib/commonjs/components/VideoCalls/useCallKeep.js.map +1 -1
- package/lib/commonjs/components/VideoCalls/useOngoingCallNotification.js +2 -1
- package/lib/commonjs/components/VideoCalls/useOngoingCallNotification.js.map +1 -1
- package/lib/commonjs/components/styled/MessageImage.js +4 -1
- package/lib/commonjs/components/styled/MessageImage.js.map +1 -1
- package/lib/commonjs/components/styled/VideoMessage.js +5 -1
- package/lib/commonjs/components/styled/VideoMessage.js.map +1 -1
- package/lib/commonjs/context/MediaSourceContext.js +18 -0
- package/lib/commonjs/context/MediaSourceContext.js.map +1 -0
- package/lib/commonjs/context/xmppProvider.js +2 -1
- package/lib/commonjs/context/xmppProvider.js.map +1 -1
- package/lib/commonjs/helpers/callPush.js +3 -1
- package/lib/commonjs/helpers/callPush.js.map +1 -1
- package/lib/commonjs/helpers/constants/MODAL_COMPONENTS.js +3 -1
- package/lib/commonjs/helpers/constants/MODAL_COMPONENTS.js.map +1 -1
- package/lib/commonjs/helpers/constants/MODAL_TYPES.js +2 -0
- package/lib/commonjs/helpers/constants/MODAL_TYPES.js.map +1 -1
- package/lib/commonjs/helpers/incomingCallFromPush.js +63 -7
- package/lib/commonjs/helpers/incomingCallFromPush.js.map +1 -1
- package/lib/commonjs/helpers/publicChatsEntry.js +8 -6
- package/lib/commonjs/helpers/publicChatsEntry.js.map +1 -1
- package/lib/commonjs/helpers/pushPayload.js +5 -0
- package/lib/commonjs/helpers/pushPayload.js.map +1 -1
- package/lib/commonjs/helpers/reportRoom.js +76 -0
- package/lib/commonjs/helpers/reportRoom.js.map +1 -0
- package/lib/commonjs/helpers/roomMedia.js +118 -0
- package/lib/commonjs/helpers/roomMedia.js.map +1 -0
- package/lib/commonjs/i18n/strings.js +480 -0
- package/lib/commonjs/i18n/strings.js.map +1 -1
- package/lib/commonjs/main.js +93 -0
- package/lib/commonjs/main.js.map +1 -1
- package/lib/commonjs/networking/api-requests/callState.api.js +75 -0
- package/lib/commonjs/networking/api-requests/callState.api.js.map +1 -0
- package/lib/commonjs/networking/api-requests/push.api.js +29 -6
- package/lib/commonjs/networking/api-requests/push.api.js.map +1 -1
- package/lib/commonjs/networking/api-requests/rooms.api.js +17 -15
- package/lib/commonjs/networking/api-requests/rooms.api.js.map +1 -1
- package/lib/commonjs/networking/api-requests/scheduledCalls.api.js +141 -0
- package/lib/commonjs/networking/api-requests/scheduledCalls.api.js.map +1 -0
- package/lib/commonjs/networking/callTokenStanza.js +210 -50
- package/lib/commonjs/networking/callTokenStanza.js.map +1 -1
- package/lib/commonjs/roomStore/callSlice.js +59 -4
- package/lib/commonjs/roomStore/callSlice.js.map +1 -1
- package/lib/commonjs/services/appBadge.js +80 -0
- package/lib/commonjs/services/appBadge.js.map +1 -0
- package/lib/commonjs/services/languageSettings.js +47 -15
- package/lib/commonjs/services/languageSettings.js.map +1 -1
- package/lib/commonjs/services/pushRegistration.js +21 -5
- package/lib/commonjs/services/pushRegistration.js.map +1 -1
- package/lib/commonjs/version.js +1 -1
- package/lib/commonjs/version.js.map +1 -1
- package/lib/module/booking/index.js +5 -0
- package/lib/module/booking/index.js.map +1 -0
- package/lib/module/booking/pendingScheduledCall.js +261 -0
- package/lib/module/booking/pendingScheduledCall.js.map +1 -0
- package/lib/module/booking/scheduleForm.js +79 -0
- package/lib/module/booking/scheduleForm.js.map +1 -0
- package/lib/module/booking/scheduledCall.js +129 -0
- package/lib/module/booking/scheduledCall.js.map +1 -0
- package/lib/module/booking/scheduledCallActions.js +118 -0
- package/lib/module/booking/scheduledCallActions.js.map +1 -0
- package/lib/module/booking/scheduledCallLink.js +136 -0
- package/lib/module/booking/scheduledCallLink.js.map +1 -0
- package/lib/module/booking/scheduledCallStore.js +60 -0
- package/lib/module/booking/scheduledCallStore.js.map +1 -0
- package/lib/module/booking/startRoomCall.js +80 -0
- package/lib/module/booking/startRoomCall.js.map +1 -0
- package/lib/module/calls/callBusy.js +13 -0
- package/lib/module/calls/callBusy.js.map +1 -0
- package/lib/module/calls/callDisplay.js +65 -0
- package/lib/module/calls/callDisplay.js.map +1 -0
- package/lib/module/calls/callMode.js +168 -0
- package/lib/module/calls/callMode.js.map +1 -0
- package/lib/module/calls/declineReport.js +16 -0
- package/lib/module/calls/declineReport.js.map +1 -0
- package/lib/module/calls/p2p/P2PCallController.js +718 -0
- package/lib/module/calls/p2p/P2PCallController.js.map +1 -0
- package/lib/module/calls/p2p/icePolicy.js +102 -0
- package/lib/module/calls/p2p/icePolicy.js.map +1 -0
- package/lib/module/calls/p2p/negotiator.js +197 -0
- package/lib/module/calls/p2p/negotiator.js.map +1 -0
- package/lib/module/calls/p2p/p2pRuntime.js +137 -0
- package/lib/module/calls/p2p/p2pRuntime.js.map +1 -0
- package/lib/module/calls/p2p/signalInbox.js +93 -0
- package/lib/module/calls/p2p/signalInbox.js.map +1 -0
- package/lib/module/calls/p2p/signalStanza.js +135 -0
- package/lib/module/calls/p2p/signalStanza.js.map +1 -0
- package/lib/module/calls/p2p/webrtcRuntime.js +46 -0
- package/lib/module/calls/p2p/webrtcRuntime.js.map +1 -0
- package/lib/module/calls/senderTrust.js +38 -0
- package/lib/module/calls/senderTrust.js.map +1 -0
- package/lib/module/calls/startCall.js +47 -0
- package/lib/module/calls/startCall.js.map +1 -0
- package/lib/module/components/Booking/BookingIcons.js +48 -0
- package/lib/module/components/Booking/BookingIcons.js.map +1 -0
- package/lib/module/components/Booking/ScheduleCallButton.js +59 -0
- package/lib/module/components/Booking/ScheduleCallButton.js.map +1 -0
- package/lib/module/components/Booking/ScheduleCallSheet.js +345 -0
- package/lib/module/components/Booking/ScheduleCallSheet.js.map +1 -0
- package/lib/module/components/Booking/ScheduledCallCard.js +197 -0
- package/lib/module/components/Booking/ScheduledCallCard.js.map +1 -0
- package/lib/module/components/Booking/ScheduledCallHost.js +18 -0
- package/lib/module/components/Booking/ScheduledCallHost.js.map +1 -0
- package/lib/module/components/Booking/ScheduledCallMessage.js +48 -0
- package/lib/module/components/Booking/ScheduledCallMessage.js.map +1 -0
- package/lib/module/components/Booking/ScheduledCallPreJoin.js +229 -0
- package/lib/module/components/Booking/ScheduledCallPreJoin.js.map +1 -0
- package/lib/module/components/Booking/bookingShared.js +291 -0
- package/lib/module/components/Booking/bookingShared.js.map +1 -0
- package/lib/module/components/MainComponents/AlbumGrid.js +6 -2
- package/lib/module/components/MainComponents/AlbumGrid.js.map +1 -1
- package/lib/module/components/MainComponents/ChatHeader.js +20 -14
- package/lib/module/components/MainComponents/ChatHeader.js.map +1 -1
- package/lib/module/components/MainComponents/LanguageSelectorButton.js +5 -2
- package/lib/module/components/MainComponents/LanguageSelectorButton.js.map +1 -1
- package/lib/module/components/MainComponents/LanguageSelectorModal.js +7 -4
- package/lib/module/components/MainComponents/LanguageSelectorModal.js.map +1 -1
- package/lib/module/components/MainComponents/MediaMessage.js +13 -0
- package/lib/module/components/MainComponents/MediaMessage.js.map +1 -1
- package/lib/module/components/MainComponents/MessageContainer.js +13 -0
- package/lib/module/components/MainComponents/MessageContainer.js.map +1 -1
- package/lib/module/components/MainComponents/ReduxWrapper.js +10 -0
- package/lib/module/components/MainComponents/ReduxWrapper.js.map +1 -1
- package/lib/module/components/MainComponents/RoomList.js +7 -16
- package/lib/module/components/MainComponents/RoomList.js.map +1 -1
- package/lib/module/components/MessageBubble/Message.js +27 -1
- package/lib/module/components/MessageBubble/Message.js.map +1 -1
- package/lib/module/components/Modals/ChatProfileModal/ChatMediaGrid.js +154 -0
- package/lib/module/components/Modals/ChatProfileModal/ChatMediaGrid.js.map +1 -0
- package/lib/module/components/Modals/ChatProfileModal/ChatProfileModal.js +204 -136
- package/lib/module/components/Modals/ChatProfileModal/ChatProfileModal.js.map +1 -1
- package/lib/module/components/Modals/ChatProfileModal/LeaveChatModal.js +175 -0
- package/lib/module/components/Modals/ChatProfileModal/LeaveChatModal.js.map +1 -0
- package/lib/module/components/Modals/ChatProfileModal/ReportChatModal.js +21 -15
- package/lib/module/components/Modals/ChatProfileModal/ReportChatModal.js.map +1 -1
- package/lib/module/components/Modals/FilePreviewModal/FilePreviewModal.js +100 -163
- package/lib/module/components/Modals/FilePreviewModal/FilePreviewModal.js.map +1 -1
- package/lib/module/components/Modals/FilePreviewModal/MediaViewer.js +819 -0
- package/lib/module/components/Modals/FilePreviewModal/MediaViewer.js.map +1 -0
- package/lib/module/components/Modals/FilePreviewModal/useSaveFile.js +172 -0
- package/lib/module/components/Modals/FilePreviewModal/useSaveFile.js.map +1 -0
- package/lib/module/components/Modals/MessageSearchModal/MessageSearchModal.js +20 -4
- package/lib/module/components/Modals/MessageSearchModal/MessageSearchModal.js.map +1 -1
- package/lib/module/components/Modals/UserProfileModal/UserProfileModal.js +17 -10
- package/lib/module/components/Modals/UserProfileModal/UserProfileModal.js.map +1 -1
- package/lib/module/components/Modals/UserSettingsModal/LanguageCard.js +1 -1
- package/lib/module/components/Modals/UserSettingsModal/LanguageCard.js.map +1 -1
- package/lib/module/components/VideoCalls/ActiveCallBar.js +3 -2
- package/lib/module/components/VideoCalls/ActiveCallBar.js.map +1 -1
- package/lib/module/components/VideoCalls/CallButtons.js +19 -11
- package/lib/module/components/VideoCalls/CallButtons.js.map +1 -1
- package/lib/module/components/VideoCalls/CallControlBar.js +113 -0
- package/lib/module/components/VideoCalls/CallControlBar.js.map +1 -0
- package/lib/module/components/VideoCalls/CallVideo.js +43 -0
- package/lib/module/components/VideoCalls/CallVideo.js.map +1 -0
- package/lib/module/components/VideoCalls/GroupCallView.js +275 -0
- package/lib/module/components/VideoCalls/GroupCallView.js.map +1 -0
- package/lib/module/components/VideoCalls/P2PCallRunner.js +147 -0
- package/lib/module/components/VideoCalls/P2PCallRunner.js.map +1 -0
- package/lib/module/components/VideoCalls/VideoCallOverlay.js +38 -14
- package/lib/module/components/VideoCalls/VideoCallOverlay.js.map +1 -1
- package/lib/module/components/VideoCalls/VideoCallSession.js +46 -127
- package/lib/module/components/VideoCalls/VideoCallSession.js.map +1 -1
- package/lib/module/components/VideoCalls/callActions.js +3 -0
- package/lib/module/components/VideoCalls/callActions.js.map +1 -1
- package/lib/module/components/VideoCalls/callElapsed.js +33 -0
- package/lib/module/components/VideoCalls/callElapsed.js.map +1 -0
- package/lib/module/components/VideoCalls/callLive.js +10 -0
- package/lib/module/components/VideoCalls/callLive.js.map +1 -0
- package/lib/module/components/VideoCalls/callSessionController.js +80 -24
- package/lib/module/components/VideoCalls/callSessionController.js.map +1 -1
- package/lib/module/components/VideoCalls/callSessionTypes.js +37 -0
- package/lib/module/components/VideoCalls/callSessionTypes.js.map +1 -0
- package/lib/module/components/VideoCalls/groupLayout.js +36 -0
- package/lib/module/components/VideoCalls/groupLayout.js.map +1 -0
- package/lib/module/components/VideoCalls/p2pCallSession.js +256 -0
- package/lib/module/components/VideoCalls/p2pCallSession.js.map +1 -0
- package/lib/module/components/VideoCalls/useCallKeep.js +8 -2
- package/lib/module/components/VideoCalls/useCallKeep.js.map +1 -1
- package/lib/module/components/VideoCalls/useOngoingCallNotification.js +2 -1
- package/lib/module/components/VideoCalls/useOngoingCallNotification.js.map +1 -1
- package/lib/module/components/styled/MessageImage.js +4 -1
- package/lib/module/components/styled/MessageImage.js.map +1 -1
- package/lib/module/components/styled/VideoMessage.js +5 -1
- package/lib/module/components/styled/VideoMessage.js.map +1 -1
- package/lib/module/context/MediaSourceContext.js +13 -0
- package/lib/module/context/MediaSourceContext.js.map +1 -0
- package/lib/module/context/xmppProvider.js +2 -1
- package/lib/module/context/xmppProvider.js.map +1 -1
- package/lib/module/helpers/callPush.js +3 -1
- package/lib/module/helpers/callPush.js.map +1 -1
- package/lib/module/helpers/constants/MODAL_COMPONENTS.js +2 -1
- package/lib/module/helpers/constants/MODAL_COMPONENTS.js.map +1 -1
- package/lib/module/helpers/constants/MODAL_TYPES.js +2 -0
- package/lib/module/helpers/constants/MODAL_TYPES.js.map +1 -1
- package/lib/module/helpers/incomingCallFromPush.js +63 -7
- package/lib/module/helpers/incomingCallFromPush.js.map +1 -1
- package/lib/module/helpers/publicChatsEntry.js +8 -6
- package/lib/module/helpers/publicChatsEntry.js.map +1 -1
- package/lib/module/helpers/pushPayload.js +5 -0
- package/lib/module/helpers/pushPayload.js.map +1 -1
- package/lib/module/helpers/reportRoom.js +70 -0
- package/lib/module/helpers/reportRoom.js.map +1 -0
- package/lib/module/helpers/roomMedia.js +112 -0
- package/lib/module/helpers/roomMedia.js.map +1 -0
- package/lib/module/i18n/strings.js +480 -0
- package/lib/module/i18n/strings.js.map +1 -1
- package/lib/module/main.js +5 -0
- package/lib/module/main.js.map +1 -1
- package/lib/module/networking/api-requests/callState.api.js +66 -0
- package/lib/module/networking/api-requests/callState.api.js.map +1 -0
- package/lib/module/networking/api-requests/push.api.js +29 -6
- package/lib/module/networking/api-requests/push.api.js.map +1 -1
- package/lib/module/networking/api-requests/rooms.api.js +17 -15
- package/lib/module/networking/api-requests/rooms.api.js.map +1 -1
- package/lib/module/networking/api-requests/scheduledCalls.api.js +130 -0
- package/lib/module/networking/api-requests/scheduledCalls.api.js.map +1 -0
- package/lib/module/networking/callTokenStanza.js +210 -50
- package/lib/module/networking/callTokenStanza.js.map +1 -1
- package/lib/module/roomStore/callSlice.js +57 -3
- package/lib/module/roomStore/callSlice.js.map +1 -1
- package/lib/module/services/appBadge.js +74 -0
- package/lib/module/services/appBadge.js.map +1 -0
- package/lib/module/services/languageSettings.js +44 -13
- package/lib/module/services/languageSettings.js.map +1 -1
- package/lib/module/services/pushRegistration.js +21 -5
- package/lib/module/services/pushRegistration.js.map +1 -1
- package/lib/module/version.js +1 -1
- package/lib/module/version.js.map +1 -1
- package/lib/typescript/booking/index.d.ts +3 -0
- package/lib/typescript/booking/index.d.ts.map +1 -0
- package/lib/typescript/booking/pendingScheduledCall.d.ts +80 -0
- package/lib/typescript/booking/pendingScheduledCall.d.ts.map +1 -0
- package/lib/typescript/booking/scheduleForm.d.ts +28 -0
- package/lib/typescript/booking/scheduleForm.d.ts.map +1 -0
- package/lib/typescript/booking/scheduledCall.d.ts +52 -0
- package/lib/typescript/booking/scheduledCall.d.ts.map +1 -0
- package/lib/typescript/booking/scheduledCallActions.d.ts +22 -0
- package/lib/typescript/booking/scheduledCallActions.d.ts.map +1 -0
- package/lib/typescript/booking/scheduledCallLink.d.ts +37 -0
- package/lib/typescript/booking/scheduledCallLink.d.ts.map +1 -0
- package/lib/typescript/booking/scheduledCallStore.d.ts +47 -0
- package/lib/typescript/booking/scheduledCallStore.d.ts.map +1 -0
- package/lib/typescript/booking/startRoomCall.d.ts +12 -0
- package/lib/typescript/booking/startRoomCall.d.ts.map +1 -0
- package/lib/typescript/calls/callBusy.d.ts +9 -0
- package/lib/typescript/calls/callBusy.d.ts.map +1 -0
- package/lib/typescript/calls/callDisplay.d.ts +23 -0
- package/lib/typescript/calls/callDisplay.d.ts.map +1 -0
- package/lib/typescript/calls/callMode.d.ts +106 -0
- package/lib/typescript/calls/callMode.d.ts.map +1 -0
- package/lib/typescript/calls/declineReport.d.ts +11 -0
- package/lib/typescript/calls/declineReport.d.ts.map +1 -0
- package/lib/typescript/calls/p2p/P2PCallController.d.ts +150 -0
- package/lib/typescript/calls/p2p/P2PCallController.d.ts.map +1 -0
- package/lib/typescript/calls/p2p/icePolicy.d.ts +37 -0
- package/lib/typescript/calls/p2p/icePolicy.d.ts.map +1 -0
- package/lib/typescript/calls/p2p/negotiator.d.ts +57 -0
- package/lib/typescript/calls/p2p/negotiator.d.ts.map +1 -0
- package/lib/typescript/calls/p2p/p2pRuntime.d.ts +41 -0
- package/lib/typescript/calls/p2p/p2pRuntime.d.ts.map +1 -0
- package/lib/typescript/calls/p2p/signalInbox.d.ts +35 -0
- package/lib/typescript/calls/p2p/signalInbox.d.ts.map +1 -0
- package/lib/typescript/calls/p2p/signalStanza.d.ts +52 -0
- package/lib/typescript/calls/p2p/signalStanza.d.ts.map +1 -0
- package/lib/typescript/calls/p2p/webrtcRuntime.d.ts +32 -0
- package/lib/typescript/calls/p2p/webrtcRuntime.d.ts.map +1 -0
- package/lib/typescript/calls/senderTrust.d.ts +8 -0
- package/lib/typescript/calls/senderTrust.d.ts.map +1 -0
- package/lib/typescript/calls/startCall.d.ts +17 -0
- package/lib/typescript/calls/startCall.d.ts.map +1 -0
- package/lib/typescript/components/Booking/BookingIcons.d.ts +9 -0
- package/lib/typescript/components/Booking/BookingIcons.d.ts.map +1 -0
- package/lib/typescript/components/Booking/ScheduleCallButton.d.ts +11 -0
- package/lib/typescript/components/Booking/ScheduleCallButton.d.ts.map +1 -0
- package/lib/typescript/components/Booking/ScheduleCallSheet.d.ts +4 -0
- package/lib/typescript/components/Booking/ScheduleCallSheet.d.ts.map +1 -0
- package/lib/typescript/components/Booking/ScheduledCallCard.d.ts +14 -0
- package/lib/typescript/components/Booking/ScheduledCallCard.d.ts.map +1 -0
- package/lib/typescript/components/Booking/ScheduledCallHost.d.ts +10 -0
- package/lib/typescript/components/Booking/ScheduledCallHost.d.ts.map +1 -0
- package/lib/typescript/components/Booking/ScheduledCallMessage.d.ts +20 -0
- package/lib/typescript/components/Booking/ScheduledCallMessage.d.ts.map +1 -0
- package/lib/typescript/components/Booking/ScheduledCallPreJoin.d.ts +8 -0
- package/lib/typescript/components/Booking/ScheduledCallPreJoin.d.ts.map +1 -0
- package/lib/typescript/components/Booking/bookingShared.d.ts +199 -0
- package/lib/typescript/components/Booking/bookingShared.d.ts.map +1 -0
- package/lib/typescript/components/MainComponents/AlbumGrid.d.ts.map +1 -1
- package/lib/typescript/components/MainComponents/ChatHeader.d.ts.map +1 -1
- package/lib/typescript/components/MainComponents/LanguageSelectorButton.d.ts +3 -1
- package/lib/typescript/components/MainComponents/LanguageSelectorButton.d.ts.map +1 -1
- package/lib/typescript/components/MainComponents/LanguageSelectorModal.d.ts.map +1 -1
- package/lib/typescript/components/MainComponents/MediaMessage.d.ts +3 -1
- package/lib/typescript/components/MainComponents/MediaMessage.d.ts.map +1 -1
- package/lib/typescript/components/MainComponents/MessageContainer.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/MessageBubble/Message.d.ts.map +1 -1
- package/lib/typescript/components/Modals/ChatProfileModal/ChatMediaGrid.d.ts +16 -0
- package/lib/typescript/components/Modals/ChatProfileModal/ChatMediaGrid.d.ts.map +1 -0
- package/lib/typescript/components/Modals/ChatProfileModal/ChatProfileModal.d.ts.map +1 -1
- package/lib/typescript/components/Modals/ChatProfileModal/LeaveChatModal.d.ts +18 -0
- package/lib/typescript/components/Modals/ChatProfileModal/LeaveChatModal.d.ts.map +1 -0
- package/lib/typescript/components/Modals/ChatProfileModal/ReportChatModal.d.ts.map +1 -1
- package/lib/typescript/components/Modals/FilePreviewModal/FilePreviewModal.d.ts +16 -0
- package/lib/typescript/components/Modals/FilePreviewModal/FilePreviewModal.d.ts.map +1 -1
- package/lib/typescript/components/Modals/FilePreviewModal/MediaViewer.d.ts +27 -0
- package/lib/typescript/components/Modals/FilePreviewModal/MediaViewer.d.ts.map +1 -0
- package/lib/typescript/components/Modals/FilePreviewModal/useSaveFile.d.ts +9 -0
- package/lib/typescript/components/Modals/FilePreviewModal/useSaveFile.d.ts.map +1 -0
- package/lib/typescript/components/Modals/MessageSearchModal/MessageSearchModal.d.ts +8 -0
- package/lib/typescript/components/Modals/MessageSearchModal/MessageSearchModal.d.ts.map +1 -1
- package/lib/typescript/components/Modals/UserProfileModal/UserProfileModal.d.ts.map +1 -1
- package/lib/typescript/components/Modals/UserSettingsModal/LanguageCard.d.ts.map +1 -1
- package/lib/typescript/components/VideoCalls/ActiveCallBar.d.ts.map +1 -1
- package/lib/typescript/components/VideoCalls/CallButtons.d.ts +2 -1
- package/lib/typescript/components/VideoCalls/CallButtons.d.ts.map +1 -1
- package/lib/typescript/components/VideoCalls/CallControlBar.d.ts +17 -0
- package/lib/typescript/components/VideoCalls/CallControlBar.d.ts.map +1 -0
- package/lib/typescript/components/VideoCalls/CallVideo.d.ts +23 -0
- package/lib/typescript/components/VideoCalls/CallVideo.d.ts.map +1 -0
- package/lib/typescript/components/VideoCalls/GroupCallView.d.ts +22 -0
- package/lib/typescript/components/VideoCalls/GroupCallView.d.ts.map +1 -0
- package/lib/typescript/components/VideoCalls/P2PCallRunner.d.ts +2 -0
- package/lib/typescript/components/VideoCalls/P2PCallRunner.d.ts.map +1 -0
- package/lib/typescript/components/VideoCalls/VideoCallOverlay.d.ts.map +1 -1
- package/lib/typescript/components/VideoCalls/VideoCallSession.d.ts +10 -12
- package/lib/typescript/components/VideoCalls/VideoCallSession.d.ts.map +1 -1
- package/lib/typescript/components/VideoCalls/callActions.d.ts.map +1 -1
- package/lib/typescript/components/VideoCalls/callElapsed.d.ts +8 -0
- package/lib/typescript/components/VideoCalls/callElapsed.d.ts.map +1 -0
- package/lib/typescript/components/VideoCalls/callLive.d.ts +9 -0
- package/lib/typescript/components/VideoCalls/callLive.d.ts.map +1 -0
- package/lib/typescript/components/VideoCalls/callSessionController.d.ts +10 -31
- package/lib/typescript/components/VideoCalls/callSessionController.d.ts.map +1 -1
- package/lib/typescript/components/VideoCalls/callSessionTypes.d.ts +60 -0
- package/lib/typescript/components/VideoCalls/callSessionTypes.d.ts.map +1 -0
- package/lib/typescript/components/VideoCalls/groupLayout.d.ts +23 -0
- package/lib/typescript/components/VideoCalls/groupLayout.d.ts.map +1 -0
- package/lib/typescript/components/VideoCalls/p2pCallSession.d.ts +31 -0
- package/lib/typescript/components/VideoCalls/p2pCallSession.d.ts.map +1 -0
- package/lib/typescript/components/VideoCalls/useCallKeep.d.ts.map +1 -1
- package/lib/typescript/components/VideoCalls/useOngoingCallNotification.d.ts.map +1 -1
- package/lib/typescript/components/styled/MessageImage.d.ts.map +1 -1
- package/lib/typescript/components/styled/VideoMessage.d.ts.map +1 -1
- package/lib/typescript/context/MediaSourceContext.d.ts +4 -0
- package/lib/typescript/context/MediaSourceContext.d.ts.map +1 -0
- package/lib/typescript/context/xmppProvider.d.ts.map +1 -1
- package/lib/typescript/helpers/callPush.d.ts +11 -1
- package/lib/typescript/helpers/callPush.d.ts.map +1 -1
- package/lib/typescript/helpers/constants/MODAL_COMPONENTS.d.ts.map +1 -1
- package/lib/typescript/helpers/constants/MODAL_TYPES.d.ts +2 -0
- package/lib/typescript/helpers/constants/MODAL_TYPES.d.ts.map +1 -1
- package/lib/typescript/helpers/incomingCallFromPush.d.ts.map +1 -1
- package/lib/typescript/helpers/publicChatsEntry.d.ts +7 -5
- package/lib/typescript/helpers/publicChatsEntry.d.ts.map +1 -1
- package/lib/typescript/helpers/pushPayload.d.ts +1 -1
- package/lib/typescript/helpers/pushPayload.d.ts.map +1 -1
- package/lib/typescript/helpers/reportRoom.d.ts +19 -0
- package/lib/typescript/helpers/reportRoom.d.ts.map +1 -0
- package/lib/typescript/helpers/roomMedia.d.ts +26 -0
- package/lib/typescript/helpers/roomMedia.d.ts.map +1 -0
- package/lib/typescript/i18n/strings.d.ts.map +1 -1
- package/lib/typescript/main.d.ts +6 -1
- package/lib/typescript/main.d.ts.map +1 -1
- package/lib/typescript/networking/api-requests/callState.api.d.ts +25 -0
- package/lib/typescript/networking/api-requests/callState.api.d.ts.map +1 -0
- package/lib/typescript/networking/api-requests/push.api.d.ts +9 -2
- package/lib/typescript/networking/api-requests/push.api.d.ts.map +1 -1
- package/lib/typescript/networking/api-requests/rooms.api.d.ts +8 -6
- package/lib/typescript/networking/api-requests/rooms.api.d.ts.map +1 -1
- package/lib/typescript/networking/api-requests/scheduledCalls.api.d.ts +86 -0
- package/lib/typescript/networking/api-requests/scheduledCalls.api.d.ts.map +1 -0
- package/lib/typescript/networking/callTokenStanza.d.ts.map +1 -1
- package/lib/typescript/roomStore/callSlice.d.ts +23 -1
- package/lib/typescript/roomStore/callSlice.d.ts.map +1 -1
- package/lib/typescript/services/appBadge.d.ts +3 -0
- package/lib/typescript/services/appBadge.d.ts.map +1 -0
- package/lib/typescript/services/languageSettings.d.ts +7 -0
- package/lib/typescript/services/languageSettings.d.ts.map +1 -1
- package/lib/typescript/services/pushRegistration.d.ts.map +1 -1
- package/lib/typescript/types/models/modal.model.d.ts +18 -0
- package/lib/typescript/types/models/modal.model.d.ts.map +1 -1
- package/lib/typescript/types/types.d.ts +85 -4
- package/lib/typescript/types/types.d.ts.map +1 -1
- package/lib/typescript/version.d.ts +1 -1
- package/lib/typescript/version.d.ts.map +1 -1
- package/package.json +9 -2
- package/src/booking/index.ts +10 -0
- package/src/booking/pendingScheduledCall.ts +272 -0
- package/src/booking/scheduleForm.ts +84 -0
- package/src/booking/scheduledCall.ts +163 -0
- package/src/booking/scheduledCallActions.ts +141 -0
- package/src/booking/scheduledCallLink.ts +145 -0
- package/src/booking/scheduledCallStore.ts +69 -0
- package/src/booking/startRoomCall.ts +103 -0
- package/src/calls/callBusy.ts +10 -0
- package/src/calls/callDisplay.ts +74 -0
- package/src/calls/callMode.ts +286 -0
- package/src/calls/declineReport.ts +16 -0
- package/src/calls/p2p/P2PCallController.ts +813 -0
- package/src/calls/p2p/icePolicy.ts +99 -0
- package/src/calls/p2p/negotiator.ts +186 -0
- package/src/calls/p2p/p2pRuntime.ts +164 -0
- package/src/calls/p2p/signalInbox.ts +117 -0
- package/src/calls/p2p/signalStanza.ts +205 -0
- package/src/calls/p2p/webrtcRuntime.ts +60 -0
- package/src/calls/senderTrust.ts +40 -0
- package/src/calls/startCall.ts +56 -0
- package/src/components/Booking/BookingIcons.tsx +44 -0
- package/src/components/Booking/ScheduleCallButton.tsx +66 -0
- package/src/components/Booking/ScheduleCallSheet.tsx +380 -0
- package/src/components/Booking/ScheduledCallCard.tsx +216 -0
- package/src/components/Booking/ScheduledCallHost.tsx +18 -0
- package/src/components/Booking/ScheduledCallMessage.tsx +62 -0
- package/src/components/Booking/ScheduledCallPreJoin.tsx +230 -0
- package/src/components/Booking/bookingShared.tsx +295 -0
- package/src/components/MainComponents/AlbumGrid.tsx +5 -1
- package/src/components/MainComponents/ChatHeader.tsx +18 -11
- package/src/components/MainComponents/LanguageSelectorButton.tsx +9 -2
- package/src/components/MainComponents/LanguageSelectorModal.tsx +10 -6
- package/src/components/MainComponents/MediaMessage.tsx +13 -2
- package/src/components/MainComponents/MessageContainer.tsx +15 -0
- package/src/components/MainComponents/ReduxWrapper.tsx +10 -0
- package/src/components/MainComponents/RoomList.tsx +8 -19
- package/src/components/MessageBubble/Message.tsx +24 -1
- package/src/components/Modals/ChatProfileModal/ChatMediaGrid.tsx +174 -0
- package/src/components/Modals/ChatProfileModal/ChatProfileModal.tsx +119 -48
- package/src/components/Modals/ChatProfileModal/LeaveChatModal.tsx +191 -0
- package/src/components/Modals/ChatProfileModal/ReportChatModal.tsx +22 -22
- package/src/components/Modals/FilePreviewModal/FilePreviewModal.tsx +115 -185
- package/src/components/Modals/FilePreviewModal/MediaViewer.tsx +880 -0
- package/src/components/Modals/FilePreviewModal/useSaveFile.ts +207 -0
- package/src/components/Modals/MessageSearchModal/MessageSearchModal.tsx +56 -30
- package/src/components/Modals/UserProfileModal/UserProfileModal.tsx +28 -9
- package/src/components/Modals/UserSettingsModal/LanguageCard.tsx +9 -7
- package/src/components/VideoCalls/ActiveCallBar.tsx +6 -5
- package/src/components/VideoCalls/CallButtons.tsx +23 -12
- package/src/components/VideoCalls/CallControlBar.tsx +131 -0
- package/src/components/VideoCalls/CallVideo.tsx +59 -0
- package/src/components/VideoCalls/GroupCallView.tsx +324 -0
- package/src/components/VideoCalls/P2PCallRunner.tsx +192 -0
- package/src/components/VideoCalls/VideoCallOverlay.tsx +62 -17
- package/src/components/VideoCalls/VideoCallSession.tsx +55 -133
- package/src/components/VideoCalls/callActions.ts +3 -0
- package/src/components/VideoCalls/callElapsed.ts +27 -0
- package/src/components/VideoCalls/callLive.ts +13 -0
- package/src/components/VideoCalls/callSessionController.ts +130 -55
- package/src/components/VideoCalls/callSessionTypes.ts +80 -0
- package/src/components/VideoCalls/groupLayout.ts +48 -0
- package/src/components/VideoCalls/p2pCallSession.ts +291 -0
- package/src/components/VideoCalls/useCallKeep.ts +9 -2
- package/src/components/VideoCalls/useOngoingCallNotification.ts +2 -2
- package/src/components/styled/MessageImage.tsx +3 -1
- package/src/components/styled/VideoMessage.tsx +5 -1
- package/src/context/MediaSourceContext.tsx +14 -0
- package/src/context/xmppProvider.tsx +3 -0
- package/src/helpers/callPush.ts +13 -1
- package/src/helpers/constants/MODAL_COMPONENTS.tsx +4 -1
- package/src/helpers/constants/MODAL_TYPES.ts +2 -0
- package/src/helpers/incomingCallFromPush.ts +65 -7
- package/src/helpers/publicChatsEntry.ts +8 -7
- package/src/helpers/pushPayload.ts +9 -1
- package/src/helpers/reportRoom.ts +93 -0
- package/src/helpers/roomMedia.ts +126 -0
- package/src/i18n/strings.ts +480 -0
- package/src/main.ts +33 -0
- package/src/networking/api-requests/callState.api.ts +83 -0
- package/src/networking/api-requests/push.api.ts +28 -3
- package/src/networking/api-requests/rooms.api.ts +25 -15
- package/src/networking/api-requests/scheduledCalls.api.ts +232 -0
- package/src/networking/callTokenStanza.ts +247 -50
- package/src/roomStore/callSlice.ts +86 -2
- package/src/services/appBadge.ts +85 -0
- package/src/services/languageSettings.ts +43 -8
- package/src/services/pushRegistration.ts +34 -3
- package/src/types/models/modal.model.ts +16 -0
- package/src/types/types.ts +86 -4
- package/src/version.ts +1 -1
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/** @format */
|
|
4
|
+
|
|
5
|
+
import React, { useMemo, useState } from 'react';
|
|
6
|
+
import { ActivityIndicator, Alert, Modal, StyleSheet, Text, TouchableOpacity, View } from 'react-native';
|
|
7
|
+
import { useSelector } from 'react-redux';
|
|
8
|
+
import { ProfileImagePlaceholder } from '../../MainComponents/ProfileImagePlaceholder';
|
|
9
|
+
import { useLeaveRoom } from '../../../hooks/useLeaveRoom';
|
|
10
|
+
import { useFileToken } from '../../../hooks/useFileToken';
|
|
11
|
+
import { appendFileToken } from '../../../helpers/secureFileUrl';
|
|
12
|
+
import { useTheme } from '../../../hooks/useTheme';
|
|
13
|
+
import { useT } from '../../../i18n/useT';
|
|
14
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
15
|
+
/**
|
|
16
|
+
* Telegram-style confirmation in front of every Leave: the chat's avatar and
|
|
17
|
+
* name, the question, Cancel and a red Leave. The leave itself runs here, so
|
|
18
|
+
* the card stays up with a spinner until the server answers and a failure is
|
|
19
|
+
* reported over it instead of after it has gone.
|
|
20
|
+
*/
|
|
21
|
+
const LeaveChatModal = ({
|
|
22
|
+
roomJid,
|
|
23
|
+
onClose,
|
|
24
|
+
onLeft
|
|
25
|
+
}) => {
|
|
26
|
+
const t = useT();
|
|
27
|
+
const theme = useTheme();
|
|
28
|
+
const styles = useMemo(() => createStyles(theme), [theme]);
|
|
29
|
+
const fileToken = useFileToken();
|
|
30
|
+
const leaveRoom = useLeaveRoom();
|
|
31
|
+
const room = useSelector(state => roomJid ? state.rooms.rooms?.[roomJid] : undefined);
|
|
32
|
+
const [leaving, setLeaving] = useState(false);
|
|
33
|
+
const name = room?.title || room?.name || '';
|
|
34
|
+
const close = () => {
|
|
35
|
+
if (!leaving) {
|
|
36
|
+
onClose();
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
const confirm = async () => {
|
|
40
|
+
if (!roomJid || leaving) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
setLeaving(true);
|
|
44
|
+
const ok = await leaveRoom(roomJid);
|
|
45
|
+
setLeaving(false);
|
|
46
|
+
if (!ok) {
|
|
47
|
+
Alert.alert(t('toast.error'), t('toast.leaveFailed'));
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
onLeft?.(roomJid);
|
|
51
|
+
onClose();
|
|
52
|
+
};
|
|
53
|
+
return /*#__PURE__*/_jsx(Modal, {
|
|
54
|
+
transparent: true,
|
|
55
|
+
visible: roomJid !== null,
|
|
56
|
+
animationType: "fade",
|
|
57
|
+
onRequestClose: close,
|
|
58
|
+
children: /*#__PURE__*/_jsxs(View, {
|
|
59
|
+
style: styles.backdrop,
|
|
60
|
+
children: [/*#__PURE__*/_jsx(TouchableOpacity, {
|
|
61
|
+
testID: "leave-backdrop",
|
|
62
|
+
style: StyleSheet.absoluteFill,
|
|
63
|
+
activeOpacity: 1,
|
|
64
|
+
onPress: close
|
|
65
|
+
}), /*#__PURE__*/_jsxs(View, {
|
|
66
|
+
style: styles.card,
|
|
67
|
+
children: [/*#__PURE__*/_jsxs(View, {
|
|
68
|
+
style: styles.header,
|
|
69
|
+
children: [/*#__PURE__*/_jsx(ProfileImagePlaceholder, {
|
|
70
|
+
name: name,
|
|
71
|
+
size: 40,
|
|
72
|
+
icon: appendFileToken(room?.icon, fileToken),
|
|
73
|
+
disableOverlay: true
|
|
74
|
+
}), /*#__PURE__*/_jsx(Text, {
|
|
75
|
+
style: styles.title,
|
|
76
|
+
numberOfLines: 1,
|
|
77
|
+
children: t('modal.leaveChat.title')
|
|
78
|
+
})]
|
|
79
|
+
}), /*#__PURE__*/_jsx(Text, {
|
|
80
|
+
style: styles.description,
|
|
81
|
+
children: name ? t('modal.leaveChat.descriptionNamed', {
|
|
82
|
+
name
|
|
83
|
+
}) : t('modal.leaveChat.description')
|
|
84
|
+
}), /*#__PURE__*/_jsxs(View, {
|
|
85
|
+
style: styles.buttons,
|
|
86
|
+
children: [/*#__PURE__*/_jsx(TouchableOpacity, {
|
|
87
|
+
testID: "leave-cancel",
|
|
88
|
+
activeOpacity: 0.7,
|
|
89
|
+
disabled: leaving,
|
|
90
|
+
style: [styles.button, styles.cancel],
|
|
91
|
+
onPress: close,
|
|
92
|
+
children: /*#__PURE__*/_jsx(Text, {
|
|
93
|
+
style: styles.cancelLabel,
|
|
94
|
+
children: t('action.cancel')
|
|
95
|
+
})
|
|
96
|
+
}), /*#__PURE__*/_jsx(TouchableOpacity, {
|
|
97
|
+
testID: "leave-confirm",
|
|
98
|
+
activeOpacity: 0.7,
|
|
99
|
+
disabled: leaving,
|
|
100
|
+
style: [styles.button, {
|
|
101
|
+
backgroundColor: theme.danger
|
|
102
|
+
}],
|
|
103
|
+
onPress: confirm,
|
|
104
|
+
children: leaving ? /*#__PURE__*/_jsx(ActivityIndicator, {
|
|
105
|
+
color: theme.textOnPrimary
|
|
106
|
+
}) : /*#__PURE__*/_jsx(Text, {
|
|
107
|
+
style: styles.leaveLabel,
|
|
108
|
+
children: t('action.leave')
|
|
109
|
+
})
|
|
110
|
+
})]
|
|
111
|
+
})]
|
|
112
|
+
})]
|
|
113
|
+
})
|
|
114
|
+
});
|
|
115
|
+
};
|
|
116
|
+
const createStyles = theme => StyleSheet.create({
|
|
117
|
+
backdrop: {
|
|
118
|
+
flex: 1,
|
|
119
|
+
backgroundColor: theme.overlay,
|
|
120
|
+
alignItems: 'center',
|
|
121
|
+
justifyContent: 'center',
|
|
122
|
+
padding: 24
|
|
123
|
+
},
|
|
124
|
+
card: {
|
|
125
|
+
width: '100%',
|
|
126
|
+
maxWidth: 400,
|
|
127
|
+
borderRadius: 16,
|
|
128
|
+
backgroundColor: theme.surface,
|
|
129
|
+
padding: 20
|
|
130
|
+
},
|
|
131
|
+
header: {
|
|
132
|
+
flexDirection: 'row',
|
|
133
|
+
alignItems: 'center',
|
|
134
|
+
gap: 12,
|
|
135
|
+
marginBottom: 12
|
|
136
|
+
},
|
|
137
|
+
title: {
|
|
138
|
+
flex: 1,
|
|
139
|
+
fontSize: 18,
|
|
140
|
+
fontWeight: '600',
|
|
141
|
+
color: theme.text
|
|
142
|
+
},
|
|
143
|
+
description: {
|
|
144
|
+
fontSize: 15,
|
|
145
|
+
lineHeight: 21,
|
|
146
|
+
color: theme.text
|
|
147
|
+
},
|
|
148
|
+
buttons: {
|
|
149
|
+
flexDirection: 'row',
|
|
150
|
+
gap: 12,
|
|
151
|
+
marginTop: 20
|
|
152
|
+
},
|
|
153
|
+
button: {
|
|
154
|
+
flex: 1,
|
|
155
|
+
height: 44,
|
|
156
|
+
borderRadius: 12,
|
|
157
|
+
alignItems: 'center',
|
|
158
|
+
justifyContent: 'center'
|
|
159
|
+
},
|
|
160
|
+
cancel: {
|
|
161
|
+
backgroundColor: theme.surfaceSecondary
|
|
162
|
+
},
|
|
163
|
+
cancelLabel: {
|
|
164
|
+
fontSize: 16,
|
|
165
|
+
fontWeight: '500',
|
|
166
|
+
color: theme.text
|
|
167
|
+
},
|
|
168
|
+
leaveLabel: {
|
|
169
|
+
fontSize: 16,
|
|
170
|
+
fontWeight: '600',
|
|
171
|
+
color: theme.textOnPrimary
|
|
172
|
+
}
|
|
173
|
+
});
|
|
174
|
+
export default LeaveChatModal;
|
|
175
|
+
//# sourceMappingURL=LeaveChatModal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["React","useMemo","useState","ActivityIndicator","Alert","Modal","StyleSheet","Text","TouchableOpacity","View","useSelector","ProfileImagePlaceholder","useLeaveRoom","useFileToken","appendFileToken","useTheme","useT","jsx","_jsx","jsxs","_jsxs","LeaveChatModal","roomJid","onClose","onLeft","t","theme","styles","createStyles","fileToken","leaveRoom","room","state","rooms","undefined","leaving","setLeaving","name","title","close","confirm","ok","alert","transparent","visible","animationType","onRequestClose","children","style","backdrop","testID","absoluteFill","activeOpacity","onPress","card","header","size","icon","disableOverlay","numberOfLines","description","buttons","disabled","button","cancel","cancelLabel","backgroundColor","danger","color","textOnPrimary","leaveLabel","create","flex","overlay","alignItems","justifyContent","padding","width","maxWidth","borderRadius","surface","flexDirection","gap","marginBottom","fontSize","fontWeight","text","lineHeight","marginTop","height","surfaceSecondary"],"sourceRoot":"../../../../../src","sources":["components/Modals/ChatProfileModal/LeaveChatModal.tsx"],"mappings":";;AAAA;;AAEA,OAAOA,KAAK,IAAIC,OAAO,EAAEC,QAAQ,QAAQ,OAAO;AAChD,SACEC,iBAAiB,EACjBC,KAAK,EACLC,KAAK,EACLC,UAAU,EACVC,IAAI,EACJC,gBAAgB,EAChBC,IAAI,QACC,cAAc;AACrB,SAASC,WAAW,QAAQ,aAAa;AAEzC,SAASC,uBAAuB,QAAQ,8CAA8C;AACtF,SAASC,YAAY,QAAQ,6BAA6B;AAC1D,SAASC,YAAY,QAAQ,6BAA6B;AAC1D,SAASC,eAAe,QAAQ,gCAAgC;AAChE,SAASC,QAAQ,QAAQ,yBAAyB;AAClD,SAASC,IAAI,QAAQ,oBAAoB;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAW1C;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,cAA6C,GAAGA,CAAC;EACrDC,OAAO;EACPC,OAAO;EACPC;AACF,CAAC,KAAK;EACJ,MAAMC,CAAC,GAAGT,IAAI,CAAC,CAAC;EAChB,MAAMU,KAAK,GAAGX,QAAQ,CAAC,CAAC;EACxB,MAAMY,MAAM,GAAG1B,OAAO,CAAC,MAAM2B,YAAY,CAACF,KAAK,CAAC,EAAE,CAACA,KAAK,CAAC,CAAC;EAC1D,MAAMG,SAAS,GAAGhB,YAAY,CAAC,CAAC;EAChC,MAAMiB,SAAS,GAAGlB,YAAY,CAAC,CAAC;EAChC,MAAMmB,IAAI,GAAGrB,WAAW,CAAEsB,KAAgB,IACxCV,OAAO,GAAGU,KAAK,CAACC,KAAK,CAACA,KAAK,GAAGX,OAAO,CAAC,GAAGY,SAC3C,CAAC;EACD,MAAM,CAACC,OAAO,EAAEC,UAAU,CAA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M,EAAE;IACNS,IAAI,EAAE,CAAC;IACPiB,MAAM,EAAE,EAAE;IACVV,YAAY,EAAE,EAAE;IAChBL,UAAU,EAAE,QAAQ;IACpBC,cAAc,EAAE;EAClB,CAAC;EACDX,MAAM,EAAE;IACNE,eAAe,EAAExC,KAAK,CAACgE;EACzB,CAAC;EACDzB,WAAW,EAAE;IACXmB,QAAQ,EAAE,EAAE;IACZC,UAAU,EAAE,KAAK;IACjBjB,KAAK,EAAE1C,KAAK,CAAC4D;EACf,CAAC;EACDhB,UAAU,EAAE;IACVc,QAAQ,EAAE,EAAE;IACZC,UAAU,EAAE,KAAK;IACjBjB,KAAK,EAAE1C,KAAK,CAAC2C;EACf;AACF,CAAC,CAAC;AAEF,eAAehD,cAAc","ignoreList":[]}
|
|
@@ -12,13 +12,16 @@ import { useT } from '../../../i18n/useT';
|
|
|
12
12
|
import { getIconColor } from '../../../helpers/getIconColor';
|
|
13
13
|
import { useChatSettingState } from '../../../hooks/useChatSettingState';
|
|
14
14
|
import { useTheme } from '../../../hooks/useTheme';
|
|
15
|
-
import {
|
|
15
|
+
import { buildReportRoomPayload, OTHER_REPORT_CATEGORY, REPORT_CATEGORIES } from '../../../helpers/reportRoom';
|
|
16
|
+
|
|
16
17
|
/**
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
18
|
+
* The ids are UI ids: helpers/reportRoom maps each one onto the category
|
|
19
|
+
* value `POST /v1/chats/reports/{chatName}` accepts and builds the
|
|
20
|
+
* non-empty text it requires. Labels come from the `report.category.*`
|
|
21
|
+
* strings.
|
|
20
22
|
*/
|
|
21
|
-
|
|
23
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
24
|
+
const CATEGORIES = [...REPORT_CATEGORIES, OTHER_REPORT_CATEGORY];
|
|
22
25
|
const ReportChatModal = ({
|
|
23
26
|
visible,
|
|
24
27
|
onClose,
|
|
@@ -47,17 +50,17 @@ const ReportChatModal = ({
|
|
|
47
50
|
if (!category || sending) {
|
|
48
51
|
return;
|
|
49
52
|
}
|
|
53
|
+
const payload = buildReportRoomPayload(roomJid || activeRoom?.jid || '', category, details);
|
|
54
|
+
if (!payload) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
50
57
|
setSending(true);
|
|
51
58
|
try {
|
|
52
|
-
await postReportRoom(
|
|
53
|
-
chatName: (roomJid || activeRoom?.jid || '').split('@')[0],
|
|
54
|
-
category,
|
|
55
|
-
text: details.trim() || undefined
|
|
56
|
-
});
|
|
59
|
+
await postReportRoom(payload);
|
|
57
60
|
showToast({
|
|
58
61
|
id: Date.now().toString(),
|
|
59
62
|
title: t('toast.successTitle'),
|
|
60
|
-
message: t('
|
|
63
|
+
message: t('toast.reportSent'),
|
|
61
64
|
type: 'success'
|
|
62
65
|
});
|
|
63
66
|
close();
|
|
@@ -66,7 +69,7 @@ const ReportChatModal = ({
|
|
|
66
69
|
showToast({
|
|
67
70
|
id: Date.now().toString(),
|
|
68
71
|
title: t('toast.error'),
|
|
69
|
-
message: t('
|
|
72
|
+
message: t('toast.reportFailed'),
|
|
70
73
|
type: 'error'
|
|
71
74
|
});
|
|
72
75
|
} finally {
|
|
@@ -92,7 +95,10 @@ const ReportChatModal = ({
|
|
|
92
95
|
children: t('modal.report.chatTitle')
|
|
93
96
|
}), /*#__PURE__*/_jsx(View, {
|
|
94
97
|
style: styles.categories,
|
|
95
|
-
children: CATEGORIES.map(
|
|
98
|
+
children: CATEGORIES.map(({
|
|
99
|
+
id,
|
|
100
|
+
labelKey
|
|
101
|
+
}) => {
|
|
96
102
|
const selected = category === id;
|
|
97
103
|
return /*#__PURE__*/_jsx(TouchableOpacity, {
|
|
98
104
|
testID: `report-category-${id}`,
|
|
@@ -106,11 +112,11 @@ const ReportChatModal = ({
|
|
|
106
112
|
style: [styles.categoryLabel, selected && {
|
|
107
113
|
color: primary
|
|
108
114
|
}],
|
|
109
|
-
children: t(
|
|
115
|
+
children: t(labelKey)
|
|
110
116
|
})
|
|
111
117
|
}, id);
|
|
112
118
|
})
|
|
113
|
-
}), category ===
|
|
119
|
+
}), category === OTHER_REPORT_CATEGORY.id && /*#__PURE__*/_jsx(TextInput, {
|
|
114
120
|
testID: "report-details",
|
|
115
121
|
style: styles.input,
|
|
116
122
|
placeholder: t('modal.report.otherDetails'),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","useMemo","useState","ActivityIndicator","Modal","StyleSheet","Text","TextInput","TouchableOpacity","View","useSelector","getActiveRoom","postReportRoom","useToast","useT","getIconColor","useChatSettingState","useTheme","jsx","_jsx","jsxs","_jsxs","CATEGORIES","ReportChatModal","visible","onClose","roomJid","t","showToast","config","activeRoom","state","category","setCategory","details","setDetails","sending","setSending","primary","theme","styles","createStyles","close","submit","
|
|
1
|
+
{"version":3,"names":["React","useMemo","useState","ActivityIndicator","Modal","StyleSheet","Text","TextInput","TouchableOpacity","View","useSelector","getActiveRoom","postReportRoom","useToast","useT","getIconColor","useChatSettingState","useTheme","buildReportRoomPayload","OTHER_REPORT_CATEGORY","REPORT_CATEGORIES","jsx","_jsx","jsxs","_jsxs","CATEGORIES","ReportChatModal","visible","onClose","roomJid","t","showToast","config","activeRoom","state","category","setCategory","details","setDetails","sending","setSending","primary","theme","styles","createStyles","close","submit","payload","jid","id","Date","now","toString","title","message","type","error","console","transparent","animationType","onRequestClose","children","style","backdrop","testID","absoluteFill","activeOpacity","onPress","card","categories","map","labelKey","selected","borderColor","backgroundColor","categoryLabel","color","input","placeholder","placeholderTextColor","textMuted","value","onChangeText","multiline","buttons","button","cancel","cancelLabel","disabled","opacity","textOnPrimary","submitLabel","create","flex","overlay","alignItems","justifyContent","padding","width","borderRadius","surface","fontSize","fontWeight","text","marginBottom","flexDirection","flexWrap","gap","paddingHorizontal","paddingVertical","borderWidth","border","marginTop","minHeight","textAlignVertical","height","surfaceSecondary"],"sourceRoot":"../../../../../src","sources":["components/Modals/ChatProfileModal/ReportChatModal.tsx"],"mappings":";;AAAA;;AAEA,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Q,EAAE,EAAE;IACZzB,KAAK,EAAElC,KAAK,CAAC6D;EACf,CAAC;EACD1B,KAAK,EAAE;IACLmC,SAAS,EAAE,EAAE;IACbC,SAAS,EAAE,EAAE;IACbd,YAAY,EAAE,EAAE;IAChBW,WAAW,EAAE,CAAC;IACdrC,WAAW,EAAE/B,KAAK,CAACqE,MAAM;IACzBd,OAAO,EAAE,EAAE;IACXI,QAAQ,EAAE,EAAE;IACZzB,KAAK,EAAElC,KAAK,CAAC6D,IAAI;IACjBW,iBAAiB,EAAE;EACrB,CAAC;EACD9B,OAAO,EAAE;IACPqB,aAAa,EAAE,KAAK;IACpBE,GAAG,EAAE,EAAE;IACPK,SAAS,EAAE;EACb,CAAC;EACD3B,MAAM,EAAE;IACNQ,IAAI,EAAE,CAAC;IACPsB,MAAM,EAAE,EAAE;IACVhB,YAAY,EAAE,EAAE;IAChBJ,UAAU,EAAE,QAAQ;IACpBC,cAAc,EAAE;EAClB,CAAC;EACDV,MAAM,EAAE;IACNZ,eAAe,EAAEhC,KAAK,CAAC0E;EACzB,CAAC;EACD7B,WAAW,EAAE;IACXc,QAAQ,EAAE,EAAE;IACZC,UAAU,EAAE,KAAK;IACjB1B,KAAK,EAAElC,KAAK,CAAC6D;EACf,CAAC;EACDZ,WAAW,EAAE;IACXU,QAAQ,EAAE,EAAE;IACZC,UAAU,EAAE,KAAK;IACjB1B,KAAK,EAAElC,KAAK,CAACgD;EACf;AACF,CAAC,CAAC;AAEF,eAAehE,eAAe","ignoreList":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import React, { useCallback, useEffect, useRef, useState } from 'react';
|
|
3
|
+
import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
4
4
|
import { withFileToken } from '../../../helpers/secureFileUrl';
|
|
5
5
|
import { CenterContainer, ModalContainerFullScreen } from '../styledModalComponents';
|
|
6
6
|
import { SaveIcon } from '../../../assets/icons';
|
|
@@ -8,33 +8,36 @@ import ModalHeaderComponent from '../ModalHeaderComponent';
|
|
|
8
8
|
import { useChatSettingState } from '../../../hooks/useChatSettingState';
|
|
9
9
|
import { useTheme } from '../../../hooks/useTheme';
|
|
10
10
|
import { chatTextStyle } from '../../../helpers/typography';
|
|
11
|
-
import { useDispatch, useSelector } from 'react-redux';
|
|
11
|
+
import { useDispatch, useSelector, useStore } from 'react-redux';
|
|
12
12
|
import Button from '../../styled/Button';
|
|
13
13
|
import { FullScreenImage } from '../../styled/StyledInputComponents/MediaComponents';
|
|
14
14
|
import { setActiveFile } from '../../../roomStore/chatSettingsSlice';
|
|
15
|
-
import
|
|
15
|
+
import MediaViewer from './MediaViewer';
|
|
16
|
+
import { isLocalFile, useSaveFile } from './useSaveFile';
|
|
17
|
+
import { withChatSiblings } from '../../../helpers/roomMedia';
|
|
18
|
+
import { loadRoomHistory } from '../../../helpers/loadRoomHistory';
|
|
19
|
+
import { getGlobalXmppClient } from '../../../utils/clientRegistry';
|
|
20
|
+
import { useFileToken } from '../../../hooks/useFileToken';
|
|
21
|
+
import { ActivityIndicator, Text, View, Platform, TouchableOpacity, StyleSheet } from 'react-native';
|
|
16
22
|
import { useVideoPlayer, VideoView } from 'expo-video';
|
|
17
23
|
import { PlayIcon } from '../../../assets/icons';
|
|
18
|
-
import * as FileSystem from 'expo-file-system/legacy';
|
|
19
|
-
import { getMediaLibrary } from '../../../helpers/mediaLibraryRuntime';
|
|
20
|
-
import { useToast } from '../../../context/ToastContext';
|
|
21
24
|
import { useT } from '../../../i18n/useT';
|
|
22
25
|
import PdfViewer from './PdfView';
|
|
23
26
|
import DocumentViewer from './DocumentViewer';
|
|
24
27
|
import AudioMessage from '../../styled/AudioMessage';
|
|
25
28
|
import { isLikelyAudio } from '../../../helpers/mimeToExtension';
|
|
26
29
|
import { downloadVideoToCache, findCachedVideo, isRemoteUrl, isStreamingUnsupported, markStreamingUnsupported } from '../../../helpers/videoCache';
|
|
27
|
-
import { getDisplayFileName,
|
|
30
|
+
import { getDisplayFileName, sanitizeFileNameForPath } from '../../../helpers/getDisplayFileName';
|
|
28
31
|
|
|
29
32
|
// MIME types Google's gview embed renders reliably. Everything else
|
|
30
33
|
// falls through to the info-card so the user can still download.
|
|
31
34
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
32
35
|
const GVIEW_PREVIEWABLE = new Set(['application/msword', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'application/vnd.ms-excel', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'application/vnd.ms-powerpoint', 'application/vnd.openxmlformats-officedocument.presentationml.presentation', 'text/plain', 'text/csv', 'application/rtf']);
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
const isMedia = mime => !!mime && (mime.startsWith('image/') || mime.startsWith('video/'));
|
|
37
|
+
|
|
38
|
+
/** Older history pages the viewer asked for; one at a time per room. */
|
|
39
|
+
const historyInFlight = new Set();
|
|
40
|
+
const HISTORY_PAGE_SIZE = 30;
|
|
38
41
|
const isGviewPreviewable = mime => {
|
|
39
42
|
if (!mime) {
|
|
40
43
|
return false;
|
|
@@ -227,13 +230,82 @@ const ModalVideo = ({
|
|
|
227
230
|
})]
|
|
228
231
|
});
|
|
229
232
|
};
|
|
233
|
+
/** The viewer on the store's `activeFile`, as opened from a message bubble. */
|
|
230
234
|
const FilePreviewModal = ({
|
|
231
235
|
handleCloseModal
|
|
232
236
|
}) => {
|
|
233
237
|
const dispatch = useDispatch();
|
|
238
|
+
const store = useStore();
|
|
234
239
|
const {
|
|
235
|
-
|
|
236
|
-
} =
|
|
240
|
+
activeFile
|
|
241
|
+
} = useSelector(state => state.chatSettingStore);
|
|
242
|
+
const {
|
|
243
|
+
user,
|
|
244
|
+
config
|
|
245
|
+
} = useChatSettingState();
|
|
246
|
+
const fileToken = useFileToken();
|
|
247
|
+
const roomJid = activeFile?.source?.roomJid;
|
|
248
|
+
const room = useSelector(state => roomJid ? state.rooms.rooms?.[roomJid] : undefined);
|
|
249
|
+
const messages = room?.messages;
|
|
250
|
+
|
|
251
|
+
// A picture or video opened from a bubble pages through the whole chat;
|
|
252
|
+
// anything not in the loaded history keeps what it was opened with.
|
|
253
|
+
const file = useMemo(() => {
|
|
254
|
+
if (!activeFile?.fileURL || !isMedia(activeFile.mimetype)) {
|
|
255
|
+
return activeFile;
|
|
256
|
+
}
|
|
257
|
+
return withChatSiblings(activeFile, messages, {
|
|
258
|
+
me: user,
|
|
259
|
+
fileToken,
|
|
260
|
+
interactive: !config?.disableInteractions,
|
|
261
|
+
repliesOn: !config?.disableReplies
|
|
262
|
+
}) ?? activeFile;
|
|
263
|
+
}, [activeFile, messages, user, fileToken, config?.disableInteractions, config?.disableReplies]);
|
|
264
|
+
|
|
265
|
+
// On the oldest loaded file, ask for an older page: what it brings in
|
|
266
|
+
// shows up to the left of it.
|
|
267
|
+
const atOldest = !!file?.siblings && file.index === 0 && !!roomJid;
|
|
268
|
+
const historyComplete = !!room?.historyComplete;
|
|
269
|
+
useEffect(() => {
|
|
270
|
+
if (!atOldest || historyComplete || !roomJid) {
|
|
271
|
+
return;
|
|
272
|
+
}
|
|
273
|
+
loadRoomHistory({
|
|
274
|
+
client: getGlobalXmppClient(),
|
|
275
|
+
room: store.getState().rooms.rooms?.[roomJid],
|
|
276
|
+
inFlight: historyInFlight,
|
|
277
|
+
chatJID: roomJid,
|
|
278
|
+
max: HISTORY_PAGE_SIZE
|
|
279
|
+
});
|
|
280
|
+
}, [atOldest, historyComplete, roomJid, store]);
|
|
281
|
+
if (!file?.fileURL) {
|
|
282
|
+
return null;
|
|
283
|
+
}
|
|
284
|
+
const closeModal = () => {
|
|
285
|
+
dispatch(setActiveFile({
|
|
286
|
+
fileName: '',
|
|
287
|
+
fileURL: '',
|
|
288
|
+
mimetype: ''
|
|
289
|
+
}));
|
|
290
|
+
handleCloseModal?.();
|
|
291
|
+
};
|
|
292
|
+
return /*#__PURE__*/_jsx(FilePreview, {
|
|
293
|
+
file: file,
|
|
294
|
+
onClose: closeModal,
|
|
295
|
+
onChangeFile: next => dispatch(setActiveFile(next))
|
|
296
|
+
});
|
|
297
|
+
};
|
|
298
|
+
/**
|
|
299
|
+
* One file, full screen: pictures and videos in the Telegram-style
|
|
300
|
+
* MediaViewer, everything else (documents, PDFs, voice notes) on the
|
|
301
|
+
* plain preview page with the save button in its header.
|
|
302
|
+
*/
|
|
303
|
+
export const FilePreview = ({
|
|
304
|
+
file: activeFile,
|
|
305
|
+
onClose,
|
|
306
|
+
onChangeFile,
|
|
307
|
+
onReplyOpened
|
|
308
|
+
}) => {
|
|
237
309
|
const t = useT();
|
|
238
310
|
const {
|
|
239
311
|
config
|
|
@@ -243,16 +315,6 @@ const FilePreviewModal = ({
|
|
|
243
315
|
// dark sits them on the secondary surface.
|
|
244
316
|
const cardBackground = theme.dark ? theme.surfaceSecondary : '#FFF8ED';
|
|
245
317
|
|
|
246
|
-
// Cache the SAF directory the user granted so saving several documents
|
|
247
|
-
// in a row doesn't re-prompt for a folder every time (Android only).
|
|
248
|
-
const safDirUriRef = useRef(null);
|
|
249
|
-
const {
|
|
250
|
-
activeFile
|
|
251
|
-
} = useSelector(state => state.chatSettingStore);
|
|
252
|
-
if (!activeFile) {
|
|
253
|
-
return null;
|
|
254
|
-
}
|
|
255
|
-
|
|
256
318
|
// Bug #40: prefer the sender's original name over the server's stored
|
|
257
319
|
// hash name everywhere this modal shows or saves/shares the file.
|
|
258
320
|
// Sanitized so it's safe to use as an actual path segment (strips path
|
|
@@ -263,135 +325,8 @@ const FilePreviewModal = ({
|
|
|
263
325
|
location: activeFile.fileURL,
|
|
264
326
|
mimetype: activeFile.mimetype
|
|
265
327
|
}));
|
|
266
|
-
const
|
|
267
|
-
|
|
268
|
-
if (!MediaLibrary?.requestPermissionsAsync) {
|
|
269
|
-
return false;
|
|
270
|
-
}
|
|
271
|
-
try {
|
|
272
|
-
const {
|
|
273
|
-
status
|
|
274
|
-
} = await MediaLibrary.requestPermissionsAsync();
|
|
275
|
-
return status === 'granted';
|
|
276
|
-
} catch (error) {
|
|
277
|
-
console.error('Error requesting permission:', error);
|
|
278
|
-
return false;
|
|
279
|
-
}
|
|
280
|
-
};
|
|
281
|
-
const saveToGallery = async () => {
|
|
282
|
-
const hasPermission = await requestStoragePermission();
|
|
283
|
-
if (!hasPermission) {
|
|
284
|
-
Alert.alert('Permission Denied', 'Storage permission is required to save files to the gallery.');
|
|
285
|
-
return;
|
|
286
|
-
}
|
|
287
|
-
try {
|
|
288
|
-
const filePath = FileSystem.cacheDirectory + displayFileName;
|
|
289
|
-
const download = await fetchToCache(activeFile.fileURL, filePath);
|
|
290
|
-
if (download.status === 200) {
|
|
291
|
-
await getMediaLibrary()?.saveToLibraryAsync(download.uri);
|
|
292
|
-
showToast({
|
|
293
|
-
id: Date.now().toString(),
|
|
294
|
-
title: t('toast.successTitle'),
|
|
295
|
-
message: t('toast.saveSuccessful'),
|
|
296
|
-
type: 'success'
|
|
297
|
-
});
|
|
298
|
-
} else {
|
|
299
|
-
Alert.alert('Error', 'Failed to save the file.');
|
|
300
|
-
}
|
|
301
|
-
} catch (err) {
|
|
302
|
-
Alert.alert('Error', `Failed to save the file: ${displayFileName}`);
|
|
303
|
-
}
|
|
304
|
-
};
|
|
305
|
-
|
|
306
|
-
// Best-effort existing-name lookup for the Android SAF branch below: SAF
|
|
307
|
-
// hands back content URIs, not plain names, so this decodes each one and
|
|
308
|
-
// takes its last path segment. If the provider's URI shape doesn't match
|
|
309
|
-
// what we expect, we fail open (empty set) rather than block the save -
|
|
310
|
-
// worst case we skip de-duplication, we never crash the save flow.
|
|
311
|
-
const listSafDirectoryNames = async (saf, dirUri) => {
|
|
312
|
-
try {
|
|
313
|
-
const uris = await saf.readDirectoryAsync(dirUri);
|
|
314
|
-
const names = uris.map(uri => {
|
|
315
|
-
try {
|
|
316
|
-
const decoded = decodeURIComponent(uri);
|
|
317
|
-
const last = decoded.split('/').pop() || '';
|
|
318
|
-
return last.includes(':') ? last.split(':').pop() || '' : last;
|
|
319
|
-
} catch {
|
|
320
|
-
return '';
|
|
321
|
-
}
|
|
322
|
-
});
|
|
323
|
-
return new Set(names.filter(Boolean));
|
|
324
|
-
} catch {
|
|
325
|
-
return new Set();
|
|
326
|
-
}
|
|
327
|
-
};
|
|
328
|
-
const saveFileToDownloads = async () => {
|
|
329
|
-
try {
|
|
330
|
-
const filePath = FileSystem.cacheDirectory + displayFileName;
|
|
331
|
-
const download = await fetchToCache(activeFile.fileURL, filePath);
|
|
332
|
-
if (download.status !== 200) {
|
|
333
|
-
Alert.alert('Error', 'Failed to save the file.');
|
|
334
|
-
return;
|
|
335
|
-
}
|
|
336
|
-
if (Platform.OS === 'android') {
|
|
337
|
-
const saf = FileSystem.StorageAccessFramework;
|
|
338
|
-
let dirUri = safDirUriRef.current;
|
|
339
|
-
if (!dirUri) {
|
|
340
|
-
const perm = await saf.requestDirectoryPermissionsAsync();
|
|
341
|
-
if (!perm.granted) {
|
|
342
|
-
Alert.alert('Permission Denied', 'Storage permission is required to save the file.');
|
|
343
|
-
return;
|
|
344
|
-
}
|
|
345
|
-
dirUri = perm.directoryUri;
|
|
346
|
-
safDirUriRef.current = dirUri;
|
|
347
|
-
}
|
|
348
|
-
|
|
349
|
-
// Avoid silently overwriting a different attachment that happens
|
|
350
|
-
// to share the same display name (common now that we prefer the
|
|
351
|
-
// human-picked name over the unique server hash - bug #40) by
|
|
352
|
-
// suffixing " (1)", " (2)", ... on a collision.
|
|
353
|
-
const existingNames = await listSafDirectoryNames(saf, dirUri);
|
|
354
|
-
const uniqueName = await getUniqueFileName(displayFileName, async candidate => existingNames.has(candidate));
|
|
355
|
-
const baseName = uniqueName.replace(/\.[^/.]+$/, '');
|
|
356
|
-
const mime = activeFile.mimetype || 'application/octet-stream';
|
|
357
|
-
const base64 = await FileSystem.readAsStringAsync(download.uri, {
|
|
358
|
-
encoding: FileSystem.EncodingType.Base64
|
|
359
|
-
});
|
|
360
|
-
const destUri = await saf.createFileAsync(dirUri, baseName, mime);
|
|
361
|
-
await FileSystem.writeAsStringAsync(destUri, base64, {
|
|
362
|
-
encoding: FileSystem.EncodingType.Base64
|
|
363
|
-
});
|
|
364
|
-
showToast({
|
|
365
|
-
id: Date.now().toString(),
|
|
366
|
-
title: t('toast.successTitle'),
|
|
367
|
-
message: t('toast.saveSuccessful'),
|
|
368
|
-
type: 'success'
|
|
369
|
-
});
|
|
370
|
-
return;
|
|
371
|
-
}
|
|
372
|
-
|
|
373
|
-
// iOS (and any non-Android): there is no app-writable "Downloads"
|
|
374
|
-
// folder, and MediaLibrary only accepts images/videos — which is why
|
|
375
|
-
// documents previously hit the success toast without ever being
|
|
376
|
-
// saved. Present the system share sheet so the user can "Save to
|
|
377
|
-
// Files", AirDrop, etc. The sheet itself is the confirmation (the
|
|
378
|
-
// user may cancel), so we don't show a "Save successful" toast here.
|
|
379
|
-
await Share.share({
|
|
380
|
-
url: download.uri,
|
|
381
|
-
title: displayFileName
|
|
382
|
-
});
|
|
383
|
-
} catch (err) {
|
|
384
|
-
console.error('Error saving file:', err);
|
|
385
|
-
Alert.alert('Error', 'Failed to save the file.');
|
|
386
|
-
}
|
|
387
|
-
};
|
|
388
|
-
const saveClick = async () => {
|
|
389
|
-
if (activeFile.mimetype.startsWith('image/') || activeFile.mimetype.startsWith('video/')) {
|
|
390
|
-
await saveToGallery();
|
|
391
|
-
} else {
|
|
392
|
-
await saveFileToDownloads();
|
|
393
|
-
}
|
|
394
|
-
};
|
|
328
|
+
const saveFile = useSaveFile();
|
|
329
|
+
const saveClick = () => saveFile(activeFile);
|
|
395
330
|
|
|
396
331
|
// An album opens with its siblings; the viewer pages through them.
|
|
397
332
|
const albumSize = activeFile.siblings?.length ?? 0;
|
|
@@ -401,20 +336,22 @@ const FilePreviewModal = ({
|
|
|
401
336
|
if (!target) {
|
|
402
337
|
return;
|
|
403
338
|
}
|
|
404
|
-
|
|
339
|
+
onChangeFile({
|
|
405
340
|
...target,
|
|
406
341
|
siblings: activeFile.siblings,
|
|
407
342
|
index: next
|
|
408
|
-
})
|
|
409
|
-
};
|
|
410
|
-
const closeModal = () => {
|
|
411
|
-
dispatch(setActiveFile({
|
|
412
|
-
fileName: '',
|
|
413
|
-
fileURL: '',
|
|
414
|
-
mimetype: ''
|
|
415
|
-
}));
|
|
416
|
-
handleCloseModal?.();
|
|
343
|
+
});
|
|
417
344
|
};
|
|
345
|
+
const closeModal = onClose;
|
|
346
|
+
if (activeFile.mimetype.startsWith('image/') || activeFile.mimetype.startsWith('video/')) {
|
|
347
|
+
return /*#__PURE__*/_jsx(MediaViewer, {
|
|
348
|
+
file: activeFile,
|
|
349
|
+
onClose: onClose,
|
|
350
|
+
onPage: goToSibling,
|
|
351
|
+
onSave: saveClick,
|
|
352
|
+
onReplyOpened: onReplyOpened
|
|
353
|
+
});
|
|
354
|
+
}
|
|
418
355
|
|
|
419
356
|
// NOTE: plain computed value, NOT useMemo. It sits AFTER the
|
|
420
357
|
// `if (!activeFile) return` guard above, so as a hook it would run
|