Fix live update false comments in permalink view

This commit is contained in:
Chi Vinh Le
2017-08-28 21:05:32 +07:00
parent 5ec65c86ce
commit 7856c9d947
@@ -36,11 +36,15 @@ function applyToCommentsOrigin(root, callback) {
}
function findAndInsertComment(parent, comment) {
const [connectionField, countField, action] = parent.__typename === 'Asset'
const isAsset = parent.__typename === 'Asset';
const [connectionField, countField, action] = isAsset
? ['comments', 'commentCount', '$unshift']
: ['replies', 'replyCount', '$push'];
if (!comment.parent || parent.id === comment.parent.id) {
if (
!comment.parent && isAsset // A top level comment in the asset.
|| comment.parent && parent.id === comment.parent.id // A reply at the correct parent.
) {
return update(parent, {
[connectionField]: {
nodes: {[action]: [comment]},