mirror of
https://github.com/wassname/talk.git
synced 2026-07-27 11:28:12 +08:00
Fully working best tag
This commit is contained in:
@@ -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});
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user