Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3393916
D10687.id35823.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
5 KB
Referenced Files
None
Subscribers
None
D10687.id35823.diff
View Options
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
Details
Attached
Mime Type
text/plain
Expires
Sun, Dec 1, 4:27 PM (20 h, 43 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2605377
Default Alt Text
D10687.id35823.diff (5 KB)
Attached To
Mode
D10687: [lib] Inline useBindCallKeyserverEndpointSelector
Attached
Detach File
Event Timeline
Log In to Comment