Page MenuHomePhabricator

D10687.diff
No OneTemporary

D10687.diff

diff --git a/lib/keyserver-conn/keyserver-call-infos.js b/lib/keyserver-conn/keyserver-call-infos.js
--- a/lib/keyserver-conn/keyserver-call-infos.js
+++ b/lib/keyserver-conn/keyserver-call-infos.js
@@ -11,7 +11,7 @@
+urlPrefix: $PropertyType<KeyserverInfo, 'urlPrefix'>,
}>;
-export type KeyserverCallInfo = {
+type KeyserverCallInfo = {
+cookie: ?string,
+urlPrefix: string,
+sessionID: ?string,
diff --git a/lib/utils/keyserver-call.js b/lib/utils/keyserver-call.js
--- a/lib/utils/keyserver-call.js
+++ b/lib/utils/keyserver-call.js
@@ -10,7 +10,6 @@
import {
useKeyserverCallInfos,
type KeyserverInfoPartial,
- type KeyserverCallInfo,
} from '../keyserver-conn/keyserver-call-infos.js';
import type { Endpoint } from '../types/endpoints.js';
import type { Dispatch } from '../types/redux-types.js';
@@ -30,78 +29,6 @@
allKeyserverIDs: $ReadOnlyArray<string>,
) => Args => Promise<Return>;
-type BindCallKeyserverSelector = <Args: mixed, Return>(
- keyserverCall: ActionFunc<Args, Return>,
-) => Args => Promise<Return>;
-function useBindCallKeyserverEndpointSelector(
- dispatch: Dispatch,
- currentUserInfo: ?CurrentUserInfo,
- keyserverCallInfos: { +[keyserverID: string]: KeyserverCallInfo },
-): BindCallKeyserverSelector {
- const { createCallSingleKeyserverEndpointSelector } =
- useCallKeyserverEndpointContext();
- const getCallSingleKeyserverEndpointSelector: typeof createCallSingleKeyserverEndpointSelector =
- React.useMemo(
- () => _memoize(createCallSingleKeyserverEndpointSelector),
- [createCallSingleKeyserverEndpointSelector],
- );
- return React.useMemo(
- () =>
- _memoize(
- <Args: mixed, Return>(
- keyserverCall: ActionFunc<Args, Return>,
- ): (Args => Promise<Return>) => {
- const callKeyserverEndpoint = (
- endpoint: Endpoint,
- requests: { +[keyserverID: string]: ?{ +[string]: mixed } },
- options?: ?CallServerEndpointOptions,
- ) => {
- const makeCallToSingleKeyserver = (keyserverID: string) => {
- const {
- cookie,
- urlPrefix,
- sessionID,
- isSocketConnected,
- lastCommunicatedPlatformDetails,
- } = keyserverCallInfos[keyserverID];
-
- const boundCallServerEndpoint =
- getCallSingleKeyserverEndpointSelector(keyserverID)({
- dispatch,
- currentUserInfo,
- cookie,
- urlPrefix,
- sessionID,
- isSocketConnected,
- lastCommunicatedPlatformDetails,
- });
-
- return boundCallServerEndpoint(
- endpoint,
- requests[keyserverID],
- options,
- );
- };
-
- const promises: { [string]: Promise<Object> } = {};
- for (const keyserverID in requests) {
- promises[keyserverID] = makeCallToSingleKeyserver(keyserverID);
- }
- return promiseAll(promises);
- };
- const keyserverIDs = Object.keys(keyserverCallInfos);
- return keyserverCall(callKeyserverEndpoint, keyserverIDs);
- },
- ),
- [
- dispatch,
- currentUserInfo,
- keyserverCallInfos,
- getCallSingleKeyserverEndpointSelector,
- ],
- );
-}
-
export type KeyserverCallParamOverride = Partial<{
+dispatch: Dispatch,
+currentUserInfo: ?CurrentUserInfo,
@@ -132,17 +59,63 @@
} = baseCombinedInfo;
const keyserverCallInfos = useKeyserverCallInfos(keyserverInfoPartials);
- const bindCallKeyserverEndpointToAction =
- useBindCallKeyserverEndpointSelector(
- dispatch,
- currentUserInfo,
- keyserverCallInfos,
+ const { createCallSingleKeyserverEndpointSelector } =
+ useCallKeyserverEndpointContext();
+ const getCallSingleKeyserverEndpointSelector: typeof createCallSingleKeyserverEndpointSelector =
+ React.useMemo(
+ () => _memoize(createCallSingleKeyserverEndpointSelector),
+ [createCallSingleKeyserverEndpointSelector],
);
- return React.useMemo(
- () => bindCallKeyserverEndpointToAction(keyserverCall),
- [bindCallKeyserverEndpointToAction, keyserverCall],
- );
+ return React.useMemo(() => {
+ const callKeyserverEndpoint = (
+ endpoint: Endpoint,
+ requests: { +[keyserverID: string]: ?{ +[string]: mixed } },
+ options?: ?CallServerEndpointOptions,
+ ) => {
+ const makeCallToSingleKeyserver = (keyserverID: string) => {
+ const {
+ cookie,
+ urlPrefix,
+ sessionID,
+ isSocketConnected,
+ lastCommunicatedPlatformDetails,
+ } = keyserverCallInfos[keyserverID];
+
+ const boundCallServerEndpoint = getCallSingleKeyserverEndpointSelector(
+ keyserverID,
+ )({
+ dispatch,
+ currentUserInfo,
+ cookie,
+ urlPrefix,
+ sessionID,
+ isSocketConnected,
+ lastCommunicatedPlatformDetails,
+ });
+
+ return boundCallServerEndpoint(
+ endpoint,
+ requests[keyserverID],
+ options,
+ );
+ };
+
+ const promises: { [string]: Promise<Object> } = {};
+ for (const keyserverID in requests) {
+ promises[keyserverID] = makeCallToSingleKeyserver(keyserverID);
+ }
+ return promiseAll(promises);
+ };
+ const keyserverIDs = Object.keys(keyserverCallInfos);
+ return keyserverCall(callKeyserverEndpoint, keyserverIDs);
+ }, [
+ dispatch,
+ currentUserInfo,
+ keyserverCallInfos,
+ getCallSingleKeyserverEndpointSelector,
+ keyserverCall,
+ ]);
}
export { useKeyserverCall };

File Metadata

Mime Type
text/plain
Expires
Sun, Dec 1, 3:45 PM (21 h, 46 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2605377
Default Alt Text
D10687.diff (5 KB)

Event Timeline