Merge pull request #77 from lbryio/sync-after-signin

restore user preferences after in-app sign in  flow
This commit is contained in:
Akinwale Ariwodola 2019-11-12 15:35:44 +01:00 committed by GitHub
commit 2e3e1a1250
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 48 additions and 11 deletions

View file

@ -54,7 +54,11 @@ class DrawerContent extends React.PureComponent {
launchSignInFlow = () => {
// for now, sync flow (email, then password input) will be the default sign in flow
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() {

View file

@ -16,7 +16,11 @@ class WalletSignIn extends React.Component {
onSignInPressed = () => {
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() {

View file

@ -159,7 +159,6 @@ class SplashScreen extends React.PureComponent {
this.setState({ shouldAuthenticate: true });
NativeModules.Firebase.getMessagingToken()
.then(firebaseToken => {
console.log(firebaseToken);
authenticate(appVersion, Platform.OS, firebaseToken);
})
.catch(() => authenticate(appVersion, Platform.OS));

View file

@ -1,5 +1,5 @@
import { connect } from 'react-redux';
import { doToast } from 'lbry-redux';
import { doToast, doPopulateSharedUserState } from 'lbry-redux';
import {
doCheckSync,
doGetSync,
@ -58,6 +58,7 @@ const perform = dispatch => ({
checkSync: () => dispatch(doCheckSync()),
verifyPhone: verificationCode => dispatch(doUserPhoneVerify(verificationCode)),
notify: data => dispatch(doToast(data)),
populateSharedUserState: settings => dispatch(doPopulateSharedUserState(settings)),
setClientSetting: (key, value) => dispatch(doSetClientSetting(key, value)),
setEmailToVerify: email => dispatch(doUserEmailToVerify(email)),
syncApply: (hash, data, password) => dispatch(doSyncApply(hash, data, password)),

View file

@ -112,7 +112,7 @@ class SyncVerifyPage extends React.PureComponent {
};
render() {
const { hasSyncedWallet, syncApplyIsPending } = this.props;
const { hasSyncedWallet, syncApplyIsPending, signInFlow } = this.props;
let paragraph;
if (!hasSyncedWallet) {
@ -194,7 +194,7 @@ class SyncVerifyPage extends React.PureComponent {
<Button
style={rewardStyle.verificationButton}
theme={'light'}
text={'Enable sync'}
text={signInFlow ? 'Use LBRY' : 'Enable sync'}
onPress={this.onEnableSyncPressed}
/>
)}

View file

@ -1,10 +1,11 @@
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 { NavigationActions, StackActions } from 'react-navigation';
import AsyncStorage from '@react-native-community/async-storage';
import Colors from 'styles/colors';
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 ManualVerifyPage from './internal/manual-verify-page';
import PhoneVerifyPage from './internal/phone-verify-page';
@ -19,6 +20,7 @@ class VerificationScreen extends React.PureComponent {
showSkip: false,
skipAccountConfirmed: false,
showBottomContainer: true,
signInFlow: false,
walletPassword: null,
isEmailVerificationPhase: false,
isEmailVerified: false,
@ -27,7 +29,9 @@ class VerificationScreen extends React.PureComponent {
};
componentDidMount() {
const { user } = this.props;
const { user, navigation } = this.props;
const { signInFlow } = navigation.state.params;
this.setState({ signInFlow });
this.checkVerificationStatus(user);
NativeModules.Firebase.setCurrentScreen('Verification');
}
@ -36,8 +40,22 @@ class VerificationScreen extends React.PureComponent {
this.setState({ isEmailVerificationPhase: value });
};
getUserSettings = () => {
const { populateSharedUserState } = this.props;
doPreferenceGet(
'shared',
preference => {
populateSharedUserState(preference);
},
error => {
/* failed */
}
);
};
checkVerificationStatus = user => {
const { deviceWalletSynced, navigation } = this.props;
const { deviceWalletSynced, getSync, navigation } = this.props;
const { syncFlow } = navigation.state.params;
this.setState(
@ -57,7 +75,13 @@ class VerificationScreen extends React.PureComponent {
}
if (this.state.isEmailVerified && syncFlow && deviceWalletSynced) {
navigation.goBack();
// retrieve user settings
NativeModules.UtilityModule.getSecureValue(Constants.KEY_WALLET_PASSWORD).then(walletPassword => {
getSync(walletPassword, () => {
this.getUserSettings();
navigation.goBack();
});
});
}
} else {
if (this.state.isEmailVerified && !this.state.isIdentityVerified && !this.state.isRewardApproved) {
@ -167,6 +191,7 @@ class VerificationScreen extends React.PureComponent {
syncApply={syncApply}
syncData={syncData}
syncHash={syncHash}
signInFlow={this.state.signInFlow}
/>
);
break;
@ -182,7 +207,7 @@ class VerificationScreen extends React.PureComponent {
{!this.state.isEmailVerificationPhase && (
<TouchableOpacity style={firstRunStyle.closeButton} onPress={this.onCloseButtonPressed}>
<Text style={firstRunStyle.closeButtonText}>x</Text>
<Icon name={'times'} size={16} style={firstRunStyle.closeButtonIcon} />
</TouchableOpacity>
)}
</View>

View file

@ -153,6 +153,10 @@ const firstRunStyle = StyleSheet.create({
color: Colors.White,
fontSize: 16,
},
closeButtonIcon: {
alignSelf: 'center',
color: Colors.White,
},
buttonContainer: {
flexDirection: 'row',
alignItems: 'center',