mirror of
https://github.com/wassname/talk.git
synced 2026-09-12 13:01:11 +08:00
Merge pull request #555 from coralproject/fix-more-reply-count
Fix reply count polling
This commit is contained in:
@@ -19,24 +19,13 @@ const {showSignInDialog} = authActions;
|
|||||||
const {addNotification} = notificationActions;
|
const {addNotification} = notificationActions;
|
||||||
|
|
||||||
class StreamContainer extends React.Component {
|
class StreamContainer extends React.Component {
|
||||||
getCounts = ({asset_id, limit, sort}) => {
|
getCounts = (variables) => {
|
||||||
return this.props.data.fetchMore({
|
return this.props.data.fetchMore({
|
||||||
query: LOAD_COMMENT_COUNTS_QUERY,
|
query: LOAD_COMMENT_COUNTS_QUERY,
|
||||||
variables: {
|
variables,
|
||||||
asset_id,
|
|
||||||
limit,
|
// Apollo requires this, even though we don't use it...
|
||||||
sort,
|
updateQuery: data => data,
|
||||||
excludeIgnored: this.props.data.variables.excludeIgnored,
|
|
||||||
},
|
|
||||||
updateQuery: (oldData, {fetchMoreResult:{asset}}) => {
|
|
||||||
return {
|
|
||||||
...oldData,
|
|
||||||
asset: {
|
|
||||||
...oldData.asset,
|
|
||||||
commentCount: asset.commentCount
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -122,12 +111,7 @@ class StreamContainer extends React.Component {
|
|||||||
this.props.data.refetch();
|
this.props.data.refetch();
|
||||||
}
|
}
|
||||||
this.countPoll = setInterval(() => {
|
this.countPoll = setInterval(() => {
|
||||||
const {asset} = this.props.root;
|
this.getCounts(this.props.data.variables);
|
||||||
this.getCounts({
|
|
||||||
asset_id: asset.id,
|
|
||||||
limit: asset.comments.length,
|
|
||||||
sort: 'REVERSE_CHRONOLOGICAL'
|
|
||||||
});
|
|
||||||
}, NEW_COMMENT_COUNT_POLL_INTERVAL);
|
}, NEW_COMMENT_COUNT_POLL_INTERVAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -141,13 +125,13 @@ class StreamContainer extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const LOAD_COMMENT_COUNTS_QUERY = gql`
|
const LOAD_COMMENT_COUNTS_QUERY = gql`
|
||||||
query LoadCommentCounts($asset_id: ID, $limit: Int = 5, $sort: SORT_ORDER) {
|
query LoadCommentCounts($assetUrl: String, $assetId: ID, $excludeIgnored: Boolean) {
|
||||||
asset(id: $asset_id) {
|
asset(id: $assetId, url: $assetUrl) {
|
||||||
id
|
id
|
||||||
commentCount
|
commentCount(excludeIgnored: $excludeIgnored)
|
||||||
comments(sort: $sort, limit: $limit) {
|
comments(limit: 10) {
|
||||||
id
|
id
|
||||||
replyCount
|
replyCount(excludeIgnored: $excludeIgnored)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ export const postComment = graphql(POST_COMMENT, {
|
|||||||
...oldData.asset,
|
...oldData.asset,
|
||||||
comments: oldData.asset.comments.map((oldComment) => {
|
comments: oldData.asset.comments.map((oldComment) => {
|
||||||
return oldComment.id === parent_id
|
return oldComment.id === parent_id
|
||||||
? {...oldComment, replies: [...oldComment.replies, comment]}
|
? {...oldComment, replies: [...oldComment.replies, comment], replyCount: oldComment.replyCount + 1}
|
||||||
: oldComment;
|
: oldComment;
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user