Skip to content

Commit

Permalink
fix: Remove unneeded memberships functions
Browse files Browse the repository at this point in the history
  • Loading branch information
David Code Howard committed Sep 25, 2023
1 parent 0a80d68 commit 4abe6b8
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 21 deletions.
17 changes: 0 additions & 17 deletions src/project/projectService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,23 +76,6 @@ const collapseProjectFields = collapseFields<
(x, y) => ({ ...x, [y.id]: collapseSiteFields(y) }),
{} as Record<string, Site>,
),
memberships: inp =>
inp.membershipList.memberships?.edges
.map(({ node: { id, userRole, user } }) => ({
membershipId: id,
userId: user?.id,
userRole,
}))
.reduce(
(x, y) => {
if (y.userId !== undefined) {
let userId = y.userId;
return { ...x, [y.membershipId]: { ...y, userId } };
}
return x;
},
{} as Record<string, ProjectMembership>,
) || {},
users: inp =>
inp.membershipList.memberships?.edges
.map(({ node: { user } }) => {
Expand Down
5 changes: 1 addition & 4 deletions src/project/projectSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import { createAction, createSlice } from '@reduxjs/toolkit';
import { setUsers, User } from 'terraso-client-shared/account/accountSlice';
import { UserRole } from 'terraso-client-shared/graphqlSchema/graphql';
import { setMembers } from 'terraso-client-shared/memberships/membershipsSlice';
import * as projectService from 'terraso-client-shared/project/projectService';
import { setSites, Site } from 'terraso-client-shared/site/siteSlice';
import {
Expand All @@ -30,7 +29,6 @@ const { plural: dehydrateProjects, sing: dehydrateProject } = dehydrated<
Project,
HydratedProject
>({
memberships: setMembers,
users: setUsers,
sites: setSites,
});
Expand All @@ -55,7 +53,6 @@ export type Project = {

export type HydratedProject = {
dehydrated: Project;
memberships: Record<string, ProjectMembership>;
users: Record<string, User>;
sites: Record<string, Site>;
};
Expand Down Expand Up @@ -139,7 +136,7 @@ const projectSlice = createSlice({
builder.addCase(
removeMembershipFromProject,
(state, { payload: { membershipId, projectId } }) => {
delete state.projects[projectId].membershipIds[membershipId];
delete state.projects[projectId].memberships[membershipId];
},
);

Expand Down

0 comments on commit 4abe6b8

Please sign in to comment.