From db47b23b3115ba73324ab917af72691912219f5e Mon Sep 17 00:00:00 2001 From: Alexander Zinchuk Date: Wed, 19 Apr 2023 04:08:36 +0200 Subject: [PATCH] Message List: Get rid of scroll patch as it is now fixed in Chromium --- src/components/middle/MessageList.tsx | 16 +--------------- src/components/middle/MessageListContent.tsx | 6 ------ src/components/middle/hooks/useScrollHooks.ts | 12 ++---------- src/util/windowEnvironment.ts | 4 +--- 4 files changed, 4 insertions(+), 34 deletions(-) diff --git a/src/components/middle/MessageList.tsx b/src/components/middle/MessageList.tsx index 466ee0b76..15e4ca8ae 100644 --- a/src/components/middle/MessageList.tsx +++ b/src/components/middle/MessageList.tsx @@ -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 = ({ const { isScrolled, updateStickyDates } = useStickyDates(); - const isScrollingRef = useRef(); - const isScrollPatchNeededRef = useRef(); - const handleScroll = useCallback(() => { if (isScrollTopJustUpdatedRef.current) { isScrollTopJustUpdatedRef.current = false; @@ -313,8 +310,6 @@ const MessageList: FC = ({ return; } - isScrollingRef.current = true; - if (!memoFocusingIdRef.current) { updateStickyDates(container, hasTools); } @@ -326,8 +321,6 @@ const MessageList: FC = ({ onPinnedIntersectionChange({ hasScrolled: true }); } - isScrollingRef.current = false; - fastRaf(() => { if (!container.parentElement) { return; @@ -493,11 +486,6 @@ const MessageList: FC = ({ 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 = ({ threadId={threadId} type={type} isReady={isReady} - isScrollingRef={isScrollingRef} - isScrollPatchNeededRef={isScrollPatchNeededRef} threadTopMessageId={threadTopMessageId} hasLinkedChat={hasLinkedChat} isSchedule={messageGroups ? type === 'scheduled' : false} diff --git a/src/components/middle/MessageListContent.tsx b/src/components/middle/MessageListContent.tsx index 55b68cc71..a2b88aae5 100644 --- a/src/components/middle/MessageListContent.tsx +++ b/src/components/middle/MessageListContent.tsx @@ -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 = ({ memoFirstUnreadIdRef, type, isReady, - isScrollingRef, - isScrollPatchNeededRef, threadTopMessageId, hasLinkedChat, isSchedule, @@ -105,8 +101,6 @@ const MessageListContent: FC = ({ onFabToggle, onNotchToggle, isReady, - isScrollingRef, - isScrollPatchNeededRef, ); const lang = useLang(); diff --git a/src/components/middle/hooks/useScrollHooks.ts b/src/components/middle/hooks/useScrollHooks.ts index 9e9add7bc..949808788 100644 --- a/src/components/middle/hooks/useScrollHooks.ts +++ b/src/components/middle/hooks/useScrollHooks.ts @@ -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(); diff --git a/src/util/windowEnvironment.ts b/src/util/windowEnvironment.ts index bab3eba2a..d0ae75f2b 100644 --- a/src/util/windowEnvironment.ts +++ b/src/util/windowEnvironment.ts @@ -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