From 45bc5182ce39660c5952c4db2ae56af6c9705dc7 Mon Sep 17 00:00:00 2001 From: Sean Yesmunt Date: Wed, 13 Jan 2021 11:53:35 -0500 Subject: [PATCH] don't call sync/set for exisitng users that signed in in a different tab this was causing users to lose their subs before the page refreshed --- ui/component/userSignUp/view.jsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ui/component/userSignUp/view.jsx b/ui/component/userSignUp/view.jsx index 98f4ca47b..f034b0b0f 100644 --- a/ui/component/userSignUp/view.jsx +++ b/ui/component/userSignUp/view.jsx @@ -18,6 +18,7 @@ import Spinner from 'component/spinner'; import YoutubeTransferStatus from 'component/youtubeTransferStatus'; import useFetched from 'effects/use-fetched'; import Confetti from 'react-confetti'; +import usePrevious from 'effects/use-previous'; const REDIRECT_PARAM = 'redirect'; const REDIRECT_IMMEDIATELY_PARAM = 'immediate'; @@ -87,6 +88,7 @@ function UserSignUp(props: Props) { const isIdentityVerified = user && user.is_identity_verified; const passwordSet = user && user.password_set; const hasFetchedReward = useFetched(claimingReward); + const previousHasVerifiedEmail = usePrevious(hasVerifiedEmail); const channelCount = channels ? channels.length : 0; const hasClaimedEmailAward = claimedRewards.some(reward => reward.reward_type === REWARDS.TYPE_CONFIRM_EMAIL); const hasYoutubeChannels = youtubeChannels && Boolean(youtubeChannels.length); @@ -134,11 +136,11 @@ function UserSignUp(props: Props) { }, [fetchUser]); React.useEffect(() => { - if (hasVerifiedEmail) { + if (previousHasVerifiedEmail === false && hasVerifiedEmail) { setPrefsReady(); setSettingAndSync(SETTINGS.FIRST_RUN_STARTED, true); } - }, [hasVerifiedEmail, setPrefsReady]); + }, [hasVerifiedEmail, previousHasVerifiedEmail, setPrefsReady]); React.useEffect(() => { // Don't claim the reward if sync is enabled until after a sync has been completed successfully