diff --git a/lib/actions/activity-actions.js b/lib/actions/activity-actions.js --- a/lib/actions/activity-actions.js +++ b/lib/actions/activity-actions.js @@ -1,13 +1,13 @@ // @flow import { extractKeyserverIDFromID } from '../keyserver-conn/keyserver-call-utils.js'; +import type { CallKeyserverEndpoint } from '../keyserver-conn/keyserver-conn-types.js'; import type { ActivityUpdate, ActivityUpdateSuccessPayload, SetThreadUnreadStatusPayload, SetThreadUnreadStatusRequest, } from '../types/activity-types.js'; -import type { CallKeyserverEndpoint } from '../utils/keyserver-call'; import { useKeyserverCall } from '../utils/keyserver-call.js'; export type UpdateActivityInput = { diff --git a/lib/actions/device-actions.js b/lib/actions/device-actions.js --- a/lib/actions/device-actions.js +++ b/lib/actions/device-actions.js @@ -1,15 +1,13 @@ // @flow +import type { CallKeyserverEndpoint } from '../keyserver-conn/keyserver-conn-types.js'; import type { GetVersionActionPayload, DeviceTokenUpdateRequest, } from '../types/device-types'; import { getConfig } from '../utils/config.js'; import { useKeyserverCall } from '../utils/keyserver-call.js'; -import type { - CallKeyserverEndpoint, - KeyserverCallParamOverride, -} from '../utils/keyserver-call.js'; +import type { KeyserverCallParamOverride } from '../utils/keyserver-call.js'; export type DeviceTokens = { +[keyserverID: string]: ?string, diff --git a/lib/actions/entry-actions.js b/lib/actions/entry-actions.js --- a/lib/actions/entry-actions.js +++ b/lib/actions/entry-actions.js @@ -4,6 +4,7 @@ extractKeyserverIDFromID, sortCalendarQueryPerKeyserver, } from '../keyserver-conn/keyserver-call-utils.js'; +import type { CallKeyserverEndpoint } from '../keyserver-conn/keyserver-conn-types.js'; import { localIDPrefix } from '../shared/message-utils.js'; import type { RawEntryInfo, @@ -22,7 +23,6 @@ import type { HistoryRevisionInfo } from '../types/history-types.js'; import { dateFromString } from '../utils/date-utils.js'; import { useKeyserverCall } from '../utils/keyserver-call.js'; -import type { CallKeyserverEndpoint } from '../utils/keyserver-call.js'; const fetchEntriesActionTypes = Object.freeze({ started: 'FETCH_ENTRIES_STARTED', 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 @@ -1,6 +1,7 @@ // @flow import { extractKeyserverIDFromID } from '../keyserver-conn/keyserver-call-utils.js'; +import type { CallKeyserverEndpoint } from '../keyserver-conn/keyserver-conn-types.js'; import type { FetchInviteLinksResponse, InviteLinkVerificationRequest, @@ -12,7 +13,6 @@ } from '../types/link-types.js'; import type { CallSingleKeyserverEndpoint } from '../utils/call-single-keyserver-endpoint.js'; import { useKeyserverCall } from '../utils/keyserver-call.js'; -import type { CallKeyserverEndpoint } from '../utils/keyserver-call.js'; const verifyInviteLinkActionTypes = Object.freeze({ started: 'VERIFY_INVITE_LINK_STARTED', diff --git a/lib/actions/message-actions.js b/lib/actions/message-actions.js --- a/lib/actions/message-actions.js +++ b/lib/actions/message-actions.js @@ -6,6 +6,7 @@ extractKeyserverIDFromID, sortThreadIDsPerKeyserver, } from '../keyserver-conn/keyserver-call-utils.js'; +import type { CallKeyserverEndpoint } from '../keyserver-conn/keyserver-conn-types.js'; import type { FetchMessageInfosPayload, SendMessageResult, @@ -28,7 +29,6 @@ } from '../types/thread-types.js'; import type { CallSingleKeyserverEndpointResultInfo } from '../utils/call-single-keyserver-endpoint.js'; import { useKeyserverCall } from '../utils/keyserver-call.js'; -import type { CallKeyserverEndpoint } from '../utils/keyserver-call.js'; const fetchMessagesBeforeCursorActionTypes = Object.freeze({ started: 'FETCH_MESSAGES_BEFORE_CURSOR_STARTED', diff --git a/lib/actions/message-report-actions.js b/lib/actions/message-report-actions.js --- a/lib/actions/message-report-actions.js +++ b/lib/actions/message-report-actions.js @@ -1,11 +1,11 @@ // @flow import { extractKeyserverIDFromID } from '../keyserver-conn/keyserver-call-utils.js'; +import type { CallKeyserverEndpoint } from '../keyserver-conn/keyserver-conn-types.js'; import type { MessageReportCreationRequest, MessageReportCreationResult, } from '../types/message-report-types.js'; -import type { CallKeyserverEndpoint } from '../utils/keyserver-call.js'; import { useKeyserverCall } from '../utils/keyserver-call.js'; const sendMessageReportActionTypes = Object.freeze({ diff --git a/lib/actions/thread-actions.js b/lib/actions/thread-actions.js --- a/lib/actions/thread-actions.js +++ b/lib/actions/thread-actions.js @@ -4,6 +4,7 @@ import genesis from '../facts/genesis.js'; import { extractKeyserverIDFromID } from '../keyserver-conn/keyserver-call-utils.js'; +import type { CallKeyserverEndpoint } from '../keyserver-conn/keyserver-conn-types.js'; import type { ChangeThreadSettingsPayload, LeaveThreadPayload, @@ -19,7 +20,6 @@ RoleDeletionRequest, RoleDeletionPayload, } from '../types/thread-types.js'; -import type { CallKeyserverEndpoint } from '../utils/keyserver-call'; import { useKeyserverCall } from '../utils/keyserver-call.js'; import { values } from '../utils/objects.js'; diff --git a/lib/actions/upload-actions.js b/lib/actions/upload-actions.js --- a/lib/actions/upload-actions.js +++ b/lib/actions/upload-actions.js @@ -4,6 +4,7 @@ import blobService from '../facts/blob-service.js'; import { extractKeyserverIDFromID } from '../keyserver-conn/keyserver-call-utils.js'; +import type { CallKeyserverEndpoint } from '../keyserver-conn/keyserver-conn-types.js'; import type { UploadMultimediaResult, Dimensions } from '../types/media-types'; import { toBase64URL } from '../utils/base64.js'; import { @@ -14,7 +15,6 @@ import type { CallSingleKeyserverEndpoint } from '../utils/call-single-keyserver-endpoint.js'; import { getMessageForException } from '../utils/errors.js'; import { useKeyserverCall } from '../utils/keyserver-call.js'; -import type { CallKeyserverEndpoint } from '../utils/keyserver-call.js'; import { handleHTTPResponseError } from '../utils/services-utils.js'; import { type UploadBlob } from '../utils/upload-blob.js'; diff --git a/lib/actions/user-actions.js b/lib/actions/user-actions.js --- a/lib/actions/user-actions.js +++ b/lib/actions/user-actions.js @@ -7,6 +7,7 @@ sortThreadIDsPerKeyserver, sortCalendarQueryPerKeyserver, } from '../keyserver-conn/keyserver-call-utils.js'; +import type { CallKeyserverEndpoint } from '../keyserver-conn/keyserver-conn-types.js'; import { preRequestUserStateSelector } from '../selectors/account-selectors.js'; import { IdentityClientContext } from '../shared/identity-client-context.js'; import threadWatcher from '../shared/thread-watcher.js'; @@ -63,7 +64,6 @@ CallSingleKeyserverEndpointOptions, } from '../utils/call-single-keyserver-endpoint.js'; import { getConfig } from '../utils/config.js'; -import type { CallKeyserverEndpoint } from '../utils/keyserver-call'; import { useKeyserverCall } from '../utils/keyserver-call.js'; import { useSelector } from '../utils/redux-utils.js'; import sleep from '../utils/sleep.js'; 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 @@ -26,9 +26,11 @@ type CreateCallSingleKeyserverEndpointSelector = ( keyserverID: string, ) => ServerCallSelectorParams => CallSingleKeyserverEndpoint; + type GetCallSingleKeyserverEndpoint = ( keyserverID: string, ) => CallSingleKeyserverEndpoint; + type CallKeyserverEndpointContextType = { +createCallSingleKeyserverEndpointSelector: CreateCallSingleKeyserverEndpointSelector, +getCallSingleKeyserverEndpoint: GetCallSingleKeyserverEndpoint, diff --git a/lib/keyserver-conn/keyserver-conn-types.js b/lib/keyserver-conn/keyserver-conn-types.js --- a/lib/keyserver-conn/keyserver-conn-types.js +++ b/lib/keyserver-conn/keyserver-conn-types.js @@ -5,11 +5,16 @@ LogInStartingPayload, LogInResult, } from '../types/account-types.js'; +import type { Endpoint } from '../types/endpoints.js'; import type { Dispatch } from '../types/redux-types.js'; import type { ClientSessionChange, PreRequestUserState, } from '../types/session-types.js'; +import type { + CallSingleKeyserverEndpoint, + CallSingleKeyserverEndpointOptions, +} from '../utils/call-single-keyserver-endpoint.js'; export type ActionTypes< STARTED_ACTION_TYPE: string, @@ -48,4 +53,21 @@ }); } +export type SingleKeyserverActionFunc = ( + callSingleKeyserverEndpoint: CallSingleKeyserverEndpoint, +) => F; + +export type CallKeyserverEndpoint = ( + endpoint: Endpoint, + requests: { +[keyserverID: string]: ?{ +[string]: mixed } }, + options?: ?CallSingleKeyserverEndpointOptions, +) => Promise<{ +[keyserverID: string]: any }>; +export type ActionFunc = ( + callSingleKeyserverEndpoint: CallKeyserverEndpoint, + // The second argument is only used in actions that call all keyservers, + // and the request to all keyservers are exactly the same. + // An example of such action is fetchEntries. + allKeyserverIDs: $ReadOnlyArray, +) => Args => Promise; + export { setNewSessionActionType, setNewSession }; 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 @@ -3,21 +3,17 @@ import invariant from 'invariant'; import * as React from 'react'; -import type { CallSingleKeyserverEndpoint } from './call-single-keyserver-endpoint.js'; import { useSelector, useDispatch } from './redux-utils.js'; import { ashoatKeyserverID } from './validation-utils.js'; import { type ServerCallSelectorParams, useCallKeyserverEndpointContext, } from '../keyserver-conn/call-keyserver-endpoint-provider.react.js'; +import type { SingleKeyserverActionFunc } from '../keyserver-conn/keyserver-conn-types.js'; import { serverCallStateSelector } from '../selectors/server-calls.js'; -type ActionFunc = ( - callSingleKeyserverEndpoint: CallSingleKeyserverEndpoint, -) => F; - function useLegacyAshoatKeyserverCall( - serverCall: ActionFunc, + serverCall: SingleKeyserverActionFunc, paramOverride?: ?Partial, ): F { const dispatch = useDispatch(); diff --git a/lib/utils/config.js b/lib/utils/config.js --- a/lib/utils/config.js +++ b/lib/utils/config.js @@ -3,8 +3,10 @@ import invariant from 'invariant'; import type { CallSingleKeyserverEndpoint } from './call-single-keyserver-endpoint.js'; -import type { CallKeyserverEndpoint } from './keyserver-call.js'; -import type { DispatchRecoveryAttempt } from '../keyserver-conn/keyserver-conn-types.js'; +import type { + DispatchRecoveryAttempt, + CallKeyserverEndpoint, +} from '../keyserver-conn/keyserver-conn-types.js'; import type { InitialNotifMessageOptions } from '../shared/crypto-utils.js'; import type { LogInActionSource } from '../types/account-types.js'; import type { PlatformDetails } from '../types/device-types.js'; 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 @@ -11,24 +11,11 @@ useKeyserverCallInfos, type KeyserverInfoPartial, } from '../keyserver-conn/keyserver-call-infos.js'; +import type { ActionFunc } from '../keyserver-conn/keyserver-conn-types.js'; import type { Endpoint } from '../types/endpoints.js'; import type { Dispatch } from '../types/redux-types.js'; import type { CurrentUserInfo } from '../types/user-types.js'; -export type CallKeyserverEndpoint = ( - endpoint: Endpoint, - requests: { +[keyserverID: string]: ?{ +[string]: mixed } }, - options?: ?CallSingleKeyserverEndpointOptions, -) => Promise<{ +[keyserverID: string]: any }>; - -type ActionFunc = ( - callSingleKeyserverEndpoint: CallKeyserverEndpoint, - // The second argument is only used in actions that call all keyservers, - // and the request to all keyservers are exactly the same. - // An example of such action is fetchEntries. - allKeyserverIDs: $ReadOnlyArray, -) => Args => Promise; - export type KeyserverCallParamOverride = Partial<{ +dispatch: Dispatch, +currentUserInfo: ?CurrentUserInfo, diff --git a/native/account/legacy-recover-keyserver-session.js b/native/account/legacy-recover-keyserver-session.js --- a/native/account/legacy-recover-keyserver-session.js +++ b/native/account/legacy-recover-keyserver-session.js @@ -1,11 +1,13 @@ // @flow import { logInActionTypes, logInRawAction } from 'lib/actions/user-actions.js'; -import type { DispatchRecoveryAttempt } from 'lib/keyserver-conn/keyserver-conn-types.js'; +import type { + DispatchRecoveryAttempt, + CallKeyserverEndpoint, +} from 'lib/keyserver-conn/keyserver-conn-types.js'; import type { InitialNotifMessageOptions } from 'lib/shared/crypto-utils.js'; import type { LogInActionSource } from 'lib/types/account-types.js'; import type { CallSingleKeyserverEndpoint } from 'lib/utils/call-single-keyserver-endpoint.js'; -import type { CallKeyserverEndpoint } from 'lib/utils/keyserver-call.js'; import { fetchNativeKeychainCredentials } from './native-credentials.js'; import { store } from '../redux/redux-setup.js'; diff --git a/web/redux/action-types.js b/web/redux/action-types.js --- a/web/redux/action-types.js +++ b/web/redux/action-types.js @@ -1,9 +1,9 @@ // @flow import { extractKeyserverIDFromID } from 'lib/keyserver-conn/keyserver-call-utils.js'; +import type { CallKeyserverEndpoint } from 'lib/keyserver-conn/keyserver-conn-types.js'; import { defaultCalendarFilters } from 'lib/types/filter-types.js'; import { useKeyserverCall } from 'lib/utils/keyserver-call.js'; -import type { CallKeyserverEndpoint } from 'lib/utils/keyserver-call.js'; import type { URLInfo } from 'lib/utils/url-utils.js'; import { ashoatKeyserverID } from 'lib/utils/validation-utils.js';