fix scrolling issue, limit length of chat history

This commit is contained in:
DispatchCommit 2021-04-04 02:53:58 -07:00
parent 1a7fdbb65c
commit 69ebf47cb5
2 changed files with 3 additions and 3 deletions

View file

@ -7,7 +7,7 @@ import LivestreamFeed from './view';
const select = (state, props) => ({
claim: makeSelectClaimForUri(props.uri)(state),
comments: makeSelectTopLevelCommentsForUri(props.uri)(state),
comments: makeSelectTopLevelCommentsForUri(props.uri)(state).slice(0, 25),
fetchingComments: selectIsFetchingComments(state),
});

View file

@ -54,7 +54,7 @@ export default function LivestreamFeed(props: Props) {
function handleScroll() {
if (element) {
const scrollHeight = element.scrollHeight - element.offsetHeight;
const isAtBottom = scrollHeight === element.scrollTop;
const isAtBottom = scrollHeight <= element.scrollTop + 100;
if (!isAtBottom) {
hasScrolledComments.current = true;
@ -71,7 +71,7 @@ export default function LivestreamFeed(props: Props) {
// Only update comment scroll if the user hasn't scrolled up to view old comments
// If they have, do nothing
if (!hasScrolledComments.current || !performedInitialScroll) {
element.scrollTop = element.scrollHeight - element.offsetHeight;
setTimeout(() => (element.scrollTop = element.scrollHeight - element.offsetHeight + 100), 20);
if (!performedInitialScroll) {
setPerformedInitialScroll(true);