From 64571d384859f2870cdfef8a5cd2404e0ceedc43 Mon Sep 17 00:00:00 2001 From: Chi Vinh Le Date: Thu, 20 Jul 2017 03:28:45 +0700 Subject: [PATCH] Subtract ignored comments correctly --- plugins/talk-plugin-featured-comments/client/index.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/plugins/talk-plugin-featured-comments/client/index.js b/plugins/talk-plugin-featured-comments/client/index.js index 8301ab624..d804e2b55 100644 --- a/plugins/talk-plugin-featured-comments/client/index.js +++ b/plugins/talk-plugin-featured-comments/client/index.js @@ -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, } } });