From a758018f51656220d08aff2412344a5e313c32e3 Mon Sep 17 00:00:00 2001 From: Mathieu Meissonnier <173043140+mmeissonnier-pass@users.noreply.github.com> Date: Tue, 24 Dec 2024 10:52:01 +0100 Subject: [PATCH] (BSR) fix(global): keep splashscreen when no network at startup --- src/App.tsx | 73 ++++++++++++++--------------- src/libs/network/NetInfoWrapper.tsx | 10 +++- 2 files changed, 44 insertions(+), 39 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index 370b0d42a9b..f863ed0ddb2 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -81,25 +81,24 @@ const App: FunctionComponent = function () { }, []) return ( - - - - - - - {/* All react-query calls should be nested inside NetInfoWrapper to ensure the user has internet connection */} - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + @@ -111,24 +110,24 @@ const App: FunctionComponent = function () { - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + ) } diff --git a/src/libs/network/NetInfoWrapper.tsx b/src/libs/network/NetInfoWrapper.tsx index f1cb1702d54..ace14976ef1 100644 --- a/src/libs/network/NetInfoWrapper.tsx +++ b/src/libs/network/NetInfoWrapper.tsx @@ -6,6 +6,7 @@ import { onlineManager } from 'react-query' import { analytics } from 'libs/analytics' import { useNetInfo } from 'libs/network/useNetInfo' +import { useSplashScreenContext } from 'libs/splashscreen' import { SNACK_BAR_TIME_OUT, useSnackBarContext } from 'ui/components/snackBar/SnackBarContext' export const NetInfoWrapper = memo(function NetInfoWrapper({ @@ -15,9 +16,10 @@ export const NetInfoWrapper = memo(function NetInfoWrapper({ }) { const networkInfo = useNetInfo() const { showInfoSnackBar } = useSnackBarContext() + const isConnected = !!networkInfo.isConnected && !!networkInfo.isInternetReachable + const { isSplashScreenHidden } = useSplashScreenContext() useEffect(() => { - const isConnected = !!networkInfo.isConnected && !!networkInfo.isInternetReachable onlineManager.setOnline(isConnected) if (isConnected === false) { showInfoSnackBar({ @@ -43,7 +45,11 @@ export const NetInfoWrapper = memo(function NetInfoWrapper({ // eslint-disable-next-line react-hooks/exhaustive-deps }, [networkInfo.type]) - return {children} + return ( + + {!isSplashScreenHidden && !isConnected ? null : children} + + ) }) const isWeb = Platform.OS === 'web'