use switch for modals on splash

This commit is contained in:
Sean Yesmunt 2018-11-12 13:22:51 -05:00
parent df322c573a
commit e407acb63a
2 changed files with 26 additions and 12 deletions

View file

@ -42,6 +42,7 @@ export class SplashScreen extends React.PureComponent<Props, State> {
error: false,
};
(this: any).renderModals = this.renderModals.bind(this);
this.hasRecordedUser = false;
this.timeout = undefined;
}
@ -170,26 +171,38 @@ export class SplashScreen extends React.PureComponent<Props, State> {
hasRecordedUser: boolean;
timeout: ?TimeoutID;
render() {
renderModals() {
const { modal } = this.props;
const { message, details, isRunning, error } = this.state;
const modalId = modal && modal.id;
if (!modalId) {
return null;
}
switch (modalId) {
case MODALS.INCOMPATIBLE_DAEMON:
return <ModalIncompatibleDaemon />;
case MODALS.WALLET_UNLOCK:
return <ModalWalletUnlock />;
case MODALS.UPGRADE:
return <ModalUpgrade />;
case MODALS.DOWNLOADING:
return <ModalDownloading />;
default:
return null;
}
}
render() {
const { message, details, isRunning, error } = this.state;
return (
<React.Fragment>
<LoadScreen message={message} details={details} error={error} />
{/* 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
in the modals won't work. */}
{isRunning && (
<React.Fragment>
{modalId === MODALS.WALLET_UNLOCK && <ModalWalletUnlock />}
{modalId === MODALS.INCOMPATIBLE_DAEMON && <ModalIncompatibleDaemon />}
{modalId === MODALS.UPGRADE && <ModalUpgrade />}
{modalId === MODALS.DOWNLOADING && <ModalDownloading />}
</React.Fragment>
)}
{isRunning && this.renderModals()}
</React.Fragment>
);
}

View file

@ -5676,6 +5676,7 @@ lbry-redux@lbryio/lbry-redux#bf83ec3dd8f0417439b2ee4b6bf7b2549c012096:
dependencies:
proxy-polyfill "0.1.6"
reselect "^3.0.0"
uuid "^3.3.2"
lbryinc@lbryio/lbryinc#82308ece97188747adbf6d71d55b6e7a6fa0bd95:
version "0.0.1"
@ -9919,7 +9920,7 @@ uuid@3.1.0:
version "3.1.0"
resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.1.0.tgz#3dd3d3e790abc24d7b0d3a034ffababe28ebbc04"
uuid@^3.0.0, uuid@^3.0.1, uuid@^3.1.0:
uuid@^3.0.0, uuid@^3.0.1, uuid@^3.1.0, uuid@^3.3.2:
version "3.3.2"
resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.3.2.tgz#1b4af4955eb3077c501c23872fc6513811587131"