Add totalReplyCount prop to check whether thread has reached limit instead of checking only the 20 we load on the first try

This commit is contained in:
Karishma Chadha 2021-06-02 17:38:10 -04:00
parent 99344af688
commit 17ada7172d
2 changed files with 4 additions and 1 deletions

View file

@ -103,13 +103,14 @@ class TopLevelComment extends React.Component {
replies,
postURI,
threadHasReplyStatus,
totalReplyCount,
visibility
} = this.props;
const parentVisible = visibility === 'visible';
// Check whether this comment thread has reached the thread limit
const hasReachedThreadLimit = hasThreadLimit && replies.length >= THREAD_LIMIT;
const hasReachedThreadLimit = hasThreadLimit && totalReplyCount >= THREAD_LIMIT;
/*
Check all the following conditions:
@ -250,6 +251,7 @@ TopLevelComment.propTypes = {
postURI: PropTypes.string,
replies: PropTypes.arrayOf(PropTypes.object),
threadHasReplyStatus: PropTypes.bool,
totalReplyCount: PropTypes.number,
visibility: PropTypes.string
};

View file

@ -102,6 +102,7 @@ const StudioComments = ({
postURI={postURI}
replies={replies && replies[comment.id] ? replies[comment.id] : []}
threadHasReplyStatus={hasReplyStatus(comment)}
totalReplyCount={comment.reply_count}
visibility={comment.visibility}
onAddComment={handleNewComment}
onDelete={handleDeleteComment}