Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3522055
D10311.id34530.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Referenced Files
None
Subscribers
None
D10311.id34530.diff
View Options
diff --git a/lib/actions/link-actions.js b/lib/actions/link-actions.js
--- a/lib/actions/link-actions.js
+++ b/lib/actions/link-actions.js
@@ -49,35 +49,41 @@
};
};
-function useVerifyInviteLink(keyserverOverride?: {
- +keyserverID: string,
- +keyserverURL: string,
-}): (
+function useVerifyInviteLink(): (
request: InviteLinkVerificationRequest,
+ keyserverOverride?: {
+ +keyserverID: string,
+ +keyserverURL: string,
+ },
) => Promise<InviteLinkVerificationResponse> {
- const keyserverID = keyserverOverride?.keyserverID ?? ashoatKeyserverID;
- const isKeyserverKnown = useSelector(
- state => !!state.keyserverStore.keyserverInfos[keyserverID],
- );
-
- let paramOverride = null;
- if (keyserverOverride && !isKeyserverKnown) {
- paramOverride = {
- keyserverInfos: {
- [keyserverOverride.keyserverID]: {
- urlPrefix: keyserverOverride.keyserverURL,
- },
- },
- };
- }
- const callVerifyInviteLink = useKeyserverCall(
- verifyInviteLink,
- paramOverride,
+ const callVerifyInviteLink = useKeyserverCall(verifyInviteLink);
+ const keyserverInfos = useSelector(
+ state => state.keyserverStore.keyserverInfos,
);
return React.useCallback(
- (request: InviteLinkVerificationRequest) =>
- callVerifyInviteLink({ request, keyserverID }),
- [callVerifyInviteLink, keyserverID],
+ (
+ request: InviteLinkVerificationRequest,
+ keyserverOverride?: {
+ +keyserverID: string,
+ +keyserverURL: string,
+ },
+ ) => {
+ const keyserverID = keyserverOverride?.keyserverID ?? ashoatKeyserverID;
+ const isKeyserverKnown = !!keyserverInfos[keyserverID];
+
+ let paramOverride = null;
+ if (keyserverOverride && !isKeyserverKnown) {
+ paramOverride = {
+ keyserverInfos: {
+ [keyserverOverride.keyserverID]: {
+ urlPrefix: keyserverOverride.keyserverURL,
+ },
+ },
+ };
+ }
+ return callVerifyInviteLink({ request, keyserverID }, paramOverride);
+ },
+ [callVerifyInviteLink, keyserverInfos],
);
}
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
@@ -90,7 +90,8 @@
Return,
>(
keyserverCall: ActionFunc<Args, Return>,
-) => Args => Promise<Return> = createSelector(
+ paramOverride?: ?KeyserverCallParamOverride,
+) => (Args, ?KeyserverCallParamOverride) => Promise<Return> = createSelector(
(state: BindKeyserverCallParams) => state.dispatch,
(state: BindKeyserverCallParams) => state.currentUserInfo,
(state: BindKeyserverCallParams) => state.keyserverInfos,
@@ -102,6 +103,7 @@
return _memoize(
<Args: mixed, Return>(
keyserverCall: ActionFunc<Args, Return>,
+ paramOverride?: ?KeyserverCallParamOverride,
): (Args => Promise<Return>) => {
const callKeyserverEndpoint = (
endpoint: Endpoint,
@@ -115,7 +117,10 @@
sessionID,
connection,
lastCommunicatedPlatformDetails,
- } = keyserverInfos[keyserverID];
+ } = {
+ ...keyserverInfos[keyserverID],
+ ...paramOverride,
+ };
const boundCallServerEndpoint = createBoundServerCallsSelector(
keyserverID,
@@ -155,7 +160,7 @@
function useKeyserverCall<Args: mixed, Return>(
keyserverCall: ActionFunc<Args, Return>,
paramOverride?: ?KeyserverCallParamOverride,
-): Args => Promise<Return> {
+): (Args, ?KeyserverCallParamOverride) => Promise<Return> {
const dispatch = useDispatch();
const keyserverInfos = useSelector(
state => state.keyserverStore.keyserverInfos,
@@ -168,7 +173,7 @@
...paramOverride,
});
return React.useMemo(
- () => bindCallKeyserverEndpointToAction(keyserverCall),
+ overrides => bindCallKeyserverEndpointToAction(keyserverCall, overrides),
[bindCallKeyserverEndpointToAction, keyserverCall],
);
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Dec 24, 5:39 AM (12 h, 32 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2698539
Default Alt Text
D10311.id34530.diff (3 KB)
Attached To
Mode
D10311: [lib] Allow overriding a keyserver in a function returned from useKeyserverCall hook
Attached
Detach File
Event Timeline
Log In to Comment