mirror of
https://github.com/zimplexing/OrionTV.git
synced 2026-02-16 13:14:46 +08:00
fix(init): resolve startup error message timing issue
Fix race condition where 'please check network or server address' error was shown on first startup even when API was properly configured. - Add isLoadingServerConfig state to track server config fetch status - Modify authStore to wait for server config loading before showing errors - Ensure loadSettings completes fully before triggering login checks - Only show network error when config fetch actually fails, not during loading
This commit is contained in:
@@ -13,7 +13,6 @@ import useAuthStore from "@/stores/authStore";
|
||||
import { useUpdateStore, initUpdateStore } from "@/stores/updateStore";
|
||||
import { UpdateModal } from "@/components/UpdateModal";
|
||||
import { UPDATE_CONFIG } from "@/constants/UpdateConfig";
|
||||
import MobileBottomNavigation from "@/components/MobileBottomNavigation";
|
||||
import { useResponsiveLayout } from "@/hooks/useResponsiveLayout";
|
||||
|
||||
// Prevent the splash screen from auto-hiding before asset loading is complete.
|
||||
@@ -31,7 +30,10 @@ export default function RootLayout() {
|
||||
const responsiveConfig = useResponsiveLayout();
|
||||
|
||||
useEffect(() => {
|
||||
loadSettings();
|
||||
const initializeApp = async () => {
|
||||
await loadSettings();
|
||||
};
|
||||
initializeApp();
|
||||
initUpdateStore(); // 初始化更新存储
|
||||
}, [loadSettings]);
|
||||
|
||||
@@ -73,8 +75,6 @@ export default function RootLayout() {
|
||||
return null;
|
||||
}
|
||||
|
||||
const isMobile = responsiveConfig.deviceType === 'mobile';
|
||||
|
||||
return (
|
||||
<ThemeProvider value={colorScheme === "dark" ? DarkTheme : DefaultTheme}>
|
||||
<View style={styles.container}>
|
||||
@@ -88,7 +88,6 @@ export default function RootLayout() {
|
||||
<Stack.Screen name="favorites" options={{ headerShown: false }} />
|
||||
<Stack.Screen name="+not-found" />
|
||||
</Stack>
|
||||
{isMobile && <MobileBottomNavigation colorScheme={colorScheme} />}
|
||||
</View>
|
||||
<Toast />
|
||||
<LoginModal />
|
||||
|
||||
Reference in New Issue
Block a user