mirror of
https://github.com/wassname/talk.git
synced 2026-07-03 04:03:56 +08:00
Merge branch 'master' into fix-action-type-query
This commit is contained in:
@@ -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]},
|
||||
|
||||
@@ -37,7 +37,7 @@ class ProfileContainer extends Component {
|
||||
limit: 5,
|
||||
cursor: this.props.root.me.comments.endCursor,
|
||||
},
|
||||
updateQuery: (previous, {fetchMoreResult:{comments}}) => {
|
||||
updateQuery: (previous, {fetchMoreResult:{me: {comments}}}) => {
|
||||
const updated = update(previous, {
|
||||
me: {
|
||||
comments: {
|
||||
@@ -124,8 +124,10 @@ const CommentFragment = gql`
|
||||
|
||||
const LOAD_MORE_QUERY = gql`
|
||||
query TalkSettings_LoadMoreComments($limit: Int, $cursor: Cursor) {
|
||||
comments(query: {limit: $limit, cursor: $cursor}) {
|
||||
...TalkSettings_CommentConnectionFragment
|
||||
me {
|
||||
comments(query: {limit: $limit, cursor: $cursor}) {
|
||||
...TalkSettings_CommentConnectionFragment
|
||||
}
|
||||
}
|
||||
}
|
||||
${CommentFragment}
|
||||
|
||||
@@ -21,6 +21,9 @@ const Asset = {
|
||||
query.parent_id = null;
|
||||
}
|
||||
|
||||
// Include the asset id in the search.
|
||||
query.asset_id = id;
|
||||
|
||||
return Comments.getByQuery(query);
|
||||
},
|
||||
commentCount({id, commentCount}, {tags}, {loaders: {Comments}}) {
|
||||
|
||||
Reference in New Issue
Block a user