From f202943adbc956bf5acf0b360d31078b126221fa Mon Sep 17 00:00:00 2001 From: Akinwale Ariwodola Date: Wed, 27 Nov 2019 09:23:37 +0100 Subject: [PATCH] do not prompt new users for a password --- src/component/walletSyncDriver/index.js | 2 +- src/component/walletSyncDriver/view.js | 8 ++++---- src/page/firstRun/internal/wallet-page.js | 17 ++++++++++++++++- src/page/firstRun/view.js | 6 +++++- .../verification/internal/sync-verify-page.js | 12 +++++++++++- 5 files changed, 37 insertions(+), 8 deletions(-) diff --git a/src/component/walletSyncDriver/index.js b/src/component/walletSyncDriver/index.js index 1065158..1812ce2 100644 --- a/src/component/walletSyncDriver/index.js +++ b/src/component/walletSyncDriver/index.js @@ -3,7 +3,7 @@ import { doSetClientSetting } from 'redux/actions/settings'; import { makeSelectClientSetting } from 'redux/selectors/settings'; import { doToast } from 'lbry-redux'; import { selectUserEmail } from 'lbryinc'; -import Constants from 'constants'; +import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api import WalletSyncDriver from './view'; const select = state => ({ diff --git a/src/component/walletSyncDriver/view.js b/src/component/walletSyncDriver/view.js index 799612c..cade63b 100644 --- a/src/component/walletSyncDriver/view.js +++ b/src/component/walletSyncDriver/view.js @@ -1,7 +1,7 @@ import React from 'react'; import { Alert, NativeModules, Switch, Text, View } from 'react-native'; import Button from 'component/button'; -import Constants from 'constants'; +import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api import Link from 'component/link'; import walletStyle from 'styles/wallet'; @@ -43,7 +43,7 @@ class WalletSyncDriver extends React.PureComponent { Sync status - + {deviceWalletSynced ? 'On' : 'Off'} { Connected email - - {userEmail ? userEmail : 'No connected email'} + + {userEmail || 'No connected email'} diff --git a/src/page/firstRun/internal/wallet-page.js b/src/page/firstRun/internal/wallet-page.js index cad1931..aee7348 100644 --- a/src/page/firstRun/internal/wallet-page.js +++ b/src/page/firstRun/internal/wallet-page.js @@ -28,12 +28,26 @@ class WalletPage extends React.PureComponent { walletReady: false, hasCheckedSync: false, revealPassword: false, + autoPassword: false, }; componentDidMount() { this.checkWalletReady(); } + componentDidUpdate() { + const { hasSyncedWallet, getSyncIsPending, onPasswordChanged } = this.props; + if (this.state.walletReady && this.state.hasCheckedSync && !getSyncIsPending) { + if (!hasSyncedWallet && !this.state.autoPassword) { + // new account, in which case, don't ask for a password, and act as the final first run step + this.setState({ password: '', autoPassword: true }); + if (onPasswordChanged) { + onPasswordChanged('', true); + } + } + } + } + checkWalletReady = () => { // make sure the sdk wallet component is ready Lbry.status() @@ -86,7 +100,8 @@ class WalletPage extends React.PureComponent { {syncApplyIsPending ? 'Validating password' : 'Synchronizing'}... ); - } else { + } else if (hasSyncedWallet) { + // only display this view if it's not a new user content = ( Password diff --git a/src/page/firstRun/view.js b/src/page/firstRun/view.js index a136287..60d74f9 100644 --- a/src/page/firstRun/view.js +++ b/src/page/firstRun/view.js @@ -265,8 +265,12 @@ class FirstRunScreen extends React.PureComponent { this.setState({ showBottomContainer: true, showSkip: true }); }; - onWalletPasswordChanged = password => { + onWalletPasswordChanged = (password, finalStep) => { this.setState({ walletPassword: password !== null ? password : '' }); + if (finalStep) { + // final step for a new user + this.setFreshPassword(); + } }; onWalletViewLayout = () => { diff --git a/src/page/verification/internal/sync-verify-page.js b/src/page/verification/internal/sync-verify-page.js index 7990c8a..3054c5d 100644 --- a/src/page/verification/internal/sync-verify-page.js +++ b/src/page/verification/internal/sync-verify-page.js @@ -18,6 +18,7 @@ class SyncVerifyPage extends React.PureComponent { syncApplyStarted: false, syncChecked: false, revealPassword: false, + autoPassword: false, }; componentDidMount() { @@ -79,6 +80,15 @@ class SyncVerifyPage extends React.PureComponent { } } + componentDidUpdate() { + const { hasSyncedWallet } = this.props; + if (this.state.syncChecked && !this.state.autoPassword && !hasSyncedWallet) { + // new user sync, don't prompt for a password + this.setState({ password: '', autoPassword: true }); + this.onEnableSyncPressed(); + } + } + finishSync = (notifyUnlockFailed = false) => { const { navigation, notify, setClientSetting } = this.props; @@ -133,7 +143,7 @@ class SyncVerifyPage extends React.PureComponent { Retrieving your account information... ); - } else { + } else if (hasSyncedWallet) { content = ( Wallet Sync