Skip to content

Commit

Permalink
[lib] action for calling fetch all communities with names endpoint
Browse files Browse the repository at this point in the history
Summary:
we'll dispatch this action to call fetch_all_communities_with_names on the authoritative keyserver

Depends on D13398

Test Plan:
dispatched action using useLegacyAshoatKeyserverCall. see gist: https://gist.github.com/vdhanan/df461cabc7a954ab1bc169104b98fbbb

saw success in redux and the correct payload

Reviewers: ashoat, tomek

Reviewed By: ashoat

Differential Revision: https://phab.comm.dev/D13399
  • Loading branch information
vdhanan committed Sep 24, 2024
1 parent 989db49 commit 021a1c8
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
15 changes: 15 additions & 0 deletions lib/actions/community-actions.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
// @flow

import type { CallSingleKeyserverEndpoint } from '../keyserver-conn/call-single-keyserver-endpoint.js';
import { extractKeyserverIDFromID } from '../keyserver-conn/keyserver-call-utils.js';
import { useKeyserverCall } from '../keyserver-conn/keyserver-call.js';
import type { CallKeyserverEndpoint } from '../keyserver-conn/keyserver-conn-types.js';
import type {
ServerCommunityInfo,
FetchCommunityInfosResponse,
FetchAllCommunityInfosWithNamesResponse,
CreateOrUpdateFarcasterChannelTagRequest,
CreateOrUpdateFarcasterChannelTagResponse,
DeleteFarcasterChannelTagRequest,
Expand Down Expand Up @@ -59,6 +61,17 @@ function useFetchCommunityInfos(): () => Promise<FetchCommunityInfosResponse> {
return useKeyserverCall(fetchCommunityInfos);
}

const fetchAllCommunityInfosWithNamesActionTypes = Object.freeze({
started: 'FETCH_ALL_COMMUNITY_INFOS_WITH_NAMES_STARTED',
success: 'FETCH_ALL_COMMUNITY_INFOS_WITH_NAMES_SUCCESS',
failed: 'FETCH_ALL_COMMUNITY_INFOS_WITH_NAMES_FAILED',
});
const fetchAllCommunityInfosWithNames =
(
callSingleKeyserverEndpoint: CallSingleKeyserverEndpoint,
): (() => Promise<FetchAllCommunityInfosWithNamesResponse>) =>
() =>
callSingleKeyserverEndpoint('fetch_all_community_infos_with_names');
const createOrUpdateFarcasterChannelTagActionTypes = Object.freeze({
started: 'CREATE_OR_UPDATE_FARCASTER_CHANNEL_TAG_STARTED',
success: 'CREATE_OR_UPDATE_FARCASTER_CHANNEL_TAG_SUCCESS',
Expand Down Expand Up @@ -143,6 +156,8 @@ export {
addCommunityActionType,
fetchCommunityInfosActionTypes,
useFetchCommunityInfos,
fetchAllCommunityInfosWithNamesActionTypes,
fetchAllCommunityInfosWithNames,
createOrUpdateFarcasterChannelTagActionTypes,
useCreateOrUpdateFarcasterChannelTag,
deleteFarcasterChannelTagActionTypes,
Expand Down
17 changes: 17 additions & 0 deletions lib/types/redux-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import type {
CommunityStore,
AddCommunityPayload,
FetchCommunityInfosResponse,
FetchAllCommunityInfosWithNamesResponse,
CreateOrUpdateFarcasterChannelTagResponse,
DeleteFarcasterChannelTagPayload,
} from './community-types.js';
Expand Down Expand Up @@ -1477,6 +1478,22 @@ export type BaseAction = $ReadOnly<{
+payload: Error,
+loadingInfo: LoadingInfo,
}
| {
+type: 'FETCH_ALL_COMMUNITY_INFOS_WITH_NAMES_STARTED',
+loadingInfo?: LoadingInfo,
+payload?: void,
}
| {
+type: 'FETCH_ALL_COMMUNITY_INFOS_WITH_NAMES_SUCCESS',
+payload: FetchAllCommunityInfosWithNamesResponse,
+loadingInfo: LoadingInfo,
}
| {
+type: 'FETCH_ALL_COMMUNITY_INFOS_WITH_NAMES_FAILED',
+error: true,
+payload: Error,
+loadingInfo: LoadingInfo,
}
| {
+type: 'CREATE_OR_UPDATE_FARCASTER_CHANNEL_TAG_STARTED',
+loadingInfo?: LoadingInfo,
Expand Down

0 comments on commit 021a1c8

Please sign in to comment.