Merge pull request #882 from coralproject/fix-permalink-liveupdates

Fix live update false comments in permalink view
This commit is contained in:
Kim Gardner
2017-08-28 16:23:57 +01:00
committed by GitHub
@@ -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]},