Skip to content

Commit

Permalink
fix linting error
Browse files Browse the repository at this point in the history
  • Loading branch information
marcushaddon committed Jul 25, 2023
1 parent 9ed9b82 commit a3ea525
Show file tree
Hide file tree
Showing 4 changed files with 99 additions and 86 deletions.
160 changes: 83 additions & 77 deletions src/core/client/admin/components/BanUserMutation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,99 +16,105 @@ let clientMutationId = 0;

const BanUserMutation = createMutation(
"banUser",
(environment: Environment, input: MutationInput<MutationTypes>) => {
async (environment: Environment, input: MutationInput<MutationTypes>) => {
const viewer = getViewer(environment)!;
if (input.rejectExistingComments) {
commitLocalUpdate(environment, (store) => {
const record = store.get(input.userID);
return record?.setValue(true, "allCommentsRejected");
});
}

return commitMutationPromiseNormalized<MutationTypes>(environment, {
mutation: graphql`
mutation BanUserMutation($input: BanUserInput!) {
banUser(input: $input) {
user {
id
status {
current
warning {
active
}
premod {
active
}
suspension {
active
}
ban {
active
history {
const res = await commitMutationPromiseNormalized<MutationTypes>(
environment,
{
mutation: graphql`
mutation BanUserMutation($input: BanUserInput!) {
banUser(input: $input) {
user {
id
status {
current
warning {
active
}
premod {
active
}
suspension {
active
}
ban {
active
createdAt
createdBy {
history {
active
createdAt
createdBy {
id
username
}
}
sites {
id
username
}
}
sites {
id
}
}
}
clientMutationId
}
clientMutationId
}
}
`,
variables: {
input: {
...input,
clientMutationId: clientMutationId.toString(),
`,
variables: {
input: {
...input,
clientMutationId: clientMutationId.toString(),
},
},
},
optimisticResponse: {
banUser: {
user: {
id: input.userID,
status: {
current: lookup<GQLUser>(
environment,
input.userID
)!.status.current.concat(GQLUSER_STATUS.BANNED),
ban: {
active: true,
history: [
{
active: true,
createdAt: new Date().toISOString(),
createdBy: {
id: viewer.id,
username: viewer.username || null,
optimisticResponse: {
banUser: {
user: {
id: input.userID,
status: {
current: lookup<GQLUser>(
environment,
input.userID
)!.status.current.concat(GQLUSER_STATUS.BANNED),
ban: {
active: true,
history: [
{
active: true,
createdAt: new Date().toISOString(),
createdBy: {
id: viewer.id,
username: viewer.username || null,
},
},
},
],
sites:
input.siteIDs?.map((id) => {
return { id };
}) || [],
},
warning: {
active: false,
},
suspension: {
active: false,
},
premod: {
active: false,
],
sites:
input.siteIDs?.map((id) => {
return { id };
}) || [],
},
warning: {
active: false,
},
suspension: {
active: false,
},
premod: {
active: false,
},
},
},
clientMutationId: (clientMutationId++).toString(),
},
clientMutationId: (clientMutationId++).toString(),
},
},
});
}
);

if (input.rejectExistingComments) {
commitLocalUpdate(environment, (store) => {
const record = store.get(input.userID);
return record?.setValue(true, "allCommentsRejected");
});
}

return res;
}
);

Expand Down
20 changes: 12 additions & 8 deletions src/core/client/admin/components/UpdateUserBanMutation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,16 @@ let clientMutationId = 0;

const UpdateUserBanMutation = createMutation(
"updateUserBan",
(environment: Environment, input: MutationInput<QueryTypes>) => {
async (environment: Environment, input: MutationInput<QueryTypes>) => {
const {
userID,
banSiteIDs,
unbanSiteIDs,
message,
rejectExistingComments,
} = input;
if (input.rejectExistingComments) {
commitLocalUpdate(environment, (store) => {
const record = store.get(input.userID);
return record!.setValue(banSiteIDs, "commentsRejectedOnSites");
});
}
return commitMutationPromiseNormalized(environment, {

const res = await commitMutationPromiseNormalized(environment, {
mutation: graphql`
mutation UpdateUserBanMutation($input: UpdateUserBanInput!) {
updateUserBan(input: $input) {
Expand Down Expand Up @@ -56,6 +51,15 @@ const UpdateUserBanMutation = createMutation(
},
},
});

if (input.rejectExistingComments) {
commitLocalUpdate(environment, (store) => {
const record = store.get(input.userID);
return record!.setValue(banSiteIDs, "commentsRejectedOnSites");
});
}

return res;
}
);

Expand Down
2 changes: 1 addition & 1 deletion src/core/client/admin/routes/Moderate/Queue/Queue.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ interface Props {
site: { id: string };
author: {
allCommentsRejected: boolean | null;
commentsRejectedOnSites: string[] | null;
commentsRejectedOnSites: ReadonlyArray<string> | null;
} | null;
} & PropTypesOf<typeof ModerateCardContainer>["comment"]
>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ const enhanced = withRouteConfig<Props, SingleModerateRouteQueryResponse>({
query SingleModerateRouteQuery($commentID: ID!) {
comment(id: $commentID) {
id
site {
id
}
author {
commentsRejectedOnSites
allCommentsRejected
Expand Down

0 comments on commit a3ea525

Please sign in to comment.