From fa08450185298d0ac3e47630351cd00f6b6387ed Mon Sep 17 00:00:00 2001 From: Chi Vinh Le Date: Thu, 1 Jun 2017 22:39:05 +0700 Subject: [PATCH] Increase/Decrease totalCommentCount after mutation --- client/coral-embed-stream/src/graphql/utils.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/client/coral-embed-stream/src/graphql/utils.js b/client/coral-embed-stream/src/graphql/utils.js index 3df4c2e51..163432479 100644 --- a/client/coral-embed-stream/src/graphql/utils.js +++ b/client/coral-embed-stream/src/graphql/utils.js @@ -28,6 +28,14 @@ function findAndInsertComment(parent, id, comment) { } export function insertCommentIntoEmbedQuery(root, id, comment) { + + // Increase total comment count by one. + root = update(root, { + asset: { + totalCommentCount: {$apply: (c) => c + 1}, + }, + }); + if (root.comment) { if (root.comment.parent) { return update(root, { @@ -76,6 +84,14 @@ function findAndRemoveComment(parent, id) { } export function removeCommentFromEmbedQuery(root, id) { + + // Decrease total comment by one. + root = update(root, { + asset: { + totalCommentCount: {$apply: (c) => c - 1}, + }, + }); + if (root.comment) { if (root.comment.parent) { return update(root, {