Message List: Drop redundant code

This commit is contained in:
Alexander Zinchuk 2021-12-25 12:41:05 +01:00
parent ab9cef0f13
commit 49e3ec5e93
3 changed files with 3 additions and 17 deletions

View File

@ -327,11 +327,6 @@ const MessageList: FC<OwnProps & StateProps & DispatchProps> = ({
const container = containerRef.current!;
listItemElementsRef.current = Array.from(container.querySelectorAll<HTMLDivElement>('.message-list-item'));
// TODO Consider removing
if (!container.offsetParent) {
return;
}
const hasLastMessageChanged = (
messageIds && prevMessageIds && messageIds[messageIds.length - 1] !== prevMessageIds[prevMessageIds.length - 1]
);
@ -362,8 +357,7 @@ const MessageList: FC<OwnProps & StateProps & DispatchProps> = ({
}
const { scrollTop, scrollHeight, offsetHeight } = container;
// TODO Consider `scrollOffset = scrollHeight - scrollTop`
const scrollOffset = scrollOffsetRef.current!;
const scrollOffset = scrollOffsetRef.current;
const lastItemElement = listItemElementsRef.current[listItemElementsRef.current.length - 1];
let bottomOffset = scrollOffset - (prevContainerHeight || offsetHeight);
@ -405,8 +399,7 @@ const MessageList: FC<OwnProps & StateProps & DispatchProps> = ({
}
const isResized = prevContainerHeight !== undefined && prevContainerHeight !== containerHeight;
// TODO Look up within active transition slide
const anchor = anchorIdRef.current && document.getElementById(anchorIdRef.current);
const anchor = anchorIdRef.current && container.querySelector(`#${anchorIdRef.current}`);
const unreadDivider = (
!anchor
&& memoUnreadDividerBeforeIdRef.current

View File

@ -6,9 +6,8 @@ import { LoadMoreDirection } from '../../../types';
import { MessageListType } from '../../../global/types';
import { LOCAL_MESSAGE_ID_BASE, MESSAGE_LIST_SLICE } from '../../../config';
import { IS_MAC_OS, IS_SCROLL_PATCH_NEEDED, MESSAGE_LIST_SENSITIVE_AREA } from '../../../util/environment';
import { IS_SCROLL_PATCH_NEEDED, MESSAGE_LIST_SENSITIVE_AREA } from '../../../util/environment';
import { debounce } from '../../../util/schedulers';
import resetScroll from '../../../util/resetScroll';
import { useIntersectionObserver, useOnIntersect } from '../../../hooks/useIntersectionObserver';
import useOnChange from '../../../hooks/useOnChange';
@ -100,12 +99,8 @@ export default function useScrollHooks(
isScrollPatchNeededRef.current = true;
}
// TODO Consider removing
resetScroll(containerRef.current!);
loadMoreBackwards();
} else if (target.className === 'forwards-trigger') {
// TODO Consider removing
resetScroll(containerRef.current!);
loadMoreForwards();
}
});

View File

@ -165,7 +165,6 @@ const InfiniteScroll: FC<OwnProps> = ({
stateRef.current.currentAnchor = nextAnchor;
stateRef.current.currentAnchorTop = nextAnchorTop;
isUpdated = true;
resetScroll(container);
loadMoreForwards();
}
}
@ -186,7 +185,6 @@ const InfiniteScroll: FC<OwnProps> = ({
stateRef.current.currentAnchor = nextAnchor;
stateRef.current.currentAnchorTop = nextAnchorTop;
isUpdated = true;
resetScroll(container);
loadMoreBackwards();
}
}