Set default account upon wallet sync restore (#556)
This commit is contained in:
parent
67d4e97582
commit
5fc2e1247b
5 changed files with 19 additions and 13 deletions
|
@ -4,6 +4,7 @@ import {
|
||||||
doAuthenticate,
|
doAuthenticate,
|
||||||
doCheckSync,
|
doCheckSync,
|
||||||
doGetSync,
|
doGetSync,
|
||||||
|
doSetDefaultAccount,
|
||||||
doSyncApply,
|
doSyncApply,
|
||||||
doUserEmailNew,
|
doUserEmailNew,
|
||||||
doUserResendVerificationEmail,
|
doUserResendVerificationEmail,
|
||||||
|
@ -45,6 +46,7 @@ const perform = dispatch => ({
|
||||||
syncApply: (hash, data, password) => dispatch(doSyncApply(hash, data, password)),
|
syncApply: (hash, data, password) => dispatch(doSyncApply(hash, data, password)),
|
||||||
getSync: password => dispatch(doGetSync(password)),
|
getSync: password => dispatch(doGetSync(password)),
|
||||||
checkSync: () => dispatch(doCheckSync()),
|
checkSync: () => dispatch(doCheckSync()),
|
||||||
|
setDefaultAccount: () => dispatch(doSetDefaultAccount()),
|
||||||
notify: data => dispatch(doToast(data)),
|
notify: data => dispatch(doToast(data)),
|
||||||
resendVerificationEmail: email => dispatch(doUserResendVerificationEmail(email))
|
resendVerificationEmail: email => dispatch(doUserResendVerificationEmail(email))
|
||||||
});
|
});
|
||||||
|
|
|
@ -67,7 +67,7 @@ class FirstRunScreen extends React.PureComponent {
|
||||||
|
|
||||||
componentWillReceiveProps(nextProps) {
|
componentWillReceiveProps(nextProps) {
|
||||||
const { emailNewErrorMessage, emailNewPending, syncApplyErrorMessage, syncApplyIsPending, user } = nextProps;
|
const { emailNewErrorMessage, emailNewPending, syncApplyErrorMessage, syncApplyIsPending, user } = nextProps;
|
||||||
const { notify, isApplyingSync, setClientSetting } = this.props;
|
const { notify, isApplyingSync, setClientSetting, setDefaultAccount } = this.props;
|
||||||
|
|
||||||
if (this.state.emailSubmitted && !emailNewPending) {
|
if (this.state.emailSubmitted && !emailNewPending) {
|
||||||
this.setState({ emailSubmitted: false });
|
this.setState({ emailSubmitted: false });
|
||||||
|
@ -89,6 +89,7 @@ class FirstRunScreen extends React.PureComponent {
|
||||||
if (NativeModules.UtilityModule) {
|
if (NativeModules.UtilityModule) {
|
||||||
NativeModules.UtilityModule.setSecureValue(Constants.KEY_FIRST_RUN_PASSWORD, this.state.walletPassword);
|
NativeModules.UtilityModule.setSecureValue(Constants.KEY_FIRST_RUN_PASSWORD, this.state.walletPassword);
|
||||||
}
|
}
|
||||||
|
setDefaultAccount();
|
||||||
setClientSetting(Constants.SETTING_DEVICE_WALLET_SYNCED, true);
|
setClientSetting(Constants.SETTING_DEVICE_WALLET_SYNCED, true);
|
||||||
this.closeFinalPage();
|
this.closeFinalPage();
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ import { doToast } from 'lbry-redux';
|
||||||
import {
|
import {
|
||||||
doCheckSync,
|
doCheckSync,
|
||||||
doGetSync,
|
doGetSync,
|
||||||
|
doSetDefaultAccount,
|
||||||
doSyncApply,
|
doSyncApply,
|
||||||
doUserEmailNew,
|
doUserEmailNew,
|
||||||
doUserEmailToVerify,
|
doUserEmailToVerify,
|
||||||
|
@ -59,6 +60,7 @@ const perform = dispatch => ({
|
||||||
verifyPhone: (verificationCode) => dispatch(doUserPhoneVerify(verificationCode)),
|
verifyPhone: (verificationCode) => dispatch(doUserPhoneVerify(verificationCode)),
|
||||||
notify: data => dispatch(doToast(data)),
|
notify: data => dispatch(doToast(data)),
|
||||||
setClientSetting: (key, value) => dispatch(doSetClientSetting(key, value)),
|
setClientSetting: (key, value) => dispatch(doSetClientSetting(key, value)),
|
||||||
|
setDefaultAccount: () => dispatch(doSetDefaultAccount()),
|
||||||
setEmailToVerify: email => dispatch(doUserEmailToVerify(email)),
|
setEmailToVerify: email => dispatch(doUserEmailToVerify(email)),
|
||||||
syncApply: (hash, data, password) => dispatch(doSyncApply(hash, data, password)),
|
syncApply: (hash, data, password) => dispatch(doSyncApply(hash, data, password)),
|
||||||
resendVerificationEmail: email => dispatch(doUserResendVerificationEmail(email)),
|
resendVerificationEmail: email => dispatch(doUserResendVerificationEmail(email)),
|
||||||
|
|
|
@ -68,7 +68,7 @@ class SyncVerifyPage extends React.PureComponent {
|
||||||
|
|
||||||
componentWillReceiveProps(nextProps) {
|
componentWillReceiveProps(nextProps) {
|
||||||
const { getSyncIsPending, syncApplyIsPending, syncApplyErrorMessage } = nextProps;
|
const { getSyncIsPending, syncApplyIsPending, syncApplyErrorMessage } = nextProps;
|
||||||
const { getSync, setClientSetting, navigation, notify, hasSyncedWallet } = this.props;
|
const { getSync, hasSyncedWallet, navigation, notify, setClientSetting, setDefaultAccount } = this.props;
|
||||||
if (this.state.checkSyncStarted && !getSyncIsPending) {
|
if (this.state.checkSyncStarted && !getSyncIsPending) {
|
||||||
this.setState({ syncChecked: true });
|
this.setState({ syncChecked: true });
|
||||||
}
|
}
|
||||||
|
@ -82,6 +82,7 @@ class SyncVerifyPage extends React.PureComponent {
|
||||||
if (NativeModules.UtilityModule) {
|
if (NativeModules.UtilityModule) {
|
||||||
NativeModules.UtilityModule.setSecureValue(Constants.KEY_FIRST_RUN_PASSWORD, this.state.password);
|
NativeModules.UtilityModule.setSecureValue(Constants.KEY_FIRST_RUN_PASSWORD, this.state.password);
|
||||||
}
|
}
|
||||||
|
setDefaultAccount();
|
||||||
setClientSetting(Constants.SETTING_DEVICE_WALLET_SYNCED, true);
|
setClientSetting(Constants.SETTING_DEVICE_WALLET_SYNCED, true);
|
||||||
navigation.goBack();
|
navigation.goBack();
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,6 +60,10 @@ class VerificationScreen extends React.PureComponent {
|
||||||
if (this.state.isEmailVerified && !deviceWalletSynced) {
|
if (this.state.isEmailVerified && !deviceWalletSynced) {
|
||||||
this.setState({ currentPage: 'syncVerify' });
|
this.setState({ currentPage: 'syncVerify' });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.state.isEmailVerified && syncFlow && deviceWalletSynced) {
|
||||||
|
navigation.goBack();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if (this.state.isEmailVerified && !this.state.isIdentityVerified && !this.state.isRewardApproved) {
|
if (this.state.isEmailVerified && !this.state.isIdentityVerified && !this.state.isRewardApproved) {
|
||||||
this.setState({ currentPage: 'phoneVerify' });
|
this.setState({ currentPage: 'phoneVerify' });
|
||||||
|
@ -67,17 +71,11 @@ class VerificationScreen extends React.PureComponent {
|
||||||
if (this.state.isEmailVerified && this.state.isIdentityVerified && !this.state.isRewardApproved) {
|
if (this.state.isEmailVerified && this.state.isIdentityVerified && !this.state.isRewardApproved) {
|
||||||
this.setState({ currentPage: 'manualVerify' });
|
this.setState({ currentPage: 'manualVerify' });
|
||||||
}
|
}
|
||||||
}
|
if (this.state.isEmailVerified && this.state.isRewardApproved) {
|
||||||
|
// verification steps already completed
|
||||||
if (this.state.isEmailVerified && syncFlow && deviceWalletSynced) {
|
// simply navigate back to the rewards page
|
||||||
navigation.goBack();
|
navigation.goBack();
|
||||||
return;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (this.state.isEmailVerified && this.state.isRewardApproved) {
|
|
||||||
// verification steps already completed
|
|
||||||
// simply navigate back to the rewards page
|
|
||||||
navigation.goBack();
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -104,6 +102,7 @@ class VerificationScreen extends React.PureComponent {
|
||||||
notify,
|
notify,
|
||||||
addUserPhone,
|
addUserPhone,
|
||||||
getSyncIsPending,
|
getSyncIsPending,
|
||||||
|
setDefaultAccount,
|
||||||
hasSyncedWallet,
|
hasSyncedWallet,
|
||||||
setSyncIsPending,
|
setSyncIsPending,
|
||||||
syncApplyIsPending,
|
syncApplyIsPending,
|
||||||
|
@ -164,6 +163,7 @@ class VerificationScreen extends React.PureComponent {
|
||||||
notify={notify}
|
notify={notify}
|
||||||
setEmailVerificationPhase={this.setEmailVerificationPhase}
|
setEmailVerificationPhase={this.setEmailVerificationPhase}
|
||||||
setClientSetting={setClientSetting}
|
setClientSetting={setClientSetting}
|
||||||
|
setDefaultAccount={setDefaultAccount}
|
||||||
setSyncIsPending={setSyncIsPending}
|
setSyncIsPending={setSyncIsPending}
|
||||||
syncApplyIsPending={syncApplyIsPending}
|
syncApplyIsPending={syncApplyIsPending}
|
||||||
syncApplyErrorMessage={syncApplyErrorMessage}
|
syncApplyErrorMessage={syncApplyErrorMessage}
|
||||||
|
|
Loading…
Reference in a new issue