Changeset View
Changeset View
Standalone View
Standalone View
lib/actions/link-actions.js
// @flow | // @flow | ||||
import type { | import type { | ||||
FetchInviteLinksResponse, | |||||
InviteLinkVerificationRequest, | InviteLinkVerificationRequest, | ||||
InviteLinkVerificationResponse, | InviteLinkVerificationResponse, | ||||
} from '../types/link-types.js'; | } from '../types/link-types.js'; | ||||
import type { CallServerEndpoint } from '../utils/call-server-endpoint.js'; | import type { CallServerEndpoint } from '../utils/call-server-endpoint.js'; | ||||
const verifyInviteLinkActionTypes = Object.freeze({ | const verifyInviteLinkActionTypes = Object.freeze({ | ||||
started: 'VERIFY_INVITE_LINK_STARTED', | started: 'VERIFY_INVITE_LINK_STARTED', | ||||
success: 'VERIFY_INVITE_LINK_SUCCESS', | success: 'VERIFY_INVITE_LINK_SUCCESS', | ||||
Show All 13 Lines | if (response.status === 'valid' || response.status === 'already_joined') { | ||||
community: response.community, | community: response.community, | ||||
}; | }; | ||||
} | } | ||||
return { | return { | ||||
status: response.status, | status: response.status, | ||||
}; | }; | ||||
}; | }; | ||||
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<FetchInviteLinksResponse>) => | |||||
async () => { | |||||
const response = await callServerEndpoint('fetch_primary_invite_links'); | |||||
return { | |||||
links: response.links, | |||||
}; | |||||
}; | |||||
export { | |||||
verifyInviteLinkActionTypes, | |||||
verifyInviteLink, | |||||
fetchPrimaryInviteLinkActionTypes, | |||||
fetchPrimaryInviteLinks, | |||||
}; |