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
This commit is contained in:
Sean Yesmunt 2021-01-13 11:53:35 -05:00
parent 5435dc88d4
commit 45bc5182ce

View file

@ -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