Fully working best tag

This commit is contained in:
Belen Curcio
2017-05-18 00:21:08 -03:00
parent b795368674
commit 17e7b28688
2 changed files with 9 additions and 10 deletions
+9 -6
View File
@@ -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});
-4
View File
@@ -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);