fix scrolling issue, limit length of chat history
This commit is contained in:
parent
92e55c7d5f
commit
bb56de1d4f
2 changed files with 3 additions and 3 deletions
|
@ -7,7 +7,7 @@ import LivestreamFeed from './view';
|
||||||
|
|
||||||
const select = (state, props) => ({
|
const select = (state, props) => ({
|
||||||
claim: makeSelectClaimForUri(props.uri)(state),
|
claim: makeSelectClaimForUri(props.uri)(state),
|
||||||
comments: makeSelectTopLevelCommentsForUri(props.uri)(state),
|
comments: makeSelectTopLevelCommentsForUri(props.uri)(state).slice(0, 25),
|
||||||
fetchingComments: selectIsFetchingComments(state),
|
fetchingComments: selectIsFetchingComments(state),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -54,7 +54,7 @@ export default function LivestreamFeed(props: Props) {
|
||||||
function handleScroll() {
|
function handleScroll() {
|
||||||
if (element) {
|
if (element) {
|
||||||
const scrollHeight = element.scrollHeight - element.offsetHeight;
|
const scrollHeight = element.scrollHeight - element.offsetHeight;
|
||||||
const isAtBottom = scrollHeight === element.scrollTop;
|
const isAtBottom = scrollHeight <= element.scrollTop + 100;
|
||||||
|
|
||||||
if (!isAtBottom) {
|
if (!isAtBottom) {
|
||||||
hasScrolledComments.current = true;
|
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
|
// Only update comment scroll if the user hasn't scrolled up to view old comments
|
||||||
// If they have, do nothing
|
// If they have, do nothing
|
||||||
if (!hasScrolledComments.current || !performedInitialScroll) {
|
if (!hasScrolledComments.current || !performedInitialScroll) {
|
||||||
element.scrollTop = element.scrollHeight - element.offsetHeight;
|
setTimeout(() => (element.scrollTop = element.scrollHeight - element.offsetHeight + 100), 20);
|
||||||
|
|
||||||
if (!performedInitialScroll) {
|
if (!performedInitialScroll) {
|
||||||
setPerformedInitialScroll(true);
|
setPerformedInitialScroll(true);
|
||||||
|
|
Loading…
Reference in a new issue