Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3380184
D10682.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
6 KB
Referenced Files
None
Subscribers
None
D10682.diff
View Options
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<F> = (callServerEndpoint: CallServerEndpoint) => F;
-type CreateBoundServerCallsSelectorType = <F>(
- ActionFunc<F>,
-) => BindServerCallsParams => F;
+type CreateBoundServerCallsSelectorType = (
+ keyserverID: string,
+) => <F>(ActionFunc<F>) => 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(
- <F>(actionFunc: ActionFunc<F>): (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,
+ ): (<F>(actionFunc: ActionFunc<F>) => 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<F>(
serverCall: ActionFunc<F>,
- paramOverride?: ?Partial<BindServerCallsParams>,
+ paramOverride?: ?Partial<ServerCallSelectorParams>,
): 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<BindServerCallsParams>,
+ +keyserverCallParamOverride?: Partial<ServerCallSelectorParams>,
};
function SIWEPanel(props: Props): React.Node {
const dispatchActionPromise = useDispatchActionPromise();
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Nov 28, 9:46 PM (21 h, 44 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2594980
Default Alt Text
D10682.diff (6 KB)
Attached To
Mode
D10682: [lib][native] Have createBoundServerCallsSelector take keyserverID in first
Attached
Detach File
Event Timeline
Log In to Comment