diff --git a/client/coral-embed-stream/src/graphql/utils.js b/client/coral-embed-stream/src/graphql/utils.js index 3df4c2e519..1634324796 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, {