From 8be450cc35ab4ffdf28ece795b3cde34b82dd882 Mon Sep 17 00:00:00 2001 From: Alexander Zinchuk Date: Mon, 13 Dec 2021 15:37:36 +0100 Subject: [PATCH] Voice Chat: Prevent accidentally rotating device --- src/components/main/Main.tsx | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/components/main/Main.tsx b/src/components/main/Main.tsx index 37a922b62..f1322d6ff 100644 --- a/src/components/main/Main.tsx +++ b/src/components/main/Main.tsx @@ -24,12 +24,13 @@ import { dispatchHeavyAnimationEvent } from '../../hooks/useHeavyAnimationCheck' import buildClassName from '../../util/buildClassName'; import { fastRaf } from '../../util/schedulers'; import { waitForTransitionEnd } from '../../util/cssAnimationEndListeners'; +import { processDeepLink } from '../../util/deeplink'; +import windowSize from '../../util/windowSize'; import useShowTransition from '../../hooks/useShowTransition'; import useBackgroundMode from '../../hooks/useBackgroundMode'; import useBeforeUnload from '../../hooks/useBeforeUnload'; import useOnChange from '../../hooks/useOnChange'; import usePreventPinchZoomGesture from '../../hooks/usePreventPinchZoomGesture'; -import { processDeepLink } from '../../util/deeplink'; import { LOCATION_HASH } from '../../hooks/useHistoryBack'; import LeftColumn from '../left/LeftColumn'; @@ -167,6 +168,19 @@ const Main: FC = ({ } }, [lastSyncTime]); + // Prevent refresh by accidentally rotating device when listening to a voice chat + useEffect(() => { + if (!activeGroupCallId) { + return undefined; + } + + windowSize.disableRefresh(); + + return () => { + windowSize.enableRefresh(); + }; + }, [activeGroupCallId]); + const { transitionClassNames: middleColumnTransitionClassNames, } = useShowTransition(!isLeftColumnShown, undefined, true, undefined, shouldSkipHistoryAnimations);