From 80f24edcb3d0d6bd5d5ea707c60a8e24e41b1a22 Mon Sep 17 00:00:00 2001
From: Sean Yesmunt
Date: Fri, 13 Mar 2020 21:16:19 -0400
Subject: [PATCH] Revert "skip rewards validation on future sign ins if user
clicks 'skip' button"
This reverts commit 8a73cdbc0b62879fb299990635560907bd7cec5d.
---
ui/component/userSignIn/view.jsx | 5 ++---
ui/component/userVerify/view.jsx | 12 +++---------
ui/effects/use-persisted-state.js | 14 ++++++--------
3 files changed, 11 insertions(+), 20 deletions(-)
diff --git a/ui/component/userSignIn/view.jsx b/ui/component/userSignIn/view.jsx
index 65d830a67..a5c25e57c 100644
--- a/ui/component/userSignIn/view.jsx
+++ b/ui/component/userSignIn/view.jsx
@@ -62,7 +62,6 @@ function UserSignIn(props: Props) {
const shouldRedirectImmediately = urlParams.get('immediate');
const [initialSignInStep, setInitialSignInStep] = React.useState();
const [hasSeenFollowList, setHasSeenFollowList] = usePersistedState('channel-follow-intro', false);
- const [hasSkippedRewards, setHasSkippedRewards] = usePersistedState('skip-rewards-intro', false);
const hasVerifiedEmail = user && user.has_verified_email;
const rewardsApproved = user && user.is_reward_approved;
const isIdentityVerified = user && user.is_identity_verified;
@@ -82,7 +81,7 @@ function UserSignIn(props: Props) {
// The possible screens for the sign in flow
const showEmail = !emailToVerify && !hasVerifiedEmail;
const showEmailVerification = emailToVerify && !hasVerifiedEmail;
- const showUserVerification = hasVerifiedEmail && !rewardsApproved && !isIdentityVerified && !hasSkippedRewards;
+ const showUserVerification = hasVerifiedEmail && !rewardsApproved && !isIdentityVerified;
const showSyncPassword = syncEnabled && getSyncError;
const showChannelCreation =
hasVerifiedEmail &&
@@ -120,7 +119,7 @@ function UserSignIn(props: Props) {
const SIGN_IN_FLOW = [
showEmail && ,
showEmailVerification && ,
- showUserVerification && setHasSkippedRewards(true)} />,
+ showUserVerification && ,
showChannelCreation && ,
showFollowIntro && (
void,
fetchUser: () => void,
skipLink?: string,
- onSkip: () => void,
};
class UserVerify extends React.PureComponent {
@@ -29,12 +28,7 @@ class UserVerify extends React.PureComponent {
}
render() {
- const { errorMessage, isPending, verifyPhone, fetchUser, skipLink, onSkip } = this.props;
- const skipButtonProps = {
- onClick: onSkip,
- navigate: skipLink || '/',
- };
-
+ const { errorMessage, isPending, verifyPhone, fetchUser, skipLink } = this.props;
return (
@@ -51,7 +45,7 @@ class UserVerify extends React.PureComponent {
to be validated.
{' '}
{__('This step is not required to use LBRY, and not all users or regions may qualify.')}
@@ -138,7 +132,7 @@ class UserVerify extends React.PureComponent {
subtitle={__('Rewards validation is optional.')}
actions={
-
+
}
/>
diff --git a/ui/effects/use-persisted-state.js b/ui/effects/use-persisted-state.js
index ad58c1de5..c929a45aa 100644
--- a/ui/effects/use-persisted-state.js
+++ b/ui/effects/use-persisted-state.js
@@ -1,4 +1,4 @@
-import { useState } from 'react';
+import { useState, useEffect } from 'react';
export default function usePersistedState(key, firstTimeDefault) {
// If no key is passed in, act as a normal `useState`
@@ -32,13 +32,11 @@ export default function usePersistedState(key, firstTimeDefault) {
const [value, setValue] = useState(defaultValue);
- function setValueAndLocalStorage(newValue) {
- if (key && localStorageAvailable && value !== newValue) {
- localStorage.setItem(key, typeof newValue === 'object' ? JSON.stringify(newValue) : newValue);
+ useEffect(() => {
+ if (key && localStorageAvailable) {
+ localStorage.setItem(key, typeof value === 'object' ? JSON.stringify(value) : value);
}
+ }, [key, value]);
- setValue(newValue);
- }
-
- return [value, setValueAndLocalStorage];
+ return [value, setValue];
}