Infinite Scroll: Another attempt to fix a weird bug with missing chats

This commit is contained in:
Alexander Zinchuk 2021-05-08 22:41:19 +03:00
parent 17444bd9f7
commit 99cfeb6e09

View File

@ -92,10 +92,6 @@ const InfiniteScroll: FC<OwnProps> = ({
state.listItemElements = container.querySelectorAll<HTMLDivElement>(itemSelector);
if (noScrollRestore) {
return;
}
let newScrollTop;
if (state.currentAnchor && Array.from(state.listItemElements).includes(state.currentAnchor)) {
@ -104,12 +100,16 @@ const InfiniteScroll: FC<OwnProps> = ({
newScrollTop = scrollTop + (newAnchorTop - state.currentAnchorTop);
} else {
const nextAnchor = state.listItemElements[0];
if (nextAnchor && nextAnchor.offsetParent) {
if (nextAnchor) {
state.currentAnchor = nextAnchor;
state.currentAnchorTop = nextAnchor.getBoundingClientRect().top;
}
}
if (noScrollRestore) {
return;
}
resetScroll(container, newScrollTop);
state.isScrollTopJustUpdated = true;