prevent crash when deleting last reply (still needs work)

This commit is contained in:
zeppi 2022-04-02 09:20:58 -04:00 committed by jessopb
parent 1891107a80
commit e1a66d389f

View file

@ -44,7 +44,7 @@ function CommentsReplies(props: Props) {
const [commentsToDisplay, setCommentsToDisplay] = React.useState(fetchedReplies); const [commentsToDisplay, setCommentsToDisplay] = React.useState(fetchedReplies);
const isResolvingReplies = fetchedReplies && resolvedReplies.length !== fetchedReplies.length; const isResolvingReplies = fetchedReplies && resolvedReplies.length !== fetchedReplies.length;
const alreadyResolved = !isResolvingReplies && resolvedReplies.length !== 0; const alreadyResolved = !isResolvingReplies && resolvedReplies.length !== 0;
const canDisplayComments = commentsToDisplay && commentsToDisplay.length === fetchedReplies.length; const canDisplayComments = commentsToDisplay && fetchedReplies && commentsToDisplay.length === fetchedReplies.length;
// Batch resolve comment channel urls // Batch resolve comment channel urls
React.useEffect(() => { React.useEffect(() => {
@ -106,7 +106,7 @@ function CommentsReplies(props: Props) {
/> />
</div> </div>
)} )}
{(isFetchingByParentId[parentId] || isResolvingReplies || !canDisplayComments) && ( {(isFetchingByParentId[parentId] || isResolvingReplies || (!fetchedReplies && !canDisplayComments)) && (
<div className="comment__replies-container"> <div className="comment__replies-container">
<div className="comment__actions--nested"> <div className="comment__actions--nested">
<Spinner type="small" /> <Spinner type="small" />