From ac8d5aef5bd02f2149cb1b3ee4723599ef3dd828 Mon Sep 17 00:00:00 2001 From: Sean Yesmunt Date: Wed, 9 Jan 2019 20:38:26 -0500 Subject: [PATCH] allow running the app with mismatched daemon versions --- src/renderer/component/splash/index.js | 3 +- src/renderer/component/splash/view.jsx | 39 ++++++++++++++----- src/renderer/modal/modal.jsx | 2 +- .../modal/modalIncompatibleDaemon/index.js | 3 +- .../modal/modalIncompatibleDaemon/view.jsx | 32 ++++++++------- src/renderer/modal/modalRevokeClaim/view.jsx | 14 +++++-- src/renderer/modal/modalRouter/view.jsx | 34 ++++++++++++---- src/renderer/redux/actions/app.js | 2 +- 8 files changed, 88 insertions(+), 41 deletions(-) diff --git a/src/renderer/component/splash/index.js b/src/renderer/component/splash/index.js index ba5d2d4cb..1fbc7d64b 100644 --- a/src/renderer/component/splash/index.js +++ b/src/renderer/component/splash/index.js @@ -1,6 +1,6 @@ import { connect } from 'react-redux'; import { selectDaemonVersionMatched, selectModal } from 'redux/selectors/app'; -import { doCheckDaemonVersion, doNotifyUnlockWallet } from 'redux/actions/app'; +import { doCheckDaemonVersion, doNotifyUnlockWallet, doHideModal } from 'redux/actions/app'; import SplashScreen from './view'; const select = state => ({ @@ -11,6 +11,7 @@ const select = state => ({ const perform = dispatch => ({ checkDaemonVersion: () => dispatch(doCheckDaemonVersion()), notifyUnlockWallet: () => dispatch(doNotifyUnlockWallet()), + hideModal: () => dispatch(doHideModal()), }); export default connect( diff --git a/src/renderer/component/splash/view.jsx b/src/renderer/component/splash/view.jsx index caad44c70..95c47fe15 100644 --- a/src/renderer/component/splash/view.jsx +++ b/src/renderer/component/splash/view.jsx @@ -17,6 +17,7 @@ type Props = { daemonVersionMatched: boolean, onReadyToLaunch: () => void, authenticate: () => void, + hideModal: () => void, modal: ?{ id: string, }, @@ -27,9 +28,11 @@ type State = { message: string, launchedModal: boolean, error: boolean, + isRunning: boolean, + launchWithIncompatibleDaemon: boolean, }; -export class SplashScreen extends React.PureComponent { +export default class SplashScreen extends React.PureComponent { constructor(props: Props) { super(props); @@ -38,9 +41,12 @@ export class SplashScreen extends React.PureComponent { message: __('Connecting'), launchedModal: false, error: false, + launchWithIncompatibleDaemon: false, + isRunning: false, }; (this: any).renderModals = this.renderModals.bind(this); + (this: any).runWithIncompatibleDaemon = this.runWithIncompatibleDaemon.bind(this); this.hasRecordedUser = false; this.timeout = undefined; } @@ -128,12 +134,7 @@ export class SplashScreen extends React.PureComponent { } Lbry.resolve({ uri: 'lbry://one' }).then(() => { - // Only leave the load screen if the daemon version matched; - // otherwise we'll notify the user at the end of the load screen. - - if (this.props.daemonVersionMatched) { - this.props.onReadyToLaunch(); - } + this.setState({ isRunning: true }, () => this.continueAppLaunch()); }); return; @@ -165,6 +166,26 @@ export class SplashScreen extends React.PureComponent { }, 500); } + runWithIncompatibleDaemon() { + const { hideModal } = this.props; + hideModal(); + this.setState({ launchWithIncompatibleDaemon: true }, () => this.continueAppLaunch()); + } + + continueAppLaunch() { + const { daemonVersionMatched, onReadyToLaunch } = this.props; + const { isRunning, launchWithIncompatibleDaemon } = this.state; + + if (daemonVersionMatched) { + onReadyToLaunch(); + } else if (launchWithIncompatibleDaemon && isRunning) { + // The user may have decided to run the app with mismatched daemons + // They could make this decision before the daemon is finished starting up + // If it isn't running, this function will be called after the daemon is started + onReadyToLaunch(); + } + } + hasRecordedUser: boolean; timeout: ?TimeoutID; @@ -178,7 +199,7 @@ export class SplashScreen extends React.PureComponent { switch (modalId) { case MODALS.INCOMPATIBLE_DAEMON: - return ; + return ; case MODALS.WALLET_UNLOCK: return ; case MODALS.UPGRADE: @@ -204,5 +225,3 @@ export class SplashScreen extends React.PureComponent { ); } } - -export default SplashScreen; diff --git a/src/renderer/modal/modal.jsx b/src/renderer/modal/modal.jsx index 508bcee64..2e52842d5 100644 --- a/src/renderer/modal/modal.jsx +++ b/src/renderer/modal/modal.jsx @@ -23,7 +23,7 @@ type ModalProps = { expandButtonLabel?: string, hideButtonLabel?: string, fullScreen: boolean, - title: string, + title?: string | React.Node, }; export class Modal extends React.PureComponent { diff --git a/src/renderer/modal/modalIncompatibleDaemon/index.js b/src/renderer/modal/modalIncompatibleDaemon/index.js index a676fdd88..32a446882 100644 --- a/src/renderer/modal/modalIncompatibleDaemon/index.js +++ b/src/renderer/modal/modalIncompatibleDaemon/index.js @@ -1,9 +1,8 @@ import { connect } from 'react-redux'; -import { doQuit, doQuitAnyDaemon } from 'redux/actions/app'; +import { doQuitAnyDaemon } from 'redux/actions/app'; import ModalIncompatibleDaemon from './view'; const perform = dispatch => ({ - quit: () => dispatch(doQuit()), quitAnyDaemon: () => dispatch(doQuitAnyDaemon()), }); diff --git a/src/renderer/modal/modalIncompatibleDaemon/view.jsx b/src/renderer/modal/modalIncompatibleDaemon/view.jsx index 872e51a50..7a0419270 100644 --- a/src/renderer/modal/modalIncompatibleDaemon/view.jsx +++ b/src/renderer/modal/modalIncompatibleDaemon/view.jsx @@ -4,13 +4,13 @@ import { Modal } from 'modal/modal'; import Button from 'component/button'; type Props = { - quit: () => void, + onContinueAnyway: () => void, quitAnyDaemon: () => void, }; class ModalIncompatibleDaemon extends React.PureComponent { render() { - const { quit, quitAnyDaemon } = this.props; + const { onContinueAnyway, quitAnyDaemon } = this.props; return ( { title={__('Incompatible Daemon')} contentLabel={__('Incompatible daemon running')} type="confirm" - confirmButtonLabel={__('Close LBRY and daemon')} - abortButtonLabel={__('Do nothing')} + confirmButtonLabel={__('Close App and LBRY Processes')} + abortButtonLabel={__('Continue Anyway')} onConfirmed={quitAnyDaemon} - onAborted={quit} + onAborted={onContinueAnyway} > -

- {__( - 'This browser is running with an incompatible version of the LBRY protocol, please close the LBRY app and rerun the installation package to repair it. ' - )} -

-