diff --git a/lib/keyserver-conn/call-keyserver-endpoint-provider.react.js b/lib/keyserver-conn/call-keyserver-endpoint-provider.react.js --- a/lib/keyserver-conn/call-keyserver-endpoint-provider.react.js +++ b/lib/keyserver-conn/call-keyserver-endpoint-provider.react.js @@ -22,9 +22,9 @@ import callServerEndpoint from '../utils/call-server-endpoint.js'; export type ActionFunc = (callServerEndpoint: CallServerEndpoint) => F; -type CreateBoundServerCallsSelectorType = ( - ActionFunc, -) => BindServerCallsParams => F; +type CreateBoundServerCallsSelectorType = ( + keyserverID: string, +) => (ActionFunc) => ServerCallSelectorParams => F; type CallKeyserverEndpointContextType = { +bindCookieAndUtilsIntoCallServerEndpoint: ( params: BindServerCallsParams, @@ -39,7 +39,7 @@ +waitingCalls: Array<(callServerEndpoint: ?CallServerEndpoint) => mixed>, }; -export type BindServerCallsParams = { +export type ServerCallSelectorParams = { +dispatch: Dispatch, +cookie: ?string, +urlPrefix: string, @@ -47,8 +47,11 @@ +currentUserInfo: ?CurrentUserInfo, +isSocketConnected: boolean, +lastCommunicatedPlatformDetails: ?PlatformDetails, - +keyserverID: string, }; +export type BindServerCallsParams = $ReadOnly<{ + ...ServerCallSelectorParams, + +keyserverID: string, +}>; type Props = { +children: React.Node, @@ -198,40 +201,42 @@ // "bound" callServerEndpoint that no longer needs the cookie as a parameter // on to the server call. const createBoundServerCallsSelector = React.useCallback( - (actionFunc: ActionFunc): (BindServerCallsParams => F) => - createSelector( - (state: BindServerCallsParams) => state.dispatch, - (state: BindServerCallsParams) => state.cookie, - (state: BindServerCallsParams) => state.urlPrefix, - (state: BindServerCallsParams) => state.sessionID, - (state: BindServerCallsParams) => state.currentUserInfo, - (state: BindServerCallsParams) => state.isSocketConnected, - (state: BindServerCallsParams) => state.lastCommunicatedPlatformDetails, - (state: BindServerCallsParams) => state.keyserverID, - ( - dispatch: Dispatch, - cookie: ?string, - urlPrefix: string, - sessionID: ?string, - currentUserInfo: ?CurrentUserInfo, - isSocketConnected: boolean, - lastCommunicatedPlatformDetails: ?PlatformDetails, - keyserverID: string, - ) => { - const boundCallServerEndpoint = - bindCookieAndUtilsIntoCallServerEndpoint({ - dispatch, - cookie, - urlPrefix, - sessionID, - currentUserInfo, - isSocketConnected, - lastCommunicatedPlatformDetails, - keyserverID, - }); - return actionFunc(boundCallServerEndpoint); - }, - ), + ( + keyserverID: string, + ): ((actionFunc: ActionFunc) => ServerCallSelectorParams => F) => + actionFunc => + createSelector( + (state: ServerCallSelectorParams) => state.dispatch, + (state: ServerCallSelectorParams) => state.cookie, + (state: ServerCallSelectorParams) => state.urlPrefix, + (state: ServerCallSelectorParams) => state.sessionID, + (state: ServerCallSelectorParams) => state.currentUserInfo, + (state: ServerCallSelectorParams) => state.isSocketConnected, + (state: ServerCallSelectorParams) => + state.lastCommunicatedPlatformDetails, + ( + dispatch: Dispatch, + cookie: ?string, + urlPrefix: string, + sessionID: ?string, + currentUserInfo: ?CurrentUserInfo, + isSocketConnected: boolean, + lastCommunicatedPlatformDetails: ?PlatformDetails, + ) => { + const boundCallServerEndpoint = + bindCookieAndUtilsIntoCallServerEndpoint({ + dispatch, + cookie, + urlPrefix, + sessionID, + currentUserInfo, + isSocketConnected, + lastCommunicatedPlatformDetails, + keyserverID, + }); + return actionFunc(boundCallServerEndpoint); + }, + ), [bindCookieAndUtilsIntoCallServerEndpoint], ); diff --git a/lib/utils/action-utils.js b/lib/utils/action-utils.js --- a/lib/utils/action-utils.js +++ b/lib/utils/action-utils.js @@ -7,14 +7,14 @@ import { ashoatKeyserverID } from './validation-utils.js'; import { type ActionFunc, - type BindServerCallsParams, + type ServerCallSelectorParams, useCallKeyserverEndpointContext, } from '../keyserver-conn/call-keyserver-endpoint-provider.react.js'; import { serverCallStateSelector } from '../selectors/server-calls.js'; function useServerCall( serverCall: ActionFunc, - paramOverride?: ?Partial, + paramOverride?: ?Partial, ): F { const dispatch = useDispatch(); const serverCallState = useSelector( @@ -22,7 +22,7 @@ ); const { createBoundServerCallsSelector } = useCallKeyserverEndpointContext(); const selector = React.useMemo( - () => createBoundServerCallsSelector(serverCall), + () => createBoundServerCallsSelector(ashoatKeyserverID)(serverCall), [createBoundServerCallsSelector, serverCall], ); @@ -41,7 +41,6 @@ isSocketConnected, dispatch, ...paramOverride, - keyserverID: ashoatKeyserverID, }); }, [serverCallState, dispatch, paramOverride, selector]); } diff --git a/native/account/siwe-panel.react.js b/native/account/siwe-panel.react.js --- a/native/account/siwe-panel.react.js +++ b/native/account/siwe-panel.react.js @@ -10,7 +10,7 @@ getSIWENonceActionTypes, siweAuthActionTypes, } from 'lib/actions/siwe-actions.js'; -import type { BindServerCallsParams } from 'lib/keyserver-conn/call-keyserver-endpoint-provider.react.js'; +import type { ServerCallSelectorParams } from 'lib/keyserver-conn/call-keyserver-endpoint-provider.react.js'; import { createLoadingStatusSelector } from 'lib/selectors/loading-selectors.js'; import type { SIWEWebViewMessage, SIWEResult } from 'lib/types/siwe-types.js'; import { useServerCall } from 'lib/utils/action-utils.js'; @@ -45,7 +45,7 @@ +onSuccessfulWalletSignature: SIWEResult => mixed, +closing: boolean, +setLoading: boolean => mixed, - +keyserverCallParamOverride?: Partial, + +keyserverCallParamOverride?: Partial, }; function SIWEPanel(props: Props): React.Node { const dispatchActionPromise = useDispatchActionPromise();