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 @@ -7,10 +7,13 @@ const addCommunityActionType = 'ADD_COMMUNITY'; +const removeCommunityActionType = 'REMOVE_COMMUNITY'; + export { updateCalendarCommunityFilter, clearCalendarCommunityFilter, updateChatCommunityFilter, clearChatCommunityFilter, addCommunityActionType, + removeCommunityActionType, }; 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,7 +1,10 @@ // @flow import { setClientDBStoreActionType } from '../actions/client-db-store-actions.js'; -import { addCommunityActionType } from '../actions/community-actions.js'; +import { + addCommunityActionType, + removeCommunityActionType, +} from '../actions/community-actions.js'; import { siweAuthActionTypes } from '../actions/siwe-actions.js'; import { logInActionTypes, @@ -11,6 +14,7 @@ communityStoreOpsHandlers, type CommunityStoreOperation, type ReplaceCommunityOperation, + type RemoveCommunitiesOperation, type RemoveAllCommunitiesOperation, } from '../ops/community-store-ops.js'; import type { @@ -82,6 +86,18 @@ communityStore: processStoreOps(state, [replaceOperation]), communityStoreOperations: [replaceOperation], }; + } else if (action.type === removeCommunityActionType) { + const removeOperation: RemoveCommunitiesOperation = { + type: 'remove_communities', + payload: { + ids: [action.payload.id], + }, + }; + + return { + communityStore: processStoreOps(state, [removeOperation]), + communityStoreOperations: [removeOperation], + }; } else if (action.type === setClientDBStoreActionType) { const newCommunityInfo = action.payload.communityInfos; diff --git a/lib/types/community-types.js b/lib/types/community-types.js --- a/lib/types/community-types.js +++ b/lib/types/community-types.js @@ -16,3 +16,7 @@ +id: string, +newCommunityInfo: CommunityInfo, }; + +export type RemoveCommunityPayload = { + +id: string, +}; 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 @@ -19,7 +19,11 @@ UpdateUserAvatarRequest, UpdateUserAvatarResponse, } from './avatar-types.js'; -import type { CommunityStore, AddCommunityPayload } from './community-types.js'; +import type { + CommunityStore, + AddCommunityPayload, + RemoveCommunityPayload, +} from './community-types.js'; import type { CryptoStore } from './crypto-types.js'; import type { GetVersionActionPayload, @@ -1364,6 +1368,10 @@ | { +type: 'ADD_COMMUNITY', +payload: AddCommunityPayload, + } + | { + +type: 'REMOVE_COMMUNITY', + +payload: RemoveCommunityPayload, }; export type ActionPayload = ?(Object | Array<*> | $ReadOnlyArray<*> | string);