From 2e135c997b998b28f965c00c3fecdb10c9eb8c06 Mon Sep 17 00:00:00 2001 From: Alexander Zinchuk Date: Wed, 2 Feb 2022 22:48:48 +0100 Subject: [PATCH] Message List: Fix scroll freezing on iOS after swipe-to-back --- src/components/middle/MiddleColumn.tsx | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/components/middle/MiddleColumn.tsx b/src/components/middle/MiddleColumn.tsx index b0b4544c6..8b7b190f2 100644 --- a/src/components/middle/MiddleColumn.tsx +++ b/src/components/middle/MiddleColumn.tsx @@ -203,7 +203,10 @@ const MiddleColumn: FC = ({ ); const { isReady, handleOpenEnd, handleSlideStop } = useIsReady( - animationLevel, currentTransitionKey, prevTransitionKey, chatId, + !shouldSkipHistoryAnimations && animationLevel !== ANIMATION_LEVEL_MIN, + currentTransitionKey, + prevTransitionKey, + chatId, ); useEffect(() => { @@ -608,7 +611,7 @@ export default memo(withGlobal( )(MiddleColumn)); function useIsReady( - animationLevel?: number, + withAnimations?: boolean, currentTransitionKey?: number, prevTransitionKey?: number, chatId?: string, @@ -618,7 +621,7 @@ function useIsReady( const willSwitchMessageList = prevTransitionKey !== undefined && prevTransitionKey !== currentTransitionKey; if (willSwitchMessageList) { - if (animationLevel !== ANIMATION_LEVEL_MIN) { + if (withAnimations) { setIsReady(false); } else { forceUpdate(); @@ -626,10 +629,10 @@ function useIsReady( } useOnChange(() => { - if (animationLevel === ANIMATION_LEVEL_MIN) { + if (!withAnimations) { setIsReady(true); } - }, [animationLevel]); + }, [withAnimations]); function handleOpenEnd(e: React.TransitionEvent) { if (e.propertyName === 'transform' && e.target === e.currentTarget) { @@ -643,7 +646,7 @@ function useIsReady( return { isReady: isReady && !willSwitchMessageList, - handleOpenEnd: animationLevel !== ANIMATION_LEVEL_MIN ? handleOpenEnd : undefined, - handleSlideStop: animationLevel !== ANIMATION_LEVEL_MIN ? handleSlideStop : undefined, + handleOpenEnd: withAnimations ? handleOpenEnd : undefined, + handleSlideStop: withAnimations ? handleSlideStop : undefined, }; }