From 2e35c41e0f3e968df6dc07e7656cf50509557a7c Mon Sep 17 00:00:00 2001 From: devthejo Date: Fri, 16 May 2025 10:13:31 +0200 Subject: [PATCH] fix(ios-reported-bug): app only displayed the splash screen after enabling access to location --- src/hooks/useTrackLocation.js | 13 ++++++++++--- src/layout/Layout.js | 3 +++ src/stores/tree.js | 6 ++++++ 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/hooks/useTrackLocation.js b/src/hooks/useTrackLocation.js index 731f0f2..e17cec6 100644 --- a/src/hooks/useTrackLocation.js +++ b/src/hooks/useTrackLocation.js @@ -2,7 +2,11 @@ import { useEffect, useRef, useState } from "react"; import { createLogger } from "~/lib/logger"; import { BACKGROUND_SCOPES } from "~/lib/logger/scopes"; -import { usePermissionWizardState, usePermissionsState } from "~/stores"; +import { + usePermissionWizardState, + usePermissionsState, + useTreeState, +} from "~/stores"; import trackLocation from "~/location/trackLocation"; @@ -12,6 +16,8 @@ const locationLogger = createLogger({ }); export default function useTrackLocation() { + const { splashScreenHidden } = useTreeState(["splashScreenHidden"]); + const { currentStep, completed } = usePermissionWizardState([ "completed", "currentStep", @@ -34,7 +40,8 @@ export default function useTrackLocation() { if ( locationBackground && motion && - (currentStep === "tracking" || currentStep === "success" || completed) + (currentStep === "tracking" || currentStep === "success" || completed) && + splashScreenHidden ) { locationLogger.info("Enabling location tracking", { step: currentStep, @@ -48,7 +55,7 @@ export default function useTrackLocation() { step: currentStep, }); } - }, [locationBackground, motion, currentStep, completed]); + }, [locationBackground, motion, currentStep, completed, splashScreenHidden]); useEffect(() => { if (trackLocationEnabled) { diff --git a/src/layout/Layout.js b/src/layout/Layout.js index 9615f7e..052cfd6 100644 --- a/src/layout/Layout.js +++ b/src/layout/Layout.js @@ -9,6 +9,8 @@ import LayoutProviders from "~/layout/LayoutProviders"; import loadRessources from "~/layout/loadRessources"; import useMount from "~/hooks/useMount"; +import { treeActions } from "~/stores"; + SplashScreen.preventAutoHideAsync(); export default function AppView() { @@ -30,6 +32,7 @@ export default function AppView() { const onLayoutRootView = useCallback(async () => { if (appIsReady) { await SplashScreen.hideAsync(); + treeActions.splashScreenHidden(); } }, [appIsReady]); diff --git a/src/stores/tree.js b/src/stores/tree.js index 960f672..e5f2058 100644 --- a/src/stores/tree.js +++ b/src/stores/tree.js @@ -49,15 +49,21 @@ export default createAtom(({ merge, getActions }) => { merge({ suspend: true }); }; + const splashScreenHidden = () => { + merge({ splashScreenHidden: true }); + }; + return { default: { triggerReload: false, suspend: false, + splashScreenHidden: false, }, actions: { triggerReload, suspendTree, onReload, + splashScreenHidden, }, }; });