Page MenuHomePhorge

D11996.1768532696.diff
No OneTemporary

Size
3 KB
Referenced Files
None
Subscribers
None

D11996.1768532696.diff

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

Mime Type
text/plain
Expires
Fri, Jan 16, 3:04 AM (14 h, 37 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5941543
Default Alt Text
D11996.1768532696.diff (3 KB)

Event Timeline