Port DeleteAction Mutation

This commit is contained in:
Chi Vinh Le
2017-05-09 01:15:07 +07:00
parent 83ef41000c
commit 0e931d023d
4 changed files with 29 additions and 20 deletions
@@ -6,7 +6,10 @@ import uniqBy from 'lodash/uniqBy';
import sortBy from 'lodash/sortBy';
import isNil from 'lodash/isNil';
import {NEW_COMMENT_COUNT_POLL_INTERVAL} from '../constants/stream';
import {withPostComment, withPostFlag, withPostDontAgree, deleteAction, addCommentTag, removeCommentTag, ignoreUser} from 'coral-framework/graphql/mutations';
import {
withPostComment, withPostFlag, withPostDontAgree, withDeleteAction,
addCommentTag, removeCommentTag, ignoreUser,
} from 'coral-framework/graphql/mutations';
import {notificationActions, authActions} from 'coral-framework';
import {editName} from 'coral-framework/actions/user';
import {setCommentCountCache, setActiveReplyBox} from '../actions/stream';
@@ -242,6 +245,6 @@ export default compose(
addCommentTag,
removeCommentTag,
ignoreUser,
deleteAction,
withDeleteAction,
)(StreamContainer);
@@ -3,6 +3,13 @@ import {registerConfig} from 'coral-framework/services/registry';
const config = {
fragments: {
DeleteActionResponse: gql`
fragment CoralEmbedStream_DeleteActionResponse on DeleteActionResponse {
errors {
translation_key
}
}
`,
CreateFlagResponse: gql`
fragment CoralEmbedStream_CreateFlagResponse on CreateFlagResponse {
flag {
@@ -1,7 +0,0 @@
mutation deleteAction ($id: ID!) {
deleteAction(id:$id) {
errors {
translation_key
}
}
}
@@ -1,5 +1,4 @@
import {graphql, gql} from 'react-apollo';
import DELETE_ACTION from './deleteAction.graphql';
import ADD_COMMENT_TAG from './addCommentTag.graphql';
import REMOVE_COMMENT_TAG from './removeCommentTag.graphql';
import IGNORE_USER from './ignoreUser.graphql';
@@ -61,16 +60,23 @@ export const withPostDontAgree = withMutation(
}}),
});
export const deleteAction = graphql(DELETE_ACTION, {
props: ({mutate}) => ({
deleteAction: (id) => {
return mutate({
variables: {
id
}
});
}}),
});
export const withDeleteAction = withMutation(
gql`
mutation DeleteAction($id: ID!) {
deleteAction(id:$id) {
...DeleteActionResponse
}
}
`, {
props: ({mutate}) => ({
deleteAction: (id) => {
return mutate({
variables: {
id
}
});
}}),
});
export const addCommentTag = graphql(ADD_COMMENT_TAG, {
props: ({mutate}) => ({