From bec2c4eb4907f0ea228792f4e2adff772affec1c Mon Sep 17 00:00:00 2001 From: Atul Varma Date: Sun, 22 Aug 2021 08:27:49 -0400 Subject: [PATCH] Allow firebase actions to be retried on error. --- lib/auth.tsx | 2 ++ lib/pages/debug-page.tsx | 19 ++++++++++++------- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/lib/auth.tsx b/lib/auth.tsx index 70d41f8..1390e05 100644 --- a/lib/auth.tsx +++ b/lib/auth.tsx @@ -85,9 +85,11 @@ export const FirebaseGithubAuthProvider: React.FC<{ providerName: "GitHub", error, login: useCallback(() => { + setError(undefined); state && signInWithPopup(state.auth, state.provider).catch(handleError); }, [state]), logout: useCallback(() => { + setError(undefined); state && signOut(state.auth).catch(handleError); }, [state]), }; diff --git a/lib/pages/debug-page.tsx b/lib/pages/debug-page.tsx index ef25355..c9e797a 100644 --- a/lib/pages/debug-page.tsx +++ b/lib/pages/debug-page.tsx @@ -101,15 +101,20 @@ const AuthWidget: React.FC<{}> = () => { return null; } - if (ctx.error) { - return

{ctx.error}

; - } + const button = ctx.loggedInUser ? ( + + ) : ( + + ); - if (ctx.loggedInUser) { - return ; - } + const error = ctx.error ?

{ctx.error}

: null; - return ; + return ( +
+ {button} + {error} +
+ ); }; export const DebugPage: React.FC<{}> = () => {