Merge pull request #1885 from lbryio/record-user

Record user as soon as possible
This commit is contained in:
Sean Yesmunt 2018-08-20 14:57:50 -04:00 committed by GitHub
commit 9844cbdaf6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 5 deletions

View file

@ -12,6 +12,7 @@ type Props = {
notifyUnlockWallet: () => Promise<any>, notifyUnlockWallet: () => Promise<any>,
daemonVersionMatched: boolean, daemonVersionMatched: boolean,
onReadyToLaunch: () => void, onReadyToLaunch: () => void,
authenticate: () => void,
notification: ?{ notification: ?{
id: string, id: string,
}, },
@ -34,6 +35,8 @@ export class SplashScreen extends React.PureComponent<Props, State> {
isRunning: false, isRunning: false,
launchedModal: false, launchedModal: false,
}; };
this.hasRecordedUser = false;
} }
componentDidMount() { componentDidMount() {
@ -61,8 +64,14 @@ export class SplashScreen extends React.PureComponent<Props, State> {
} }
updateStatusCallback(status) { updateStatusCallback(status) {
const { notifyUnlockWallet } = this.props; const { notifyUnlockWallet, authenticate } = this.props;
const { launchedModal } = this.state; const { launchedModal } = this.state;
if (!this.hasRecordedUser && status) {
authenticate();
this.hasRecordedUser = true;
}
if (status.wallet && status.wallet.is_locked) { if (status.wallet && status.wallet.is_locked) {
this.setState({ this.setState({
isRunning: true, isRunning: true,
@ -113,6 +122,8 @@ export class SplashScreen extends React.PureComponent<Props, State> {
}, 500); }, 500);
} }
hasRecordedUser: boolean;
render() { render() {
const { notification } = this.props; const { notification } = this.props;
const { message, details, isRunning } = this.state; const { message, details, isRunning } = this.state;

View file

@ -11,7 +11,7 @@ import { doConditionalAuthNavigate, doDaemonReady, doAutoUpdate } from 'redux/ac
import { doNotify, doBlackListedOutpointsSubscribe, isURIValid } from 'lbry-redux'; import { doNotify, doBlackListedOutpointsSubscribe, isURIValid } from 'lbry-redux';
import { doNavigate } from 'redux/actions/navigation'; import { doNavigate } from 'redux/actions/navigation';
import { doDownloadLanguages, doUpdateIsNightAsync } from 'redux/actions/settings'; import { doDownloadLanguages, doUpdateIsNightAsync } from 'redux/actions/settings';
import { doUserEmailVerify } from 'redux/actions/user'; import { doUserEmailVerify, doAuthenticate } from 'redux/actions/user';
import 'scss/all.scss'; import 'scss/all.scss';
import store from 'store'; import store from 'store';
import app from './app'; import app from './app';
@ -155,7 +155,10 @@ const init = () => {
} else { } else {
ReactDOM.render( ReactDOM.render(
<Provider store={store}> <Provider store={store}>
<SplashScreen onReadyToLaunch={onDaemonReady} /> <SplashScreen
authenticate={() => app.store.dispatch(doAuthenticate())}
onReadyToLaunch={onDaemonReady}
/>
</Provider>, </Provider>,
document.getElementById('app') document.getElementById('app')
); );

View file

@ -16,7 +16,6 @@ import Native from 'native';
import { doFetchRewardedContent } from 'redux/actions/content'; import { doFetchRewardedContent } from 'redux/actions/content';
import { doFetchDaemonSettings } from 'redux/actions/settings'; import { doFetchDaemonSettings } from 'redux/actions/settings';
import { doAuthNavigate } from 'redux/actions/navigation'; import { doAuthNavigate } from 'redux/actions/navigation';
import { doAuthenticate } from 'redux/actions/user';
import { doPause } from 'redux/actions/media'; import { doPause } from 'redux/actions/media';
import { doCheckSubscriptionsInit } from 'redux/actions/subscriptions'; import { doCheckSubscriptionsInit } from 'redux/actions/subscriptions';
import { import {
@ -337,7 +336,6 @@ export function doDaemonReady() {
return (dispatch, getState) => { return (dispatch, getState) => {
const state = getState(); const state = getState();
dispatch(doAuthenticate());
dispatch({ type: ACTIONS.DAEMON_READY }); dispatch({ type: ACTIONS.DAEMON_READY });
dispatch(doFetchDaemonSettings()); dispatch(doFetchDaemonSettings());
dispatch(doBalanceSubscribe()); dispatch(doBalanceSubscribe());