have cursor be the date of the oldest comment

This commit is contained in:
Riley Davis
2017-02-08 16:27:09 -07:00
parent 0c777cbad4
commit ddeb28d729
3 changed files with 14 additions and 8 deletions
+6 -1
View File
@@ -78,9 +78,14 @@ class Embed extends Component {
}
loadMoreComments = () => {
if (!this.props.asset.comments.length) {
return;
}
this.props.loadMore({
limit: 10,
cursor: new Date(),
cursor: this.props.asset.comments[this.props.asset.comments.length - 1].created_at,
asset_id: this.props.asset.id,
sort: 'REVERSE_CHRONOLOGICAL'
})
@@ -35,13 +35,14 @@ export const queryStream = graphql(STREAM_QUERY, {
asset_id,
sort
},
updateQuery: ({asset}, {fetchMoreResult:{data:{new_top_level_comments}}}) => {
const comments = asset.comments.concat(new_top_level_comments);
updateQuery: (oldData, {fetchMoreResult:{data:{new_top_level_comments}}}) => {
const asset = {
...oldData.asset,
comments: [...oldData.asset.comments, ...new_top_level_comments]
};
return {
asset: {
...asset,
comments
}
...oldData,
asset
};
}
});
@@ -97,7 +97,7 @@ const SignInContent = ({
SignInContent.propTypes = {
auth: PropTypes.shape({
isLoading: PropTypes.bool.isRequired,
error: PropTypes.object,
error: PropTypes.string,
emailVerificationFailure: PropTypes.bool
}).isRequired,
fetchSignInFacebook: PropTypes.func.isRequired,