Merge pull request #77 from lbryio/sync-after-signin
restore user preferences after in-app sign in flow
This commit is contained in:
commit
2e3e1a1250
7 changed files with 48 additions and 11 deletions
|
@ -54,7 +54,11 @@ class DrawerContent extends React.PureComponent {
|
||||||
launchSignInFlow = () => {
|
launchSignInFlow = () => {
|
||||||
// for now, sync flow (email, then password input) will be the default sign in flow
|
// for now, sync flow (email, then password input) will be the default sign in flow
|
||||||
const { navigation } = this.props;
|
const { navigation } = this.props;
|
||||||
navigation.navigate({ routeName: 'Verification', key: 'verification', params: { syncFlow: true } });
|
navigation.navigate({
|
||||||
|
routeName: 'Verification',
|
||||||
|
key: 'verification',
|
||||||
|
params: { syncFlow: true, signInFlow: true },
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
|
|
@ -16,7 +16,11 @@ class WalletSignIn extends React.Component {
|
||||||
|
|
||||||
onSignInPressed = () => {
|
onSignInPressed = () => {
|
||||||
const { navigation } = this.props;
|
const { navigation } = this.props;
|
||||||
navigation.navigate({ routeName: 'Verification', key: 'verification', params: { syncFlow: true } });
|
navigation.navigate({
|
||||||
|
routeName: 'Verification',
|
||||||
|
key: 'verification',
|
||||||
|
params: { syncFlow: true, signInFlow: true },
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
|
|
@ -159,7 +159,6 @@ class SplashScreen extends React.PureComponent {
|
||||||
this.setState({ shouldAuthenticate: true });
|
this.setState({ shouldAuthenticate: true });
|
||||||
NativeModules.Firebase.getMessagingToken()
|
NativeModules.Firebase.getMessagingToken()
|
||||||
.then(firebaseToken => {
|
.then(firebaseToken => {
|
||||||
console.log(firebaseToken);
|
|
||||||
authenticate(appVersion, Platform.OS, firebaseToken);
|
authenticate(appVersion, Platform.OS, firebaseToken);
|
||||||
})
|
})
|
||||||
.catch(() => authenticate(appVersion, Platform.OS));
|
.catch(() => authenticate(appVersion, Platform.OS));
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import { doToast } from 'lbry-redux';
|
import { doToast, doPopulateSharedUserState } from 'lbry-redux';
|
||||||
import {
|
import {
|
||||||
doCheckSync,
|
doCheckSync,
|
||||||
doGetSync,
|
doGetSync,
|
||||||
|
@ -58,6 +58,7 @@ const perform = dispatch => ({
|
||||||
checkSync: () => dispatch(doCheckSync()),
|
checkSync: () => dispatch(doCheckSync()),
|
||||||
verifyPhone: verificationCode => dispatch(doUserPhoneVerify(verificationCode)),
|
verifyPhone: verificationCode => dispatch(doUserPhoneVerify(verificationCode)),
|
||||||
notify: data => dispatch(doToast(data)),
|
notify: data => dispatch(doToast(data)),
|
||||||
|
populateSharedUserState: settings => dispatch(doPopulateSharedUserState(settings)),
|
||||||
setClientSetting: (key, value) => dispatch(doSetClientSetting(key, value)),
|
setClientSetting: (key, value) => dispatch(doSetClientSetting(key, value)),
|
||||||
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)),
|
||||||
|
|
|
@ -112,7 +112,7 @@ class SyncVerifyPage extends React.PureComponent {
|
||||||
};
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { hasSyncedWallet, syncApplyIsPending } = this.props;
|
const { hasSyncedWallet, syncApplyIsPending, signInFlow } = this.props;
|
||||||
|
|
||||||
let paragraph;
|
let paragraph;
|
||||||
if (!hasSyncedWallet) {
|
if (!hasSyncedWallet) {
|
||||||
|
@ -194,7 +194,7 @@ class SyncVerifyPage extends React.PureComponent {
|
||||||
<Button
|
<Button
|
||||||
style={rewardStyle.verificationButton}
|
style={rewardStyle.verificationButton}
|
||||||
theme={'light'}
|
theme={'light'}
|
||||||
text={'Enable sync'}
|
text={signInFlow ? 'Use LBRY' : 'Enable sync'}
|
||||||
onPress={this.onEnableSyncPressed}
|
onPress={this.onEnableSyncPressed}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { Lbry } from 'lbry-redux';
|
import { Lbry, doPreferenceGet } from 'lbry-redux';
|
||||||
import { ActivityIndicator, Linking, NativeModules, Text, TouchableOpacity, View } from 'react-native';
|
import { ActivityIndicator, Linking, NativeModules, Text, TouchableOpacity, View } from 'react-native';
|
||||||
import { NavigationActions, StackActions } from 'react-navigation';
|
import { NavigationActions, StackActions } from 'react-navigation';
|
||||||
import AsyncStorage from '@react-native-community/async-storage';
|
import AsyncStorage from '@react-native-community/async-storage';
|
||||||
import Colors from 'styles/colors';
|
import Colors from 'styles/colors';
|
||||||
import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api
|
import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api
|
||||||
|
import Icon from 'react-native-vector-icons/FontAwesome5';
|
||||||
import EmailVerifyPage from './internal/email-verify-page';
|
import EmailVerifyPage from './internal/email-verify-page';
|
||||||
import ManualVerifyPage from './internal/manual-verify-page';
|
import ManualVerifyPage from './internal/manual-verify-page';
|
||||||
import PhoneVerifyPage from './internal/phone-verify-page';
|
import PhoneVerifyPage from './internal/phone-verify-page';
|
||||||
|
@ -19,6 +20,7 @@ class VerificationScreen extends React.PureComponent {
|
||||||
showSkip: false,
|
showSkip: false,
|
||||||
skipAccountConfirmed: false,
|
skipAccountConfirmed: false,
|
||||||
showBottomContainer: true,
|
showBottomContainer: true,
|
||||||
|
signInFlow: false,
|
||||||
walletPassword: null,
|
walletPassword: null,
|
||||||
isEmailVerificationPhase: false,
|
isEmailVerificationPhase: false,
|
||||||
isEmailVerified: false,
|
isEmailVerified: false,
|
||||||
|
@ -27,7 +29,9 @@ class VerificationScreen extends React.PureComponent {
|
||||||
};
|
};
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
const { user } = this.props;
|
const { user, navigation } = this.props;
|
||||||
|
const { signInFlow } = navigation.state.params;
|
||||||
|
this.setState({ signInFlow });
|
||||||
this.checkVerificationStatus(user);
|
this.checkVerificationStatus(user);
|
||||||
NativeModules.Firebase.setCurrentScreen('Verification');
|
NativeModules.Firebase.setCurrentScreen('Verification');
|
||||||
}
|
}
|
||||||
|
@ -36,8 +40,22 @@ class VerificationScreen extends React.PureComponent {
|
||||||
this.setState({ isEmailVerificationPhase: value });
|
this.setState({ isEmailVerificationPhase: value });
|
||||||
};
|
};
|
||||||
|
|
||||||
|
getUserSettings = () => {
|
||||||
|
const { populateSharedUserState } = this.props;
|
||||||
|
|
||||||
|
doPreferenceGet(
|
||||||
|
'shared',
|
||||||
|
preference => {
|
||||||
|
populateSharedUserState(preference);
|
||||||
|
},
|
||||||
|
error => {
|
||||||
|
/* failed */
|
||||||
|
}
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
checkVerificationStatus = user => {
|
checkVerificationStatus = user => {
|
||||||
const { deviceWalletSynced, navigation } = this.props;
|
const { deviceWalletSynced, getSync, navigation } = this.props;
|
||||||
const { syncFlow } = navigation.state.params;
|
const { syncFlow } = navigation.state.params;
|
||||||
|
|
||||||
this.setState(
|
this.setState(
|
||||||
|
@ -57,7 +75,13 @@ class VerificationScreen extends React.PureComponent {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.state.isEmailVerified && syncFlow && deviceWalletSynced) {
|
if (this.state.isEmailVerified && syncFlow && deviceWalletSynced) {
|
||||||
|
// retrieve user settings
|
||||||
|
NativeModules.UtilityModule.getSecureValue(Constants.KEY_WALLET_PASSWORD).then(walletPassword => {
|
||||||
|
getSync(walletPassword, () => {
|
||||||
|
this.getUserSettings();
|
||||||
navigation.goBack();
|
navigation.goBack();
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (this.state.isEmailVerified && !this.state.isIdentityVerified && !this.state.isRewardApproved) {
|
if (this.state.isEmailVerified && !this.state.isIdentityVerified && !this.state.isRewardApproved) {
|
||||||
|
@ -167,6 +191,7 @@ class VerificationScreen extends React.PureComponent {
|
||||||
syncApply={syncApply}
|
syncApply={syncApply}
|
||||||
syncData={syncData}
|
syncData={syncData}
|
||||||
syncHash={syncHash}
|
syncHash={syncHash}
|
||||||
|
signInFlow={this.state.signInFlow}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
|
@ -182,7 +207,7 @@ class VerificationScreen extends React.PureComponent {
|
||||||
|
|
||||||
{!this.state.isEmailVerificationPhase && (
|
{!this.state.isEmailVerificationPhase && (
|
||||||
<TouchableOpacity style={firstRunStyle.closeButton} onPress={this.onCloseButtonPressed}>
|
<TouchableOpacity style={firstRunStyle.closeButton} onPress={this.onCloseButtonPressed}>
|
||||||
<Text style={firstRunStyle.closeButtonText}>x</Text>
|
<Icon name={'times'} size={16} style={firstRunStyle.closeButtonIcon} />
|
||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
)}
|
)}
|
||||||
</View>
|
</View>
|
||||||
|
|
|
@ -153,6 +153,10 @@ const firstRunStyle = StyleSheet.create({
|
||||||
color: Colors.White,
|
color: Colors.White,
|
||||||
fontSize: 16,
|
fontSize: 16,
|
||||||
},
|
},
|
||||||
|
closeButtonIcon: {
|
||||||
|
alignSelf: 'center',
|
||||||
|
color: Colors.White,
|
||||||
|
},
|
||||||
buttonContainer: {
|
buttonContainer: {
|
||||||
flexDirection: 'row',
|
flexDirection: 'row',
|
||||||
alignItems: 'center',
|
alignItems: 'center',
|
||||||
|
|
Loading…
Reference in a new issue