Page MenuHomePhabricator

D10311.id34531.diff
No OneTemporary

D10311.id34531.diff

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

Mime Type
text/plain
Expires
Tue, Dec 24, 5:39 AM (12 h, 21 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2698540
Default Alt Text
D10311.id34531.diff (3 KB)

Event Timeline