chore: rename accept comment to approve comment (#2341)

This commit is contained in:
Kiwi
2019-06-06 18:58:11 +00:00
committed by Wyatt Johnson
parent 39d7540987
commit 8cfced464b
48 changed files with 253 additions and 253 deletions
@@ -0,0 +1,76 @@
import { graphql } from "react-relay";
import { ConnectionHandler, Environment } from "relay-runtime";
import { ApproveCommentMutation as MutationTypes } from "coral-admin/__generated__/ApproveCommentMutation.graphql";
import { getQueueConnection } from "coral-admin/helpers";
import {
commitMutationPromiseNormalized,
createMutation,
MutationInput,
} from "coral-framework/lib/relay";
let clientMutationId = 0;
const ApproveCommentMutation = createMutation(
"approveComment",
(
environment: Environment,
input: MutationInput<MutationTypes> & { storyID?: string }
) =>
commitMutationPromiseNormalized<MutationTypes>(environment, {
mutation: graphql`
mutation ApproveCommentMutation(
$input: ApproveCommentInput!
$storyID: ID
) {
approveComment(input: $input) {
comment {
id
status
}
moderationQueues(storyID: $storyID) {
unmoderated {
count
}
reported {
count
}
pending {
count
}
}
clientMutationId
}
}
`,
variables: {
input: {
commentID: input.commentID,
commentRevisionID: input.commentRevisionID,
clientMutationId: clientMutationId.toString(),
},
},
optimisticResponse: {
approveComment: {
comment: {
id: input.commentID,
status: "APPROVED",
},
clientMutationId: (clientMutationId++).toString(),
},
},
updater: store => {
const connections = [
getQueueConnection(store, "reported", input.storyID),
getQueueConnection(store, "pending", input.storyID),
getQueueConnection(store, "unmoderated", input.storyID),
getQueueConnection(store, "rejected", input.storyID),
].filter(c => c);
connections.forEach(con =>
ConnectionHandler.deleteNode(con, input.commentID)
);
},
})
);
export default ApproveCommentMutation;