do not prompt new users for a password

This commit is contained in:
Akinwale Ariwodola 2019-11-27 09:23:37 +01:00
parent bc04f7105b
commit f202943adb
5 changed files with 37 additions and 8 deletions

View file

@ -3,7 +3,7 @@ import { doSetClientSetting } from 'redux/actions/settings';
import { makeSelectClientSetting } from 'redux/selectors/settings'; import { makeSelectClientSetting } from 'redux/selectors/settings';
import { doToast } from 'lbry-redux'; import { doToast } from 'lbry-redux';
import { selectUserEmail } from 'lbryinc'; import { selectUserEmail } from 'lbryinc';
import Constants from 'constants'; import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api
import WalletSyncDriver from './view'; import WalletSyncDriver from './view';
const select = state => ({ const select = state => ({

View file

@ -1,7 +1,7 @@
import React from 'react'; import React from 'react';
import { Alert, NativeModules, Switch, Text, View } from 'react-native'; import { Alert, NativeModules, Switch, Text, View } from 'react-native';
import Button from 'component/button'; 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 Link from 'component/link';
import walletStyle from 'styles/wallet'; import walletStyle from 'styles/wallet';
@ -43,7 +43,7 @@ class WalletSyncDriver extends React.PureComponent<Props> {
<Text style={walletStyle.labelText}>Sync status</Text> <Text style={walletStyle.labelText}>Sync status</Text>
</View> </View>
<View style={walletStyle.tableColRow}> <View style={walletStyle.tableColRow}>
<Text selectable={true} style={walletStyle.valueText}> <Text selectable style={walletStyle.valueText}>
{deviceWalletSynced ? 'On' : 'Off'} {deviceWalletSynced ? 'On' : 'Off'}
</Text> </Text>
<Switch <Switch
@ -59,8 +59,8 @@ class WalletSyncDriver extends React.PureComponent<Props> {
<Text style={walletStyle.labelText}>Connected email</Text> <Text style={walletStyle.labelText}>Connected email</Text>
</View> </View>
<View style={walletStyle.tableCol}> <View style={walletStyle.tableCol}>
<Text selectable={true} style={walletStyle.valueText}> <Text selectable style={walletStyle.valueText} numberOfLines={1}>
{userEmail ? userEmail : 'No connected email'} {userEmail || 'No connected email'}
</Text> </Text>
</View> </View>
</View> </View>

View file

@ -28,12 +28,26 @@ class WalletPage extends React.PureComponent {
walletReady: false, walletReady: false,
hasCheckedSync: false, hasCheckedSync: false,
revealPassword: false, revealPassword: false,
autoPassword: false,
}; };
componentDidMount() { componentDidMount() {
this.checkWalletReady(); 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 = () => { checkWalletReady = () => {
// make sure the sdk wallet component is ready // make sure the sdk wallet component is ready
Lbry.status() Lbry.status()
@ -86,7 +100,8 @@ class WalletPage extends React.PureComponent {
<Text style={firstRunStyle.paragraph}>{syncApplyIsPending ? 'Validating password' : 'Synchronizing'}...</Text> <Text style={firstRunStyle.paragraph}>{syncApplyIsPending ? 'Validating password' : 'Synchronizing'}...</Text>
</View> </View>
); );
} else { } else if (hasSyncedWallet) {
// only display this view if it's not a new user
content = ( content = (
<View onLayout={onWalletViewLayout}> <View onLayout={onWalletViewLayout}>
<Text style={firstRunStyle.title}>Password</Text> <Text style={firstRunStyle.title}>Password</Text>

View file

@ -265,8 +265,12 @@ class FirstRunScreen extends React.PureComponent {
this.setState({ showBottomContainer: true, showSkip: true }); this.setState({ showBottomContainer: true, showSkip: true });
}; };
onWalletPasswordChanged = password => { onWalletPasswordChanged = (password, finalStep) => {
this.setState({ walletPassword: password !== null ? password : '' }); this.setState({ walletPassword: password !== null ? password : '' });
if (finalStep) {
// final step for a new user
this.setFreshPassword();
}
}; };
onWalletViewLayout = () => { onWalletViewLayout = () => {

View file

@ -18,6 +18,7 @@ class SyncVerifyPage extends React.PureComponent {
syncApplyStarted: false, syncApplyStarted: false,
syncChecked: false, syncChecked: false,
revealPassword: false, revealPassword: false,
autoPassword: false,
}; };
componentDidMount() { 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) => { finishSync = (notifyUnlockFailed = false) => {
const { navigation, notify, setClientSetting } = this.props; const { navigation, notify, setClientSetting } = this.props;
@ -133,7 +143,7 @@ class SyncVerifyPage extends React.PureComponent {
<Text style={firstRunStyle.paragraph}>Retrieving your account information...</Text> <Text style={firstRunStyle.paragraph}>Retrieving your account information...</Text>
</View> </View>
); );
} else { } else if (hasSyncedWallet) {
content = ( content = (
<View> <View>
<Text style={rewardStyle.verificationTitle}>Wallet Sync</Text> <Text style={rewardStyle.verificationTitle}>Wallet Sync</Text>