Message List: Get rid of scroll patch as it is now fixed in Chromium

This commit is contained in:
Alexander Zinchuk 2023-04-19 04:08:36 +02:00
parent 6c50a23f4b
commit db47b23b31
4 changed files with 4 additions and 34 deletions

View File

@ -51,7 +51,7 @@ import { fastRaf, debounce, onTickEnd } from '../../util/schedulers';
import buildClassName from '../../util/buildClassName';
import { groupMessages } from './helpers/groupMessages';
import { preventMessageInputBlur } from './helpers/preventMessageInputBlur';
import resetScroll, { patchChromiumScroll } from '../../util/resetScroll';
import resetScroll from '../../util/resetScroll';
import fastSmoothScroll, { isAnimatingScroll } from '../../util/fastSmoothScroll';
import renderText from '../common/helpers/renderText';
@ -299,9 +299,6 @@ const MessageList: FC<OwnProps & StateProps> = ({
const { isScrolled, updateStickyDates } = useStickyDates();
const isScrollingRef = useRef<boolean>();
const isScrollPatchNeededRef = useRef<boolean>();
const handleScroll = useCallback(() => {
if (isScrollTopJustUpdatedRef.current) {
isScrollTopJustUpdatedRef.current = false;
@ -313,8 +310,6 @@ const MessageList: FC<OwnProps & StateProps> = ({
return;
}
isScrollingRef.current = true;
if (!memoFocusingIdRef.current) {
updateStickyDates(container, hasTools);
}
@ -326,8 +321,6 @@ const MessageList: FC<OwnProps & StateProps> = ({
onPinnedIntersectionChange({ hasScrolled: true });
}
isScrollingRef.current = false;
fastRaf(() => {
if (!container.parentElement) {
return;
@ -493,11 +486,6 @@ const MessageList: FC<OwnProps & StateProps> = ({
newScrollTop = scrollHeight - offsetHeight;
} else if (anchor) {
if (isScrollPatchNeededRef.current) {
isScrollPatchNeededRef.current = false;
patchChromiumScroll(container);
}
const newAnchorTop = anchor.getBoundingClientRect().top;
newScrollTop = scrollTop + (newAnchorTop - (anchorTopRef.current || 0));
} else if (unreadDivider) {
@ -654,8 +642,6 @@ const MessageList: FC<OwnProps & StateProps> = ({
threadId={threadId}
type={type}
isReady={isReady}
isScrollingRef={isScrollingRef}
isScrollPatchNeededRef={isScrollPatchNeededRef}
threadTopMessageId={threadTopMessageId}
hasLinkedChat={hasLinkedChat}
isSchedule={messageGroups ? type === 'scheduled' : false}

View File

@ -43,8 +43,6 @@ interface OwnProps {
memoFirstUnreadIdRef: { current: number | undefined };
type: MessageListType;
isReady: boolean;
isScrollingRef: { current: boolean | undefined };
isScrollPatchNeededRef: { current: boolean | undefined };
threadTopMessageId: number | undefined;
hasLinkedChat: boolean | undefined;
isSchedule: boolean;
@ -74,8 +72,6 @@ const MessageListContent: FC<OwnProps> = ({
memoFirstUnreadIdRef,
type,
isReady,
isScrollingRef,
isScrollPatchNeededRef,
threadTopMessageId,
hasLinkedChat,
isSchedule,
@ -105,8 +101,6 @@ const MessageListContent: FC<OwnProps> = ({
onFabToggle,
onNotchToggle,
isReady,
isScrollingRef,
isScrollPatchNeededRef,
);
const lang = useLang();

View File

@ -5,8 +5,8 @@ import { useMemo, useRef } from '../../../lib/teact/teact';
import { LoadMoreDirection } from '../../../types';
import type { MessageListType } from '../../../global/types';
import { LOCAL_MESSAGE_MIN_ID, MESSAGE_LIST_SLICE } from '../../../config';
import { IS_SCROLL_PATCH_NEEDED, MESSAGE_LIST_SENSITIVE_AREA } from '../../../util/windowEnvironment';
import { LOCAL_MESSAGE_MIN_ID } from '../../../config';
import { MESSAGE_LIST_SENSITIVE_AREA } from '../../../util/windowEnvironment';
import { debounce } from '../../../util/schedulers';
import { useIntersectionObserver, useOnIntersect } from '../../../hooks/useIntersectionObserver';
import useSyncEffect from '../../../hooks/useSyncEffect';
@ -24,8 +24,6 @@ export default function useScrollHooks(
onFabToggle: AnyToVoidFunction,
onNotchToggle: AnyToVoidFunction,
isReady: boolean,
isScrollingRef: { current: boolean | undefined },
isScrollPatchNeededRef: { current: boolean | undefined },
) {
const { loadViewportMessages } = getActions();
@ -99,12 +97,6 @@ export default function useScrollHooks(
const { target } = triggerEntry;
if (target.className === 'backwards-trigger') {
if (
IS_SCROLL_PATCH_NEEDED && isScrollingRef.current && messageIds.length <= MESSAGE_LIST_SLICE
) {
isScrollPatchNeededRef.current = true;
}
loadMoreBackwards();
} else if (target.className === 'forwards-trigger') {
loadMoreForwards();

View File

@ -110,14 +110,12 @@ export const IS_OFFSET_PATH_SUPPORTED = CSS.supports('offset-rotate: 0deg');
export const IS_BACKDROP_BLUR_SUPPORTED = CSS.supports('backdrop-filter: blur()')
|| CSS.supports('-webkit-backdrop-filter: blur()');
export const IS_COMPACT_MENU = !IS_TOUCH_ENV;
export const IS_SCROLL_PATCH_NEEDED = !IS_MAC_OS && !IS_MOBILE;
export const IS_INSTALL_PROMPT_SUPPORTED = 'onbeforeinstallprompt' in window;
export const IS_MULTITAB_SUPPORTED = 'BroadcastChannel' in window;
export const IS_OPEN_IN_NEW_TAB_SUPPORTED = IS_MULTITAB_SUPPORTED && !(IS_PWA && IS_MOBILE);
export const IS_TRANSLATION_SUPPORTED = Boolean(Intl.DisplayNames);
// Smaller area reduces scroll jumps caused by `patchChromiumScroll`
export const MESSAGE_LIST_SENSITIVE_AREA = IS_SCROLL_PATCH_NEEDED ? 300 : 750;
export const MESSAGE_LIST_SENSITIVE_AREA = 750;
export const MAX_BUFFER_SIZE = (IS_MOBILE ? 512 : 2000) * 1024 ** 2; // 512 OR 2000 MB