don't add scroll listener until comments have been fetched

This commit is contained in:
Sean Yesmunt 2020-10-06 16:13:42 -04:00
parent 00c05437ca
commit fc2a79242e

View file

@ -111,14 +111,14 @@ function CommentList(props: Props) {
} }
} }
if (moreBelow && spinnerRef && spinnerRef.current) { if (!isFetchingComments && moreBelow && spinnerRef && spinnerRef.current) {
window.addEventListener('scroll', handleCommentScroll); window.addEventListener('scroll', handleCommentScroll);
} }
return () => window.removeEventListener('scroll', handleCommentScroll); return () => window.removeEventListener('scroll', handleCommentScroll);
}, [moreBelow, handleMoreBelow, spinnerRef]); }, [moreBelow, handleMoreBelow, spinnerRef]);
function prepareComments(arrayOfComments, linkedComment) { function prepareComments(arrayOfComments, linkedComment, isFetchingComments) {
let orderedComments = []; let orderedComments = [];
if (linkedComment) { if (linkedComment) {