diff --git a/front/apps/mobile/app/(app)/_layout.tsx b/front/apps/mobile/app/(app)/_layout.tsx index 77e0e436..fd46a357 100644 --- a/front/apps/mobile/app/(app)/_layout.tsx +++ b/front/apps/mobile/app/(app)/_layout.tsx @@ -19,12 +19,10 @@ */ import { ConnectionErrorContext, useAccount } from "@kyoo/models"; -import { CircularProgress } from "@kyoo/primitives"; import { NavbarRight, NavbarTitle } from "@kyoo/ui"; import { useNetInfo } from "@react-native-community/netinfo"; import { Redirect, Stack } from "expo-router"; -import * as SplashScreen from "expo-splash-screen"; -import { useContext, useEffect } from "react"; +import { useContext } from "react"; import { useSafeAreaInsets } from "react-native-safe-area-context"; import { useTheme } from "yoshiki/native"; @@ -33,14 +31,9 @@ export default function SignGuard() { const theme = useTheme(); // TODO: support guest accounts on mobile too. const account = useAccount(); - const { loading, error } = useContext(ConnectionErrorContext); + const { error } = useContext(ConnectionErrorContext); const netInfo = useNetInfo(); - useEffect(() => { - if (!loading) SplashScreen.hideAsync(); - }, [loading]); - - if (loading) return ; if (error && netInfo.isConnected) return ; if (!account) return ; return ( diff --git a/front/apps/mobile/app/_layout.tsx b/front/apps/mobile/app/_layout.tsx index 7498b818..efb767ec 100644 --- a/front/apps/mobile/app/_layout.tsx +++ b/front/apps/mobile/app/_layout.tsx @@ -36,7 +36,7 @@ import { Poppins_400Regular, Poppins_900Black, } from "@expo-google-fonts/poppins"; -import { ReactNode, useState } from "react"; +import { ReactNode, useEffect, useState } from "react"; import { useColorScheme } from "react-native"; import { initReactI18next } from "react-i18next"; import { ThemeProvider as RNThemeProvider } from "@react-navigation/native"; @@ -117,6 +117,10 @@ export default function Root() { if (theme === "auto") theme = systemTheme ?? "light"; + useEffect(() => { + if (fontsLoaded) SplashScreen.hideAsync(); + }, [fontsLoaded]); + if (!fontsLoaded) return null; return ( { accounts[idx] = account; writeAccounts(accounts); }; - -export const unselectAllAccounts = () => { - const accounts = readAccounts(); - for (const acc of accounts) acc.selected = false; - writeAccounts(accounts); -}; diff --git a/front/packages/models/src/accounts.tsx b/front/packages/models/src/accounts.tsx index 86d34586..bffdabce 100644 --- a/front/packages/models/src/accounts.tsx +++ b/front/packages/models/src/accounts.tsx @@ -136,7 +136,7 @@ export const AccountProvider = ({ { queryClient.invalidateQueries({ queryKey: ["auth", "me"] }); diff --git a/front/packages/models/src/login.ts b/front/packages/models/src/login.ts index 80815b42..b1cd1e2c 100644 --- a/front/packages/models/src/login.ts +++ b/front/packages/models/src/login.ts @@ -26,7 +26,6 @@ import { addAccount, getCurrentAccount, removeAccounts, - unselectAllAccounts, updateAccount, } from "./account-internal"; import { Platform } from "react-native"; @@ -38,7 +37,6 @@ type Result = export const login = async ( action: "register" | "login", { apiUrl, ...body }: { username: string; password: string; email?: string; apiUrl?: string }, - timeout?: number, ): Promise> => { try { const controller = new AbortController(); @@ -117,7 +115,6 @@ export const getTokenWJ = async (account?: Account | null): ReturnType( type?: Parser, token?: string | null, ): Promise> => { - const url = context.apiUrl ?? (Platform.OS === "web" ? kyooUrl : getCurrentAccount()!.apiUrl); + const url = context.apiUrl ?? (Platform.OS === "web" ? kyooUrl : getCurrentAccount()?.apiUrl); kyooApiUrl = url; if (token === undefined && context.authenticated !== false) token = await getToken(); diff --git a/front/packages/ui/src/errors/error.tsx b/front/packages/ui/src/errors/error.tsx index ccf3cefa..51b48d11 100644 --- a/front/packages/ui/src/errors/error.tsx +++ b/front/packages/ui/src/errors/error.tsx @@ -26,6 +26,7 @@ import { useYoshiki } from "yoshiki/native"; export const ErrorView = ({ error }: { error: KyooErrors }) => { const { css } = useYoshiki(); + console.log(error) return (