diff --git a/lib/socket/socket.react.js b/lib/socket/socket.react.js --- a/lib/socket/socket.react.js +++ b/lib/socket/socket.react.js @@ -74,7 +74,6 @@ import { promiseAll } from '../utils/promises.js'; import type { DispatchActionPromise } from '../utils/redux-promise-utils.js'; import sleep from '../utils/sleep.js'; -import { ashoatKeyserverID } from '../utils/validation-utils.js'; const remainingTimeAfterVisualTimeout = clientRequestSocketTimeout - clientRequestVisualTimeout; @@ -164,7 +163,7 @@ } this.props.dispatch({ type: updateConnectionStatusActionType, - payload: { status: newStatus, keyserverID: ashoatKeyserverID }, + payload: { status: newStatus, keyserverID: this.props.keyserverID }, }); const socket = this.props.openSocket(); @@ -215,7 +214,7 @@ markSocketInitialized() { this.props.dispatch({ type: updateConnectionStatusActionType, - payload: { status: 'connected', keyserverID: ashoatKeyserverID }, + payload: { status: 'connected', keyserverID: this.props.keyserverID }, }); this.resetPing(); } @@ -236,7 +235,7 @@ this.stopPing(); this.props.dispatch({ type: updateConnectionStatusActionType, - payload: { status: 'disconnecting', keyserverID: ashoatKeyserverID }, + payload: { status: 'disconnecting', keyserverID: this.props.keyserverID }, }); if (!activityUpdatePending) { this.finishClosingSocket(); @@ -251,7 +250,7 @@ type: updateConnectionStatusActionType, payload: { status: 'forcedDisconnecting', - keyserverID: ashoatKeyserverID, + keyserverID: this.props.keyserverID, }, }); } @@ -276,7 +275,10 @@ if (this.props.connection.status !== 'disconnected') { this.props.dispatch({ type: updateConnectionStatusActionType, - payload: { status: 'disconnected', keyserverID: ashoatKeyserverID }, + payload: { + status: 'disconnected', + keyserverID: this.props.keyserverID, + }, }); } if (this.reopenConnectionAfterClosing) { @@ -359,7 +361,7 @@ sendMessage={this.sendMessageWithoutID} addListener={this.addListener} removeListener={this.removeListener} - keyserverID={ashoatKeyserverID} + keyserverID={this.props.keyserverID} /> { this.props.dispatch({ type: setLateResponseActionType, - payload: { messageID, isLate, keyserverID: ashoatKeyserverID }, + payload: { messageID, isLate, keyserverID: this.props.keyserverID }, }); }; @@ -815,7 +820,7 @@ } this.props.dispatch({ type: unsupervisedBackgroundActionType, - payload: { keyserverID: ashoatKeyserverID }, + payload: { keyserverID: this.props.keyserverID }, }); return true; }; diff --git a/native/socket.react.js b/native/socket.react.js --- a/native/socket.react.js +++ b/native/socket.react.js @@ -20,7 +20,6 @@ import { logInActionSources } from 'lib/types/account-types.js'; import { useDispatchActionPromise } from 'lib/utils/redux-promise-utils.js'; import { useDispatch } from 'lib/utils/redux-utils.js'; -import { ashoatKeyserverID } from 'lib/utils/validation-utils.js'; import { InputStateContext } from './input/input-state.js'; import { @@ -44,27 +43,29 @@ const inputState = React.useContext(InputStateContext); const navContext = React.useContext(NavContext); - const cookie = useSelector(cookieSelector(ashoatKeyserverID)); - const urlPrefix = useSelector(urlPrefixSelector(ashoatKeyserverID)); + const { keyserverID } = props; + + const cookie = useSelector(cookieSelector(keyserverID)); + const urlPrefix = useSelector(urlPrefixSelector(keyserverID)); invariant(urlPrefix, 'missing urlPrefix for given keyserver id'); - const connection = useSelector(connectionSelector(ashoatKeyserverID)); + const connection = useSelector(connectionSelector(keyserverID)); invariant(connection, 'keyserver missing from keyserverStore'); const frozen = useSelector(state => state.frozen); const active = useSelector( state => isLoggedIn(state) && state.lifecycleState !== 'background', ); const noDataAfterPolicyAcknowledgment = useSelector( - noDataAfterPolicyAcknowledgmentSelector(ashoatKeyserverID), + noDataAfterPolicyAcknowledgmentSelector(keyserverID), ); const currentUserInfo = useSelector(state => state.currentUserInfo); - const openSocket = useSelector(openSocketSelector(ashoatKeyserverID)); + const openSocket = useSelector(openSocketSelector(keyserverID)); invariant(openSocket, 'openSocket failed to be created'); const sessionIdentification = useSelector( - sessionIdentificationSelector(ashoatKeyserverID), + sessionIdentificationSelector(keyserverID), ); const preRequestUserState = useSelector( - preRequestUserStateForSingleKeyserverSelector(ashoatKeyserverID), + preRequestUserStateForSingleKeyserverSelector(keyserverID), ); const getInitialNotificationsEncryptedMessage = @@ -80,7 +81,7 @@ }), ); const sessionStateFunc = useSelector(state => - nativeSessionStateFuncSelector(ashoatKeyserverID)({ + nativeSessionStateFuncSelector(keyserverID)({ redux: state, navContext, }), @@ -107,7 +108,7 @@ }, [active, navContext]); const lastCommunicatedPlatformDetails = useSelector( - lastCommunicatedPlatformDetailsSelector(ashoatKeyserverID), + lastCommunicatedPlatformDetailsSelector(keyserverID), ); const dispatch = useDispatch(); @@ -118,7 +119,7 @@ void dispatch({ type: setConnectionIssueActionType, payload: { - keyserverID: ashoatKeyserverID, + keyserverID, connectionIssue: 'policy_acknowledgement_socket_crash_loop', }, }); @@ -135,7 +136,7 @@ cookie, urlPrefix, logInActionSources.refetchUserDataAfterAcknowledgment, - ashoatKeyserverID, + keyserverID, getInitialNotificationsEncryptedMessage, ); }, [ @@ -144,6 +145,7 @@ dispatch, urlPrefix, getInitialNotificationsEncryptedMessage, + keyserverID, ]); return ( diff --git a/web/socket.react.js b/web/socket.react.js --- a/web/socket.react.js +++ b/web/socket.react.js @@ -17,7 +17,6 @@ import type { OlmSessionInitializationInfo } from 'lib/types/request-types.js'; import { useDispatchActionPromise } from 'lib/utils/redux-promise-utils.js'; import { useDispatch } from 'lib/utils/redux-utils.js'; -import { ashoatKeyserverID } from 'lib/utils/validation-utils.js'; import { useGetSignedIdentityKeysBlob, @@ -37,10 +36,12 @@ const WebSocket: React.ComponentType = React.memo(function WebSocket(props) { - const cookie = useSelector(cookieSelector(ashoatKeyserverID)); - const urlPrefix = useSelector(urlPrefixSelector(ashoatKeyserverID)); + const { keyserverID } = props; + + const cookie = useSelector(cookieSelector(keyserverID)); + const urlPrefix = useSelector(urlPrefixSelector(keyserverID)); invariant(urlPrefix, 'missing urlPrefix for given keyserver id'); - const connection = useSelector(connectionSelector(ashoatKeyserverID)); + const connection = useSelector(connectionSelector(keyserverID)); invariant(connection, 'keyserver missing from keyserverStore'); const active = useSelector( state => @@ -49,13 +50,13 @@ state.lifecycleState !== 'background', ); - const openSocket = useSelector(openSocketSelector(ashoatKeyserverID)); + const openSocket = useSelector(openSocketSelector(keyserverID)); invariant(openSocket, 'openSocket failed to be created'); const sessionIdentification = useSelector( - sessionIdentificationSelector(ashoatKeyserverID), + sessionIdentificationSelector(keyserverID), ); const preRequestUserState = useSelector( - preRequestUserStateForSingleKeyserverSelector(ashoatKeyserverID), + preRequestUserStateForSingleKeyserverSelector(keyserverID), ); const getSignedIdentityKeysBlob = useGetSignedIdentityKeysBlob(); const webNotificationsSessionCreator = useWebNotificationsSessionCreator(); @@ -68,9 +69,9 @@ cookie, notificationsIdentityKeys, notificationsInitializationInfo, - ashoatKeyserverID, + keyserverID, ), - [webNotificationsSessionCreator, cookie], + [webNotificationsSessionCreator, cookie, keyserverID], ); const getInitialNotificationsEncryptedMessage = useInitialNotificationsEncryptedMessage(webNotifsSessionCreatorForCookie); @@ -82,7 +83,7 @@ }), ); const sessionStateFunc = useSelector( - webSessionStateFuncSelector(ashoatKeyserverID), + webSessionStateFuncSelector(keyserverID), ); const currentCalendarQuery = useSelector(webCalendarQuery); @@ -99,7 +100,7 @@ const dispatchActionPromise = useDispatchActionPromise(); const lastCommunicatedPlatformDetails = useSelector( - lastCommunicatedPlatformDetailsSelector(ashoatKeyserverID), + lastCommunicatedPlatformDetailsSelector(keyserverID), ); return (