mirror of
https://github.com/wassname/talk.git
synced 2026-09-09 11:38:08 +08:00
Merge branch 'master' into prop-types
This commit is contained in:
@@ -109,7 +109,7 @@ export default {
|
||||
},
|
||||
mutations: {
|
||||
PostComment: ({
|
||||
variables: {comment: {asset_id, body, parent_id, tags = []}},
|
||||
variables: {input: {asset_id, body, parent_id, tags = []}},
|
||||
state: {auth},
|
||||
}) => ({
|
||||
optimisticResponse: {
|
||||
|
||||
@@ -6,6 +6,7 @@ export default {
|
||||
'SetCommentStatusResponse',
|
||||
'SuspendUserResponse',
|
||||
'RejectUsernameResponse',
|
||||
'CreateCommentResponse',
|
||||
'SetUserStatusResponse',
|
||||
'CreateFlagResponse',
|
||||
'EditCommentResponse',
|
||||
|
||||
@@ -192,17 +192,17 @@ export const withSetUserStatus = withMutation(
|
||||
|
||||
export const withPostComment = withMutation(
|
||||
gql`
|
||||
mutation PostComment($comment: CreateCommentInput!) {
|
||||
createComment(comment: $comment) {
|
||||
mutation PostComment($input: CreateCommentInput!) {
|
||||
createComment(input: $input) {
|
||||
...CreateCommentResponse
|
||||
}
|
||||
}
|
||||
`, {
|
||||
props: ({mutate}) => ({
|
||||
postComment: (comment) => {
|
||||
postComment: (input) => {
|
||||
return mutate({
|
||||
variables: {
|
||||
comment
|
||||
input
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
@@ -109,7 +109,7 @@ export function mergeDocuments(documents) {
|
||||
export function getResponseErrors(mutationResult) {
|
||||
const result = [];
|
||||
Object.keys(mutationResult.data).forEach((response) => {
|
||||
const errors = mutationResult.data[response].errors;
|
||||
const errors = mutationResult.data[response] && mutationResult.data[response].errors;
|
||||
if (errors && errors.length) {
|
||||
result.push(...errors);
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ class CommentBox extends React.Component {
|
||||
return;
|
||||
}
|
||||
|
||||
let comment = {
|
||||
let input = {
|
||||
asset_id: assetId,
|
||||
parent_id: parentId,
|
||||
body: this.state.body,
|
||||
@@ -63,10 +63,10 @@ class CommentBox extends React.Component {
|
||||
};
|
||||
|
||||
// Execute preSubmit Hooks
|
||||
this.state.hooks.preSubmit.forEach((hook) => hook());
|
||||
this.state.hooks.preSubmit.forEach((hook) => hook(input));
|
||||
this.setState({loadingState: 'loading'});
|
||||
|
||||
postComment(comment, 'comments')
|
||||
postComment(input, 'comments')
|
||||
.then(({data}) => {
|
||||
this.setState({loadingState: 'success', body: ''});
|
||||
const postedComment = data.createComment.comment;
|
||||
|
||||
Reference in New Issue
Block a user