Subtract ignored comments correctly

This commit is contained in:
Chi Vinh Le
2017-07-20 03:28:45 +07:00
parent 6cab2634bf
commit 64571d3848
@@ -21,16 +21,15 @@ export default {
updateQueries: {
CoralEmbedStream_Embed: (previous) => {
const ignoredUserId = variables.id;
const newNodes = previous.asset.featuredComments.nodes.filter((n) => n.user.id !== ignoredUserId);
const removedCount = previous.asset.featuredComments.nodes.length - newNodes.length;
const updated = update(previous, {
asset: {
featuredComments: {
nodes: {
$apply: (nodes) =>
nodes.filter((n) => n.user.id !== ignoredUserId)
}
nodes: {$set: newNodes}
},
featuredCommentsCount: {
$apply: (value) => value - 1
$apply: (value) => value - removedCount,
}
}
});