mirror of
https://github.com/wassname/talk.git
synced 2026-07-09 09:59:34 +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)},
|
||||
});
|
||||
}
|
||||
|
||||
@@ -253,10 +253,19 @@ type Comment {
|
||||
editing: EditInfo
|
||||
}
|
||||
|
||||
# CommentConnection represents a paginable subset of a comment list.
|
||||
type CommentConnection {
|
||||
|
||||
# Indicates that there are more comments after this subset.
|
||||
hasNextPage: Boolean!
|
||||
|
||||
# Cursor of first comment in subset.
|
||||
startCursor: Date
|
||||
|
||||
# Cursor of last comment in subset.
|
||||
endCursor: Date
|
||||
|
||||
# Subset of comments.
|
||||
nodes: [Comment!]!
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user