fix: make sure there is no modal open before opening wallet_unlock modal

This commit is contained in:
Sean Yesmunt 2018-12-05 16:09:11 -05:00
parent 7f0db55879
commit 219eeb8e67

View file

@ -25,7 +25,6 @@ type Props = {
type State = { type State = {
details: string, details: string,
message: string, message: string,
isRunning: boolean,
launchedModal: boolean, launchedModal: boolean,
error: boolean, error: boolean,
}; };
@ -37,7 +36,6 @@ export class SplashScreen extends React.PureComponent<Props, State> {
this.state = { this.state = {
details: __('Starting up'), details: __('Starting up'),
message: __('Connecting'), message: __('Connecting'),
isRunning: false,
launchedModal: false, launchedModal: false,
error: false, error: false,
}; };
@ -52,12 +50,7 @@ export class SplashScreen extends React.PureComponent<Props, State> {
this.adjustErrorTimeout(); this.adjustErrorTimeout();
Lbry.connect() Lbry.connect()
.then(() => { .then(checkDaemonVersion)
this.setState({
isRunning: true,
});
checkDaemonVersion();
})
.then(() => { .then(() => {
this.updateStatus(); this.updateStatus();
}) })
@ -94,16 +87,13 @@ export class SplashScreen extends React.PureComponent<Props, State> {
} }
updateStatus() { updateStatus() {
const { daemonVersionMatched } = this.props; Lbry.status().then(status => {
if (daemonVersionMatched) { this.updateStatusCallback(status);
Lbry.status().then(status => { });
this.updateStatusCallback(status);
});
}
} }
updateStatusCallback(status: Status) { updateStatusCallback(status: Status) {
const { notifyUnlockWallet, authenticate } = this.props; const { notifyUnlockWallet, authenticate, modal } = this.props;
const { launchedModal } = this.state; const { launchedModal } = this.state;
if (status.error) { if (status.error) {
@ -127,7 +117,8 @@ export class SplashScreen extends React.PureComponent<Props, State> {
clearTimeout(this.timeout); clearTimeout(this.timeout);
} }
if (launchedModal === false) { // Make sure there isn't another active modal (like INCOMPATIBLE_DAEMON)
if (launchedModal === false && !modal) {
this.setState({ launchedModal: true }, () => notifyUnlockWallet()); this.setState({ launchedModal: true }, () => notifyUnlockWallet());
} }
} else if (status.is_running) { } else if (status.is_running) {
@ -135,13 +126,6 @@ export class SplashScreen extends React.PureComponent<Props, State> {
if (!this.timeout) { if (!this.timeout) {
this.adjustErrorTimeout(); this.adjustErrorTimeout();
} }
// Wait until we are able to resolve a name before declaring
// that we are done.
// TODO: This is a hack, and the logic should live in the daemon
// to give us a better sense of when we are actually started
this.setState({
isRunning: true,
});
Lbry.resolve({ uri: 'lbry://one' }).then(() => { Lbry.resolve({ uri: 'lbry://one' }).then(() => {
// Only leave the load screen if the daemon version matched; // Only leave the load screen if the daemon version matched;
@ -207,7 +191,7 @@ export class SplashScreen extends React.PureComponent<Props, State> {
} }
render() { render() {
const { message, details, isRunning, error } = this.state; const { message, details, error } = this.state;
return ( return (
<React.Fragment> <React.Fragment>
@ -215,7 +199,7 @@ export class SplashScreen extends React.PureComponent<Props, State> {
{/* Temp hack: don't show any modals on splash screen daemon is running; {/* Temp hack: don't show any modals on splash screen daemon is running;
daemon doesn't let you quit during startup, so the "Quit" buttons daemon doesn't let you quit during startup, so the "Quit" buttons
in the modals won't work. */} in the modals won't work. */}
{isRunning && this.renderModals()} {this.renderModals()}
</React.Fragment> </React.Fragment>
); );
} }