Skip to content

Commit

Permalink
Merge pull request #629 from coralproject/dec-inc-total-comment-count
Browse files Browse the repository at this point in the history
Increase/Decrease totalCommentCount after mutation
  • Loading branch information
kgardnr authored Jun 1, 2017
2 parents 06e6730 + b801550 commit c76e71c
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions client/coral-embed-stream/src/graphql/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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, {
Expand Down Expand Up @@ -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, {
Expand Down

0 comments on commit c76e71c

Please sign in to comment.