fix: restore ReportCommentEvent (#3037)

Co-authored-by: Wyatt Johnson <wyattjoh@gmail.com>
This commit is contained in:
Vinh
2020-07-24 18:48:02 +02:00
committed by GitHub
parent 25a1dcdf8d
commit 87d32680f0
2 changed files with 89 additions and 45 deletions
@@ -6,6 +6,7 @@ import {
createMutation,
MutationInput,
} from "coral-framework/lib/relay";
import { ReportCommentEvent } from "coral-stream/events";
import { CreateCommentDisagreeMutation as MutationTypes } from "coral-stream/__generated__/CreateCommentDisagreeMutation.graphql";
@@ -13,32 +14,52 @@ let clientMutationId = 0;
const CreateCommentDisagreeMutation = createMutation(
"createCommentDisagree",
(environment: Environment, input: MutationInput<MutationTypes>) =>
commitMutationPromiseNormalized<MutationTypes>(environment, {
mutation: graphql`
mutation CreateCommentDisagreeMutation(
$input: CreateCommentDontAgreeInput!
) {
createCommentDontAgree(input: $input) {
comment {
id
viewerActionPresence {
dontAgree
(
environment: Environment,
input: MutationInput<MutationTypes>,
{ eventEmitter }
) => {
const reportCommentEvent = ReportCommentEvent.begin(eventEmitter, {
reason: "DONT_AGREE",
additionalDetails: input.additionalDetails || undefined,
commentID: input.commentID,
});
try {
const result = commitMutationPromiseNormalized<MutationTypes>(
environment,
{
mutation: graphql`
mutation CreateCommentDisagreeMutation(
$input: CreateCommentDontAgreeInput!
) {
createCommentDontAgree(input: $input) {
comment {
id
viewerActionPresence {
dontAgree
}
}
clientMutationId
}
}
clientMutationId
}
`,
variables: {
input: {
commentID: input.commentID,
commentRevisionID: input.commentRevisionID,
additionalDetails: input.additionalDetails,
clientMutationId: (clientMutationId++).toString(),
},
},
}
`,
variables: {
input: {
commentID: input.commentID,
commentRevisionID: input.commentRevisionID,
additionalDetails: input.additionalDetails,
clientMutationId: (clientMutationId++).toString(),
},
},
})
);
reportCommentEvent.success();
return result;
} catch (error) {
reportCommentEvent.error({ message: error.message, code: error.code });
throw error;
}
}
);
export default CreateCommentDisagreeMutation;
@@ -6,6 +6,7 @@ import {
createMutation,
MutationInput,
} from "coral-framework/lib/relay";
import { ReportCommentEvent } from "coral-stream/events";
import { CreateCommentFlagMutation as MutationTypes } from "coral-stream/__generated__/CreateCommentFlagMutation.graphql";
@@ -13,31 +14,53 @@ let clientMutationId = 0;
const CreateCommentFlagMutation = createMutation(
"createCommentFlag",
(environment: Environment, input: MutationInput<MutationTypes>) =>
commitMutationPromiseNormalized<MutationTypes>(environment, {
mutation: graphql`
mutation CreateCommentFlagMutation($input: CreateCommentFlagInput!) {
createCommentFlag(input: $input) {
comment {
id
viewerActionPresence {
flag
(
environment: Environment,
input: MutationInput<MutationTypes>,
{ eventEmitter }
) => {
const reportCommentEvent = ReportCommentEvent.begin(eventEmitter, {
reason: input.reason,
commentID: input.commentID,
additionalDetails: input.additionalDetails || undefined,
});
try {
const result = commitMutationPromiseNormalized<MutationTypes>(
environment,
{
mutation: graphql`
mutation CreateCommentFlagMutation(
$input: CreateCommentFlagInput!
) {
createCommentFlag(input: $input) {
comment {
id
viewerActionPresence {
flag
}
}
clientMutationId
}
}
clientMutationId
}
`,
variables: {
input: {
commentID: input.commentID,
commentRevisionID: input.commentRevisionID,
reason: input.reason,
additionalDetails: input.additionalDetails,
clientMutationId: (clientMutationId++).toString(),
},
},
}
`,
variables: {
input: {
commentID: input.commentID,
commentRevisionID: input.commentRevisionID,
reason: input.reason,
additionalDetails: input.additionalDetails,
clientMutationId: (clientMutationId++).toString(),
},
},
})
);
reportCommentEvent.success();
return result;
} catch (error) {
reportCommentEvent.error({ message: error.message, code: error.code });
throw error;
}
}
);
export default CreateCommentFlagMutation;