Append comments only

This commit is contained in:
Chi Vinh Le
2017-12-14 15:57:44 +01:00
parent f32bb5ce8f
commit 62c2d551f8
@@ -45,17 +45,14 @@ function addCommentToQueue(root, queue, comment, sortOrder) {
return root;
}
const sortAlgo = sortOrder === 'ASC' ? ascending : descending;
const changes = {
[`${queue}Count`]: {$set: root[`${queue}Count`] + 1},
};
if (shouldCommentBeAdded(root, queue, comment, sortOrder)) {
const nodes = root[queue].nodes.concat(comment).sort(sortAlgo);
const nodes = root[queue].nodes.concat(comment);
changes[queue] = {
nodes: {$set: nodes},
startCursor: {$set: nodes[0].created_at},
endCursor: {$set: nodes[nodes.length - 1].created_at},
};
}