Port IgnoreUser mutation

This commit is contained in:
Chi Vinh Le
2017-05-09 02:46:42 +07:00
parent 7077300dbc
commit 5c44922d2b
4 changed files with 33 additions and 24 deletions
@@ -8,7 +8,7 @@ import isNil from 'lodash/isNil';
import {NEW_COMMENT_COUNT_POLL_INTERVAL} from '../constants/stream';
import {
withPostComment, withPostFlag, withPostDontAgree, withDeleteAction,
withAddCommentTag, withRemoveCommentTag, ignoreUser,
withAddCommentTag, withRemoveCommentTag, withIgnoreUser,
} from 'coral-framework/graphql/mutations';
import {notificationActions, authActions} from 'coral-framework';
import {editName} from 'coral-framework/actions/user';
@@ -244,7 +244,7 @@ export default compose(
withPostDontAgree,
withAddCommentTag,
withRemoveCommentTag,
ignoreUser,
withIgnoreUser,
withDeleteAction,
)(StreamContainer);
@@ -3,6 +3,13 @@ import {registerConfig} from 'coral-framework/services/registry';
const config = {
fragments: {
IgnoreUserResponse: gql`
fragment CoralEmbedStream_IgnoreUserResponse on IgnoreUserResponse {
errors {
translation_key
}
}
`,
RemoveCommentTagResponse: gql`
fragment CoralEmbedStream_RemoveCommentTagResponse on RemoveCommentTagResponse {
comment {
@@ -93,6 +100,13 @@ const config = {
`,
},
mutations: {
IgnoreUser: () => ({
// TODO: don't rely on refetching.
refetchQueries: [
'EmbedQuery', 'myIgnoredUsers',
],
}),
PostComment: ({
variables: {comment: {asset_id, body, parent_id, tags = []}},
state: {auth},
@@ -1,7 +0,0 @@
mutation ignoreUser ($id: ID!) {
ignoreUser(id:$id) {
errors {
translation_key
}
}
}
@@ -1,5 +1,4 @@
import {graphql, gql} from 'react-apollo';
import IGNORE_USER from './ignoreUser.graphql';
import STOP_IGNORING_USER from './stopIgnoringUser.graphql';
import withMutation from '../../hocs/withMutation';
@@ -114,20 +113,23 @@ export const withRemoveCommentTag = withMutation(
}}),
});
// TODO: don't rely on refetching.
export const ignoreUser = graphql(IGNORE_USER, {
props: ({mutate}) => ({
ignoreUser: ({id}) => {
return mutate({
variables: {
id,
},
refetchQueries: [
'EmbedQuery', 'myIgnoredUsers',
]
});
}}),
});
export const withIgnoreUser = withMutation(
gql`
mutation IgnoreUser($id: ID!) {
ignoreUser(id:$id) {
...IgnoreUserResponse
}
}
`, {
props: ({mutate}) => ({
ignoreUser: ({id}) => {
return mutate({
variables: {
id,
},
});
}}),
});
// TODO: don't rely on refetching.
export const stopIgnoringUser = graphql(STOP_IGNORING_USER, {