diff --git a/client/coral-framework/graphql/mutations.js b/client/coral-framework/graphql/mutations.js index ab7f4ae78..cf57688ee 100644 --- a/client/coral-framework/graphql/mutations.js +++ b/client/coral-framework/graphql/mutations.js @@ -95,8 +95,8 @@ export const withDeleteAction = withMutation( }}), }); - const COMMENT_FRAGMENT = gql` - fragment CoralRespect_UpdateFragment on Comment { +const COMMENT_FRAGMENT = gql` + fragment CoraBest_UpdateFragment on Comment { tags { tag { name @@ -135,9 +135,10 @@ export const withAddTag = withMutation( data.tags.push({ tag: { - __typename: 'TagLink', - name - } + __typename: 'Tag', + name: "BEST" + }, + __typename: 'TagLink' }); // Write our data back to the cache. @@ -171,7 +172,9 @@ export const withRemoveTag = withMutation( // Read the data from our cache for this query. const data = proxy.readFragment({fragment: COMMENT_FRAGMENT, id: fragmentId}); - console.log('remove', data); + const idx = data.tags.findIndex(i => i.tag.name === 'BEST'); + + data.tags = [...data.tags.slice(0, idx), ...data.tags.slice(idx + 1)]; // Write our data back to the cache. proxy.writeFragment({fragment: COMMENT_FRAGMENT, id: fragmentId, data}); diff --git a/client/coral-plugin-best/BestButton.js b/client/coral-plugin-best/BestButton.js index acc971a05..8a17cfdf8 100644 --- a/client/coral-plugin-best/BestButton.js +++ b/client/coral-plugin-best/BestButton.js @@ -6,12 +6,8 @@ import classnames from 'classnames'; // tag string for best comments export const BEST_TAG = 'BEST'; -<<<<<<< HEAD -export const commentIsBest = ({tags} = {}) => tags.some(t => t.tag.name === BEST_TAG); -======= export const commentIsBest = ({tags} = {}) => tags.some((t) => t.tag.name === BEST_TAG); ->>>>>>> 7a256bdd2b62c5bdf6f20df76baa910ab0b44166 const name = 'coral-plugin-best'; const lang = new I18n(translations);