Handle ignore user

This commit is contained in:
Chi Vinh Le
2017-07-18 16:39:06 +07:00
parent 8c7c564a30
commit 043d5fdcec
3 changed files with 47 additions and 26 deletions
@@ -6,7 +6,7 @@ const enhance = compose(
withFragments({
asset: gql`
fragment TalkFeatured_Tab_asset on Asset {
featuredCommentsCount: totalCommentCount(tags: ["FEATURED"])
featuredCommentsCount: totalCommentCount(tags: ["FEATURED"], excludeIgnored: $excludeIgnored)
}`,
}),
);
@@ -16,31 +16,31 @@ const enhance = compose(
asset: gql`
fragment TalkFeatured_TabPane_asset on Asset {
id
featuredComments: comments(tags: ["FEATURED"], deep: true) {
nodes {
id
body
created_at
replyCount
tags {
tag {
name
}
}
action_summaries {
... on LikeActionSummary {
count
current_user {
id
}
}
}
user {
id
username
}
featuredComments: comments(tags: ["FEATURED"], excludeIgnored: $excludeIgnored, deep: true) {
nodes {
id
body
created_at
replyCount
tags {
tag {
name
}
}
action_summaries {
... on LikeActionSummary {
count
current_user {
id
}
}
}
user {
id
username
}
}
}
}`,
}),
);
@@ -16,10 +16,31 @@ export default {
commentReactions: [FeaturedButton]
},
mutations: {
IgnoreUser: ({variables}) => ({
updateQueries: {
CoralEmbedStream_Embed: (previous) => {
const ignoredUserId = variables.id;
const updated = update(previous, {
asset: {
featuredComments: {
nodes: {
$apply: (nodes) =>
nodes.filter((n) => n.user.id !== ignoredUserId)
}
},
featuredCommentsCount: {
$apply: (value) => value - 1
}
}
});
return updated;
}
}
}),
AddTag: ({variables}) => ({
updateQueries: {
CoralEmbedStream_Embed: (previous) => {
if (variables.name !== 'FEATURED') {
return;
}
@@ -55,7 +76,7 @@ export default {
asset: {
featuredComments: {
nodes: {
$apply: (nodes) =>
$apply: (nodes) =>
nodes.filter((n) => n.id !== variables.id)
}
},