nice loading states and stuff

This commit is contained in:
talksik
2022-05-28 12:22:22 -05:00
parent 08a174b34e
commit f90756c81b
@@ -64,6 +64,8 @@ export const AuthProvider = ({ children }: { children: React.ReactNode }) => {
const tokenListener = window.electronAPI.once( const tokenListener = window.electronAPI.once(
Channels.GOOGLE_AUTH_TOKENS, Channels.GOOGLE_AUTH_TOKENS,
async (tokens: Credentials) => { async (tokens: Credentials) => {
setAuthIniting(true);
console.log('got tokens', tokens); console.log('got tokens', tokens);
const credential = GoogleAuthProvider.credential(tokens.id_token); const credential = GoogleAuthProvider.credential(tokens.id_token);
@@ -84,6 +86,8 @@ export const AuthProvider = ({ children }: { children: React.ReactNode }) => {
}); });
}) })
.catch((error: any) => { .catch((error: any) => {
setAuthIniting(false);
// Handle Errors here. // Handle Errors here.
const errorCode = error.code; const errorCode = error.code;
const errorMessage = error.message; const errorMessage = error.message;
@@ -99,7 +103,7 @@ export const AuthProvider = ({ children }: { children: React.ReactNode }) => {
); );
return () => tokenListener(); return () => tokenListener();
}, [enqueueSnackbar]); }, [enqueueSnackbar, setAuthIniting]);
const logout = useCallback(() => firebaseAuth.signOut(), []); const logout = useCallback(() => firebaseAuth.signOut(), []);