From 5db9e95a57f457cfc364c16d8fd29bfa6115d45a Mon Sep 17 00:00:00 2001 From: LauraPinilla Date: Mon, 29 Jul 2024 15:57:52 -0600 Subject: [PATCH] attending feedback --- .../social-sign-on/_children/GoogleSignIn.jsx | 2 +- .../social-sign-on/utils/useSocialSignIn.js | 13 ++++--------- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/blocks/identity-block/components/social-sign-on/_children/GoogleSignIn.jsx b/blocks/identity-block/components/social-sign-on/_children/GoogleSignIn.jsx index 159eb2e5f..fef109ebb 100644 --- a/blocks/identity-block/components/social-sign-on/_children/GoogleSignIn.jsx +++ b/blocks/identity-block/components/social-sign-on/_children/GoogleSignIn.jsx @@ -18,7 +18,7 @@ function GoogleSignIn({ customButtons, socialSignOnIn, className }) { iconLeft={GoogleIcon} className={`${className}__Google`} onClick={() => - window.google.accounts.id.prompt((notification) => { + window?.google?.accounts?.id?.prompt((notification) => { if (notification.isSkippedMoment()) { // https://developers.google.com/identity/gsi/web/reference/js-reference // https://developers.google.com/identity/gsi/web/guides/features#exponential_cooldown diff --git a/blocks/identity-block/components/social-sign-on/utils/useSocialSignIn.js b/blocks/identity-block/components/social-sign-on/utils/useSocialSignIn.js index 4a5abb165..4bf7692ed 100644 --- a/blocks/identity-block/components/social-sign-on/utils/useSocialSignIn.js +++ b/blocks/identity-block/components/social-sign-on/utils/useSocialSignIn.js @@ -133,22 +133,21 @@ function useSocialSignIn( }, [Identity, config.facebookAppId, customButtons]); useEffect(() => { + let timeout; const checkIsLoggedIn = () => { - const timeout = setTimeout(() => { + timeout = setTimeout(() => { Identity.isLoggedIn().then((isLoggedIn) => { if (isLoggedIn) { window.location = validateURL(redirectURL); } }); }, 1500); - return () => clearTimeout(timeout) }; const setIdentityUpdated = () => { - const timeout = setTimeout(() => { + timeout = setTimeout(() => { setUpdateIdentities((prev) => !prev); }, 1500); - return () => clearTimeout(timeout) }; if (customButtons && isFBInitialized && !isFBEventSubscribed && window?.FB?.Event) { @@ -163,6 +162,7 @@ function useSocialSignIn( } }); } + return () => clearTimeout(timeout); }, [ isFBInitialized, isFBEventSubscribed, @@ -174,11 +174,6 @@ function useSocialSignIn( redirectURL, ]); - - - - - return { // if facebook and google setup with subs, // then they will have a truthy value here