mirror of
				https://github.com/zoriya/Kyoo.git
				synced 2025-11-03 19:17:16 -05: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() {
 | 
			
		||||
	const [queryClient] = useState(() => createQueryClient());
 | 
			
		||||
@ -83,7 +84,8 @@ export default function Root() {
 | 
			
		||||
	const [fontsLoaded] = useFonts({ Poppins_300Light, Poppins_400Regular, Poppins_900Black });
 | 
			
		||||
	const info = useAccounts();
 | 
			
		||||
 | 
			
		||||
	if (!fontsLoaded || info.type === "loading") return <SplashScreen />;
 | 
			
		||||
	if (!fontsLoaded || (!rendered && info.type === "loading")) return <SplashScreen />;
 | 
			
		||||
	rendered = true;
 | 
			
		||||
	return (
 | 
			
		||||
		<AccountContext.Provider value={info}>
 | 
			
		||||
			<QueryClientProvider client={queryClient}>
 | 
			
		||||
 | 
			
		||||
@ -34,6 +34,7 @@ export const useAccounts = () => {
 | 
			
		||||
		status: "ok" | "error" | "loading" | "unverified";
 | 
			
		||||
		error?: string;
 | 
			
		||||
	}>({ status: "loading" });
 | 
			
		||||
	const [retryCount, setRetryCount] = useState(0);
 | 
			
		||||
	// TODO: Remember the last selected account.
 | 
			
		||||
	const selected = accounts?.length ? 0 : null;
 | 
			
		||||
 | 
			
		||||
@ -55,7 +56,7 @@ export const useAccounts = () => {
 | 
			
		||||
 | 
			
		||||
		if (accounts && selected !== null) check();
 | 
			
		||||
		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 === "unverified") return { type: "loading" } as const;
 | 
			
		||||
@ -63,7 +64,10 @@ export const useAccounts = () => {
 | 
			
		||||
		return {
 | 
			
		||||
			type: "error",
 | 
			
		||||
			error: verified.error,
 | 
			
		||||
			retry: () => setVerified({ status: "loading" }),
 | 
			
		||||
			retry: () => {
 | 
			
		||||
				setVerified({ status: "loading" })
 | 
			
		||||
				setRetryCount((x) => x + 1);
 | 
			
		||||
			},
 | 
			
		||||
		} as const;
 | 
			
		||||
	}
 | 
			
		||||
	return { type: "ok", accounts, selected } as const;
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user