chore: Delay splash screen hide until auth and theme stores are hydrated

This commit is contained in:
2025-12-27 05:57:06 +01:00
parent 9c886b7dfb
commit 9cd53ca7ab
2 changed files with 20 additions and 4 deletions
+19 -3
View File
@@ -1,12 +1,28 @@
import React from "react";
import React, { useEffect } from "react";
import {useAuth} from "@/src/stores/authStore";
import {useThemeStore} from "@/src/stores/themeStore";
import NotAuthenticated from "@/src/components/NotAuthenticated";
import LoadingScreen from "@/src/components/LoadingScreen";
import * as SplashScreen from 'expo-splash-screen';
const AuthenticatedWrapper: React.FC<{ children: React.ReactNode }> = ({children}) => {
const {isAuthenticated, loading, authenticatedUser, isHydrated} = useAuth();
const {isAuthenticated, loading, authenticatedUser, isHydrated: authHydrated} = useAuth();
const {isHydrated: themeHydrated} = useThemeStore();
if (!isHydrated || loading) {
// Verstecke den Splash Screen erst wenn beide Stores hydratiert sind
useEffect(() => {
if (authHydrated && themeHydrated) {
SplashScreen.hideAsync().catch(() => {});
}
}, [authHydrated, themeHydrated]);
// Zeige nichts (Splash Screen bleibt) bis beide Stores hydratiert sind
if (!authHydrated || !themeHydrated) {
return null;
}
// Zeige LoadingScreen während Auth Status geprüft wird
if (loading) {
return <LoadingScreen />;
}
+1 -1
View File
@@ -5,7 +5,7 @@ import {useColorScheme} from "nativewind";
import LoadingScreen from "@/src/components/LoadingScreen";
import * as SplashScreen from 'expo-splash-screen';
SplashScreen.hideAsync().catch(() => {});
SplashScreen.preventAutoHideAsync().catch(() => {});
export const ThemeProvider = ({children}: { children: ReactNode }) => {
const { theme, isDark, isHydrated } = useThemeStore();