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 { 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 => ({

View file

@ -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<Props> {
<Text style={walletStyle.labelText}>Sync status</Text>
</View>
<View style={walletStyle.tableColRow}>
<Text selectable={true} style={walletStyle.valueText}>
<Text selectable style={walletStyle.valueText}>
{deviceWalletSynced ? 'On' : 'Off'}
</Text>
<Switch
@ -59,8 +59,8 @@ class WalletSyncDriver extends React.PureComponent<Props> {
<Text style={walletStyle.labelText}>Connected email</Text>
</View>
<View style={walletStyle.tableCol}>
<Text selectable={true} style={walletStyle.valueText}>
{userEmail ? userEmail : 'No connected email'}
<Text selectable style={walletStyle.valueText} numberOfLines={1}>
{userEmail || 'No connected email'}
</Text>
</View>
</View>

View file

@ -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 {
<Text style={firstRunStyle.paragraph}>{syncApplyIsPending ? 'Validating password' : 'Synchronizing'}...</Text>
</View>
);
} else {
} else if (hasSyncedWallet) {
// only display this view if it's not a new user
content = (
<View onLayout={onWalletViewLayout}>
<Text style={firstRunStyle.title}>Password</Text>

View file

@ -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 = () => {

View file

@ -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 {
<Text style={firstRunStyle.paragraph}>Retrieving your account information...</Text>
</View>
);
} else {
} else if (hasSyncedWallet) {
content = (
<View>
<Text style={rewardStyle.verificationTitle}>Wallet Sync</Text>