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 type { + FetchInviteLinksResponse, InviteLinkVerificationRequest, InviteLinkVerificationResponse, } from '../types/link-types.js'; @@ -30,4 +31,25 @@ }; }; -export { verifyInviteLinkActionTypes, verifyInviteLink }; +const fetchPrimaryInviteLinkActionTypes = Object.freeze({ + started: 'FETCH_PRIMARY_INVITE_LINKS_STARTED', + success: 'FETCH_PRIMARY_INVITE_LINKS_SUCCESS', + failed: 'FETCH_PRIMARY_INVITE_LINKS_FAILED', +}); +const fetchPrimaryInviteLinks = + ( + callServerEndpoint: CallServerEndpoint, + ): (() => Promise) => + async () => { + const response = await callServerEndpoint('fetch_primary_invite_links'); + return { + links: response.links, + }; + }; + +export { + verifyInviteLinkActionTypes, + verifyInviteLink, + fetchPrimaryInviteLinkActionTypes, + fetchPrimaryInviteLinks, +}; diff --git a/lib/types/redux-types.js b/lib/types/redux-types.js --- a/lib/types/redux-types.js +++ b/lib/types/redux-types.js @@ -36,7 +36,10 @@ SetCalendarDeletedFilterPayload, } from './filter-types.js'; import type { LifecycleState } from './lifecycle-state-types.js'; -import type { InviteLinkVerificationResponse } from './link-types.js'; +import type { + FetchInviteLinksResponse, + InviteLinkVerificationResponse, +} from './link-types.js'; import type { LoadingStatus, LoadingInfo } from './loading-types.js'; import type { UpdateMultimediaMessageMediaPayload } from './media-types.js'; import type { MessageReportCreationResult } from './message-report-types.js'; @@ -1008,6 +1011,22 @@ +error: true, +payload: Error, +loadingInfo: LoadingInfo, + } + | { + +type: 'FETCH_PRIMARY_INVITE_LINKS_STARTED', + +loadingInfo?: LoadingInfo, + +payload?: void, + } + | { + +type: 'FETCH_PRIMARY_INVITE_LINKS_SUCCESS', + +payload: FetchInviteLinksResponse, + +loadingInfo: LoadingInfo, + } + | { + +type: 'FETCH_PRIMARY_INVITE_LINKS_FAILED', + +error: true, + +payload: Error, + +loadingInfo: LoadingInfo, }; export type ActionPayload = ?(Object | Array<*> | $ReadOnlyArray<*> | string);