Message List: Get rid of scroll patch as it is now fixed in Chromium
This commit is contained in:
parent
6c50a23f4b
commit
db47b23b31
@ -51,7 +51,7 @@ import { fastRaf, debounce, onTickEnd } from '../../util/schedulers';
|
|||||||
import buildClassName from '../../util/buildClassName';
|
import buildClassName from '../../util/buildClassName';
|
||||||
import { groupMessages } from './helpers/groupMessages';
|
import { groupMessages } from './helpers/groupMessages';
|
||||||
import { preventMessageInputBlur } from './helpers/preventMessageInputBlur';
|
import { preventMessageInputBlur } from './helpers/preventMessageInputBlur';
|
||||||
import resetScroll, { patchChromiumScroll } from '../../util/resetScroll';
|
import resetScroll from '../../util/resetScroll';
|
||||||
import fastSmoothScroll, { isAnimatingScroll } from '../../util/fastSmoothScroll';
|
import fastSmoothScroll, { isAnimatingScroll } from '../../util/fastSmoothScroll';
|
||||||
import renderText from '../common/helpers/renderText';
|
import renderText from '../common/helpers/renderText';
|
||||||
|
|
||||||
@ -299,9 +299,6 @@ const MessageList: FC<OwnProps & StateProps> = ({
|
|||||||
|
|
||||||
const { isScrolled, updateStickyDates } = useStickyDates();
|
const { isScrolled, updateStickyDates } = useStickyDates();
|
||||||
|
|
||||||
const isScrollingRef = useRef<boolean>();
|
|
||||||
const isScrollPatchNeededRef = useRef<boolean>();
|
|
||||||
|
|
||||||
const handleScroll = useCallback(() => {
|
const handleScroll = useCallback(() => {
|
||||||
if (isScrollTopJustUpdatedRef.current) {
|
if (isScrollTopJustUpdatedRef.current) {
|
||||||
isScrollTopJustUpdatedRef.current = false;
|
isScrollTopJustUpdatedRef.current = false;
|
||||||
@ -313,8 +310,6 @@ const MessageList: FC<OwnProps & StateProps> = ({
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
isScrollingRef.current = true;
|
|
||||||
|
|
||||||
if (!memoFocusingIdRef.current) {
|
if (!memoFocusingIdRef.current) {
|
||||||
updateStickyDates(container, hasTools);
|
updateStickyDates(container, hasTools);
|
||||||
}
|
}
|
||||||
@ -326,8 +321,6 @@ const MessageList: FC<OwnProps & StateProps> = ({
|
|||||||
onPinnedIntersectionChange({ hasScrolled: true });
|
onPinnedIntersectionChange({ hasScrolled: true });
|
||||||
}
|
}
|
||||||
|
|
||||||
isScrollingRef.current = false;
|
|
||||||
|
|
||||||
fastRaf(() => {
|
fastRaf(() => {
|
||||||
if (!container.parentElement) {
|
if (!container.parentElement) {
|
||||||
return;
|
return;
|
||||||
@ -493,11 +486,6 @@ const MessageList: FC<OwnProps & StateProps> = ({
|
|||||||
|
|
||||||
newScrollTop = scrollHeight - offsetHeight;
|
newScrollTop = scrollHeight - offsetHeight;
|
||||||
} else if (anchor) {
|
} else if (anchor) {
|
||||||
if (isScrollPatchNeededRef.current) {
|
|
||||||
isScrollPatchNeededRef.current = false;
|
|
||||||
patchChromiumScroll(container);
|
|
||||||
}
|
|
||||||
|
|
||||||
const newAnchorTop = anchor.getBoundingClientRect().top;
|
const newAnchorTop = anchor.getBoundingClientRect().top;
|
||||||
newScrollTop = scrollTop + (newAnchorTop - (anchorTopRef.current || 0));
|
newScrollTop = scrollTop + (newAnchorTop - (anchorTopRef.current || 0));
|
||||||
} else if (unreadDivider) {
|
} else if (unreadDivider) {
|
||||||
@ -654,8 +642,6 @@ const MessageList: FC<OwnProps & StateProps> = ({
|
|||||||
threadId={threadId}
|
threadId={threadId}
|
||||||
type={type}
|
type={type}
|
||||||
isReady={isReady}
|
isReady={isReady}
|
||||||
isScrollingRef={isScrollingRef}
|
|
||||||
isScrollPatchNeededRef={isScrollPatchNeededRef}
|
|
||||||
threadTopMessageId={threadTopMessageId}
|
threadTopMessageId={threadTopMessageId}
|
||||||
hasLinkedChat={hasLinkedChat}
|
hasLinkedChat={hasLinkedChat}
|
||||||
isSchedule={messageGroups ? type === 'scheduled' : false}
|
isSchedule={messageGroups ? type === 'scheduled' : false}
|
||||||
|
|||||||
@ -43,8 +43,6 @@ interface OwnProps {
|
|||||||
memoFirstUnreadIdRef: { current: number | undefined };
|
memoFirstUnreadIdRef: { current: number | undefined };
|
||||||
type: MessageListType;
|
type: MessageListType;
|
||||||
isReady: boolean;
|
isReady: boolean;
|
||||||
isScrollingRef: { current: boolean | undefined };
|
|
||||||
isScrollPatchNeededRef: { current: boolean | undefined };
|
|
||||||
threadTopMessageId: number | undefined;
|
threadTopMessageId: number | undefined;
|
||||||
hasLinkedChat: boolean | undefined;
|
hasLinkedChat: boolean | undefined;
|
||||||
isSchedule: boolean;
|
isSchedule: boolean;
|
||||||
@ -74,8 +72,6 @@ const MessageListContent: FC<OwnProps> = ({
|
|||||||
memoFirstUnreadIdRef,
|
memoFirstUnreadIdRef,
|
||||||
type,
|
type,
|
||||||
isReady,
|
isReady,
|
||||||
isScrollingRef,
|
|
||||||
isScrollPatchNeededRef,
|
|
||||||
threadTopMessageId,
|
threadTopMessageId,
|
||||||
hasLinkedChat,
|
hasLinkedChat,
|
||||||
isSchedule,
|
isSchedule,
|
||||||
@ -105,8 +101,6 @@ const MessageListContent: FC<OwnProps> = ({
|
|||||||
onFabToggle,
|
onFabToggle,
|
||||||
onNotchToggle,
|
onNotchToggle,
|
||||||
isReady,
|
isReady,
|
||||||
isScrollingRef,
|
|
||||||
isScrollPatchNeededRef,
|
|
||||||
);
|
);
|
||||||
|
|
||||||
const lang = useLang();
|
const lang = useLang();
|
||||||
|
|||||||
@ -5,8 +5,8 @@ import { useMemo, useRef } from '../../../lib/teact/teact';
|
|||||||
import { LoadMoreDirection } from '../../../types';
|
import { LoadMoreDirection } from '../../../types';
|
||||||
import type { MessageListType } from '../../../global/types';
|
import type { MessageListType } from '../../../global/types';
|
||||||
|
|
||||||
import { LOCAL_MESSAGE_MIN_ID, MESSAGE_LIST_SLICE } from '../../../config';
|
import { LOCAL_MESSAGE_MIN_ID } from '../../../config';
|
||||||
import { IS_SCROLL_PATCH_NEEDED, MESSAGE_LIST_SENSITIVE_AREA } from '../../../util/windowEnvironment';
|
import { MESSAGE_LIST_SENSITIVE_AREA } from '../../../util/windowEnvironment';
|
||||||
import { debounce } from '../../../util/schedulers';
|
import { debounce } from '../../../util/schedulers';
|
||||||
import { useIntersectionObserver, useOnIntersect } from '../../../hooks/useIntersectionObserver';
|
import { useIntersectionObserver, useOnIntersect } from '../../../hooks/useIntersectionObserver';
|
||||||
import useSyncEffect from '../../../hooks/useSyncEffect';
|
import useSyncEffect from '../../../hooks/useSyncEffect';
|
||||||
@ -24,8 +24,6 @@ export default function useScrollHooks(
|
|||||||
onFabToggle: AnyToVoidFunction,
|
onFabToggle: AnyToVoidFunction,
|
||||||
onNotchToggle: AnyToVoidFunction,
|
onNotchToggle: AnyToVoidFunction,
|
||||||
isReady: boolean,
|
isReady: boolean,
|
||||||
isScrollingRef: { current: boolean | undefined },
|
|
||||||
isScrollPatchNeededRef: { current: boolean | undefined },
|
|
||||||
) {
|
) {
|
||||||
const { loadViewportMessages } = getActions();
|
const { loadViewportMessages } = getActions();
|
||||||
|
|
||||||
@ -99,12 +97,6 @@ export default function useScrollHooks(
|
|||||||
const { target } = triggerEntry;
|
const { target } = triggerEntry;
|
||||||
|
|
||||||
if (target.className === 'backwards-trigger') {
|
if (target.className === 'backwards-trigger') {
|
||||||
if (
|
|
||||||
IS_SCROLL_PATCH_NEEDED && isScrollingRef.current && messageIds.length <= MESSAGE_LIST_SLICE
|
|
||||||
) {
|
|
||||||
isScrollPatchNeededRef.current = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
loadMoreBackwards();
|
loadMoreBackwards();
|
||||||
} else if (target.className === 'forwards-trigger') {
|
} else if (target.className === 'forwards-trigger') {
|
||||||
loadMoreForwards();
|
loadMoreForwards();
|
||||||
|
|||||||
@ -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()')
|
export const IS_BACKDROP_BLUR_SUPPORTED = CSS.supports('backdrop-filter: blur()')
|
||||||
|| CSS.supports('-webkit-backdrop-filter: blur()');
|
|| CSS.supports('-webkit-backdrop-filter: blur()');
|
||||||
export const IS_COMPACT_MENU = !IS_TOUCH_ENV;
|
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_INSTALL_PROMPT_SUPPORTED = 'onbeforeinstallprompt' in window;
|
||||||
export const IS_MULTITAB_SUPPORTED = 'BroadcastChannel' 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_OPEN_IN_NEW_TAB_SUPPORTED = IS_MULTITAB_SUPPORTED && !(IS_PWA && IS_MOBILE);
|
||||||
export const IS_TRANSLATION_SUPPORTED = Boolean(Intl.DisplayNames);
|
export const IS_TRANSLATION_SUPPORTED = Boolean(Intl.DisplayNames);
|
||||||
|
|
||||||
// Smaller area reduces scroll jumps caused by `patchChromiumScroll`
|
export const MESSAGE_LIST_SENSITIVE_AREA = 750;
|
||||||
export const MESSAGE_LIST_SENSITIVE_AREA = IS_SCROLL_PATCH_NEEDED ? 300 : 750;
|
|
||||||
|
|
||||||
export const MAX_BUFFER_SIZE = (IS_MOBILE ? 512 : 2000) * 1024 ** 2; // 512 OR 2000 MB
|
export const MAX_BUFFER_SIZE = (IS_MOBILE ? 512 : 2000) * 1024 ** 2; // 512 OR 2000 MB
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user