From 1c207e87364a503b6cff678fee57615904f96a40 Mon Sep 17 00:00:00 2001 From: Monil Bhavsar Date: Thu, 29 Aug 2024 13:10:51 -0400 Subject: [PATCH] Revert "Prevent Lottie from running in the background after navigating to other pages" --- src/components/Lottie/index.tsx | 26 +------------------------- 1 file changed, 1 insertion(+), 25 deletions(-) diff --git a/src/components/Lottie/index.tsx b/src/components/Lottie/index.tsx index 0f3b81554c75..dd46b33a8400 100644 --- a/src/components/Lottie/index.tsx +++ b/src/components/Lottie/index.tsx @@ -1,4 +1,3 @@ -import {useNavigation} from '@react-navigation/native'; import type {AnimationObject, LottieViewProps} from 'lottie-react-native'; import LottieView from 'lottie-react-native'; import type {ForwardedRef} from 'react'; @@ -9,7 +8,6 @@ import useAppState from '@hooks/useAppState'; import useNetwork from '@hooks/useNetwork'; import useSplashScreen from '@hooks/useSplashScreen'; import useThemeStyles from '@hooks/useThemeStyles'; -import NAVIGATORS from '@src/NAVIGATORS'; type Props = { source: DotLottieAnimation; @@ -20,8 +18,6 @@ function Lottie({source, webStyle, ...props}: Props, ref: ForwardedRef setIsError(false)}); @@ -31,33 +27,13 @@ function Lottie({source, webStyle, ...props}: Props, ref: ForwardedRef { - const unsubscribeNavigationFocus = navigation.addListener('focus', () => { - setIsHidden(false); - }); - return unsubscribeNavigationFocus; - }, [navigation]); - - // Prevent the animation from running in the background after navigating to other pages. - // See https://github.com/Expensify/App/issues/47273 - useEffect(() => { - const unsubscribeNavigationBlur = navigation.addListener('blur', () => { - const state = navigation.getState(); - const targetRouteName = state?.routes?.[state?.index ?? 0]?.name; - if (targetRouteName !== NAVIGATORS.RIGHT_MODAL_NAVIGATOR) { - setIsHidden(true); - } - }); - return unsubscribeNavigationBlur; - }, [navigation]); - const aspectRatioStyle = styles.aspectRatioLottie(source); // If the image fails to load, app is in background state, animation file isn't ready, or the splash screen isn't hidden yet, // we'll just render an empty view as the fallback to prevent // 1. memory leak, see issue: https://github.com/Expensify/App/issues/36645 // 2. heavy rendering, see issue: https://github.com/Expensify/App/issues/34696 - if (isError || isHidden || appState.isBackground || !animationFile || !isSplashHidden) { + if (isError || appState.isBackground || !animationFile || !isSplashHidden) { return ; }