mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-05-31 20:24:27 -04:00
Fix the connection error retry button
This commit is contained in:
parent
e8d4c128da
commit
6ac8af9946
@ -76,6 +76,7 @@ const ThemedStack = ({ onLayout }: { onLayout?: () => void }) => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let rendered: boolean = false;
|
||||||
|
|
||||||
export default function Root() {
|
export default function Root() {
|
||||||
const [queryClient] = useState(() => createQueryClient());
|
const [queryClient] = useState(() => createQueryClient());
|
||||||
@ -83,7 +84,8 @@ export default function Root() {
|
|||||||
const [fontsLoaded] = useFonts({ Poppins_300Light, Poppins_400Regular, Poppins_900Black });
|
const [fontsLoaded] = useFonts({ Poppins_300Light, Poppins_400Regular, Poppins_900Black });
|
||||||
const info = useAccounts();
|
const info = useAccounts();
|
||||||
|
|
||||||
if (!fontsLoaded || info.type === "loading") return <SplashScreen />;
|
if (!fontsLoaded || (!rendered && info.type === "loading")) return <SplashScreen />;
|
||||||
|
rendered = true;
|
||||||
return (
|
return (
|
||||||
<AccountContext.Provider value={info}>
|
<AccountContext.Provider value={info}>
|
||||||
<QueryClientProvider client={queryClient}>
|
<QueryClientProvider client={queryClient}>
|
||||||
|
@ -34,6 +34,7 @@ export const useAccounts = () => {
|
|||||||
status: "ok" | "error" | "loading" | "unverified";
|
status: "ok" | "error" | "loading" | "unverified";
|
||||||
error?: string;
|
error?: string;
|
||||||
}>({ status: "loading" });
|
}>({ status: "loading" });
|
||||||
|
const [retryCount, setRetryCount] = useState(0);
|
||||||
// TODO: Remember the last selected account.
|
// TODO: Remember the last selected account.
|
||||||
const selected = accounts?.length ? 0 : null;
|
const selected = accounts?.length ? 0 : null;
|
||||||
|
|
||||||
@ -55,7 +56,7 @@ export const useAccounts = () => {
|
|||||||
|
|
||||||
if (accounts && selected !== null) check();
|
if (accounts && selected !== null) check();
|
||||||
else setVerified({status: "unverified"});
|
else setVerified({status: "unverified"});
|
||||||
}, [accounts, selected]);
|
}, [accounts, selected, retryCount]);
|
||||||
|
|
||||||
if (accounts === null || verified.status === "loading") return { type: "loading" } as const;
|
if (accounts === null || verified.status === "loading") return { type: "loading" } as const;
|
||||||
if (accounts !== null && verified.status === "unverified") return { type: "loading" } as const;
|
if (accounts !== null && verified.status === "unverified") return { type: "loading" } as const;
|
||||||
@ -63,7 +64,10 @@ export const useAccounts = () => {
|
|||||||
return {
|
return {
|
||||||
type: "error",
|
type: "error",
|
||||||
error: verified.error,
|
error: verified.error,
|
||||||
retry: () => setVerified({ status: "loading" }),
|
retry: () => {
|
||||||
|
setVerified({ status: "loading" })
|
||||||
|
setRetryCount((x) => x + 1);
|
||||||
|
},
|
||||||
} as const;
|
} as const;
|
||||||
}
|
}
|
||||||
return { type: "ok", accounts, selected } as const;
|
return { type: "ok", accounts, selected } as const;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user