Page MenuHomePhabricator

D12027.id40150.diff
No OneTemporary

D12027.id40150.diff

diff --git a/lib/reducers/community-reducer.js b/lib/reducers/community-reducer.js
--- a/lib/reducers/community-reducer.js
+++ b/lib/reducers/community-reducer.js
@@ -1,13 +1,21 @@
// @flow
import { setClientDBStoreActionType } from '../actions/client-db-store-actions.js';
-import { addCommunityActionType } from '../actions/community-actions.js';
+import {
+ addCommunityActionType,
+ fetchCommunityInfosActionTypes,
+ createOrUpdateFarcasterChannelTagActionTypes,
+ deleteFarcasterChannelTagActionTypes,
+} from '../actions/community-actions.js';
import {
communityStoreOpsHandlers,
type CommunityStoreOperation,
type ReplaceCommunityOperation,
} from '../ops/community-store-ops.js';
-import type { CommunityStore } from '../types/community-types.js';
+import type {
+ CommunityStore,
+ CommunityInfo,
+} from '../types/community-types.js';
import type { BaseAction } from '../types/redux-types';
const { processStoreOperations: processStoreOps } = communityStoreOpsHandlers;
@@ -19,7 +27,65 @@
+communityStore: CommunityStore,
+communityStoreOperations: $ReadOnlyArray<CommunityStoreOperation>,
} {
- if (action.type === addCommunityActionType) {
+ if (action.type === fetchCommunityInfosActionTypes.success) {
+ const replaceOperations = action.payload.communityInfos.map(community => {
+ const { id, ...rest } = community;
+ const communityInfo: CommunityInfo = {
+ ...rest,
+ };
+
+ return {
+ type: 'replace_community',
+ payload: {
+ id,
+ communityInfo,
+ },
+ };
+ });
+
+ return {
+ communityStore: processStoreOps(state, replaceOperations),
+ communityStoreOperations: replaceOperations,
+ };
+ } else if (
+ action.type === createOrUpdateFarcasterChannelTagActionTypes.success
+ ) {
+ const communityID = action.payload.commCommunityID;
+
+ const replaceOperation: ReplaceCommunityOperation = {
+ type: 'replace_community',
+ payload: {
+ id: communityID,
+ communityInfo: {
+ ...state.communityInfos[communityID],
+ farcasterChannelID: action.payload.farcasterChannelID,
+ },
+ },
+ };
+
+ return {
+ communityStore: processStoreOps(state, [replaceOperation]),
+ communityStoreOperations: [replaceOperation],
+ };
+ } else if (action.type === deleteFarcasterChannelTagActionTypes.success) {
+ const communityID = action.payload.commCommunityID;
+
+ const replaceOperation: ReplaceCommunityOperation = {
+ type: 'replace_community',
+ payload: {
+ id: communityID,
+ communityInfo: {
+ ...state.communityInfos[communityID],
+ farcasterChannelID: null,
+ },
+ },
+ };
+
+ return {
+ communityStore: processStoreOps(state, [replaceOperation]),
+ communityStoreOperations: [replaceOperation],
+ };
+ } else if (action.type === addCommunityActionType) {
const replaceOperation: ReplaceCommunityOperation = {
type: 'replace_community',
payload: {

File Metadata

Mime Type
text/plain
Expires
Sun, Nov 24, 1:18 AM (18 h, 45 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2573390
Default Alt Text
D12027.id40150.diff (2 KB)

Event Timeline