Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F33200824
D11996.1768544283.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
3 KB
Referenced Files
None
Subscribers
None
D11996.1768544283.diff
View Options
diff --git a/lib/actions/community-actions.js b/lib/actions/community-actions.js
--- a/lib/actions/community-actions.js
+++ b/lib/actions/community-actions.js
@@ -4,6 +4,8 @@
import { useKeyserverCall } from '../keyserver-conn/keyserver-call.js';
import type { CallKeyserverEndpoint } from '../keyserver-conn/keyserver-conn-types.js';
import type {
+ ServerCommunityInfo,
+ FetchCommunityInfosResponse,
CreateOrUpdateFarcasterChannelTagRequest,
CreateOrUpdateFarcasterChannelTagResponse,
DeleteFarcasterChannelTagRequest,
@@ -17,6 +19,46 @@
const addCommunityActionType = 'ADD_COMMUNITY';
+const fetchCommunityInfosActionTypes = Object.freeze({
+ started: 'FETCH_COMMUNITY_INFOS_STARTED',
+ success: 'FETCH_COMMUNITY_INFOS_SUCCESS',
+ failed: 'FETCH_COMMUNITY_INFOS_FAILED',
+});
+
+const fetchCommunityInfos =
+ (
+ callKeyserverEndpoint: CallKeyserverEndpoint,
+ allKeyserverIDs: $ReadOnlyArray<string>,
+ ): (() => Promise<FetchCommunityInfosResponse>) =>
+ async () => {
+ const requests: { [string]: void } = {};
+
+ for (const keyserverID of allKeyserverIDs) {
+ requests[keyserverID] = undefined;
+ }
+
+ const responses = await callKeyserverEndpoint(
+ 'fetch_community_infos',
+ requests,
+ );
+
+ let communityInfos: $ReadOnlyArray<ServerCommunityInfo> = [];
+
+ for (const keyserverID in responses) {
+ communityInfos = communityInfos.concat(
+ responses[keyserverID].communityInfos,
+ );
+ }
+
+ return {
+ communityInfos,
+ };
+ };
+
+function useFetchCommunityInfos(): () => Promise<FetchCommunityInfosResponse> {
+ return useKeyserverCall(fetchCommunityInfos);
+}
+
const createOrUpdateFarcasterChannelTagActionTypes = Object.freeze({
started: 'CREATE_OR_UPDATE_FARCASTER_CHANNEL_TAG_STARTED',
success: 'CREATE_OR_UPDATE_FARCASTER_CHANNEL_TAG_SUCCESS',
@@ -99,6 +141,8 @@
updateChatCommunityFilter,
clearChatCommunityFilter,
addCommunityActionType,
+ fetchCommunityInfosActionTypes,
+ useFetchCommunityInfos,
createOrUpdateFarcasterChannelTagActionTypes,
useCreateOrUpdateFarcasterChannelTag,
deleteFarcasterChannelTagActionTypes,
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
@@ -31,6 +31,7 @@
import type {
CommunityStore,
AddCommunityPayload,
+ FetchCommunityInfosResponse,
CreateOrUpdateFarcasterChannelTagResponse,
DeleteFarcasterChannelTagPayload,
} from './community-types.js';
@@ -1415,6 +1416,22 @@
+type: 'OPS_PROCESSING_FINISHED_ACTION_TYPE',
+payload?: void,
}
+ | {
+ +type: 'FETCH_COMMUNITY_INFOS_STARTED',
+ +loadingInfo?: LoadingInfo,
+ +payload?: void,
+ }
+ | {
+ +type: 'FETCH_COMMUNITY_INFOS_SUCCESS',
+ +payload: FetchCommunityInfosResponse,
+ +loadingInfo: LoadingInfo,
+ }
+ | {
+ +type: 'FETCH_COMMUNITY_INFOS_FAILED',
+ +error: true,
+ +payload: Error,
+ +loadingInfo: LoadingInfo,
+ }
| {
+type: 'CREATE_OR_UPDATE_FARCASTER_CHANNEL_TAG_STARTED',
+loadingInfo?: LoadingInfo,
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Jan 16, 6:18 AM (11 h, 40 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5941543
Default Alt Text
D11996.1768544283.diff (3 KB)
Attached To
Mode
D11996: [lib] introduce fetch community infos redux action
Attached
Detach File
Event Timeline
Log In to Comment