Merge pull request #629 from coralproject/dec-inc-total-comment-count

Increase/Decrease totalCommentCount after mutation
This commit is contained in:
Kim Gardner
2017-06-01 11:59:11 -04:00
committed by GitHub
@@ -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, {