mirror of
https://github.com/wassname/talk.git
synced 2026-09-09 11:38:08 +08:00
Add some comments
This commit is contained in:
@@ -2,7 +2,7 @@ import {gql} from 'react-apollo';
|
||||
import {add} from 'coral-framework/services/graphqlRegistry';
|
||||
import update from 'immutability-helper';
|
||||
import uuid from 'uuid/v4';
|
||||
import {insertComment, removeComment} from './utils';
|
||||
import {insertCommentIntoEmbedQuery, removeCommentFromEmbedQuery} from './utils';
|
||||
|
||||
const extension = {
|
||||
fragments: {
|
||||
@@ -165,7 +165,7 @@ const extension = {
|
||||
if (prev.asset.settings.moderation === 'PRE' || comment.status === 'PREMOD' || comment.status === 'REJECTED') {
|
||||
return prev;
|
||||
}
|
||||
return insertComment(prev, parent_id, comment);
|
||||
return insertCommentIntoEmbedQuery(prev, parent_id, comment);
|
||||
},
|
||||
}
|
||||
}),
|
||||
@@ -175,7 +175,7 @@ const extension = {
|
||||
if (!['PREMOD', 'REJECTED'].includes(comment.status)) {
|
||||
return null;
|
||||
}
|
||||
return removeComment(prev, comment.id);
|
||||
return removeCommentFromEmbedQuery(prev, comment.id);
|
||||
},
|
||||
},
|
||||
}),
|
||||
|
||||
@@ -27,7 +27,7 @@ function findAndInsertComment(parent, id, comment) {
|
||||
});
|
||||
}
|
||||
|
||||
export function insertComment(root, id, comment) {
|
||||
export function insertCommentIntoEmbedQuery(root, id, comment) {
|
||||
if (root.comment) {
|
||||
if (root.comment.parent) {
|
||||
return update(root, {
|
||||
@@ -75,24 +75,24 @@ function findAndRemoveComment(parent, id) {
|
||||
return update(parent, changes);
|
||||
}
|
||||
|
||||
export function removeComment(root, id, comment) {
|
||||
export function removeCommentFromEmbedQuery(root, id) {
|
||||
if (root.comment) {
|
||||
if (root.comment.parent) {
|
||||
return update(root, {
|
||||
comment: {
|
||||
parent: {
|
||||
$apply: (node) => findAndRemoveComment(node, id, comment),
|
||||
$apply: (node) => findAndRemoveComment(node, id),
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
return update(root, {
|
||||
comment: {
|
||||
$apply: (node) => findAndRemoveComment(node, id, comment),
|
||||
$apply: (node) => findAndRemoveComment(node, id),
|
||||
},
|
||||
});
|
||||
}
|
||||
return update(root, {
|
||||
asset: {$apply: (asset) => findAndRemoveComment(asset, id, comment)},
|
||||
asset: {$apply: (asset) => findAndRemoveComment(asset, id)},
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user