mirror of
https://github.com/wassname/talk.git
synced 2026-06-29 21:27:02 +08:00
fix: restore ReportCommentEvent (#3037)
Co-authored-by: Wyatt Johnson <wyattjoh@gmail.com>
This commit is contained in:
+44
-23
@@ -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;
|
||||
|
||||
+45
-22
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user