From c684f56dd826b1f9f4a73cdbcb918b0dfd6c8f9c Mon Sep 17 00:00:00 2001 From: Sean Yesmunt Date: Mon, 23 Apr 2018 14:02:06 -0400 Subject: [PATCH] remove: selectCurrentModal --- .gitignore | 1 + src/renderer/component/splash/index.js | 5 ++- src/renderer/component/splash/view.jsx | 14 ++++--- src/renderer/component/userVerify/index.js | 2 - src/renderer/redux/actions/app.js | 48 ++++++++++++++-------- 5 files changed, 43 insertions(+), 27 deletions(-) diff --git a/.gitignore b/.gitignore index f57e421ea..2bacc7198 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ /static/daemon/lbrynet* /static/locales yarn-error.log +/build/daemon* diff --git a/src/renderer/component/splash/index.js b/src/renderer/component/splash/index.js index 04cc84e15..932265392 100644 --- a/src/renderer/component/splash/index.js +++ b/src/renderer/component/splash/index.js @@ -1,10 +1,11 @@ import { connect } from 'react-redux'; -import { selectCurrentModal, selectDaemonVersionMatched } from 'redux/selectors/app'; +import { selectDaemonVersionMatched } from 'redux/selectors/app'; +import { selectNotification } from 'lbry-redux'; import { doCheckDaemonVersion } from 'redux/actions/app'; import SplashScreen from './view'; const select = state => ({ - modal: selectCurrentModal(state), + notification: selectNotification(state), daemonVersionMatched: selectDaemonVersionMatched(state), }); diff --git a/src/renderer/component/splash/view.jsx b/src/renderer/component/splash/view.jsx index bdbadc247..1bb81518c 100644 --- a/src/renderer/component/splash/view.jsx +++ b/src/renderer/component/splash/view.jsx @@ -8,7 +8,9 @@ import * as modals from 'constants/modal_types'; type Props = { checkDaemonVersion: () => Promise, - modal: string, + notification: ?{ + id: string, + }, }; type State = { @@ -100,9 +102,11 @@ export class SplashScreen extends React.PureComponent { } render() { - const { modal } = this.props; + const { notification } = this.props; const { message, details, isLagging, isRunning } = this.state; + const notificationId = notification && notification.id; + return ( @@ -111,9 +115,9 @@ export class SplashScreen extends React.PureComponent { in the modals won't work. */} {isRunning && ( - {modal === modals.INCOMPATIBLE_DAEMON && } - {modal === modals.UPGRADE && } - {modal === modals.DOWNLOADING && } + {notificationId === modals.INCOMPATIBLE_DAEMON && } + {notificationId === modals.UPGRADE && } + {notificationId === modals.DOWNLOADING && } )} diff --git a/src/renderer/component/userVerify/index.js b/src/renderer/component/userVerify/index.js index fd52fec7d..3533affbd 100644 --- a/src/renderer/component/userVerify/index.js +++ b/src/renderer/component/userVerify/index.js @@ -8,7 +8,6 @@ import { selectIdentityVerifyErrorMessage, } from 'redux/selectors/user'; import UserVerify from './view'; -import { selectCurrentModal } from 'redux/selectors/app'; import { doNotify } from 'lbry-redux'; import { PHONE_COLLECTION } from 'constants/modal_types'; @@ -19,7 +18,6 @@ const select = (state, props) => { isPending: selectIdentityVerifyIsPending(state), errorMessage: selectIdentityVerifyErrorMessage(state), reward: selectReward(state, { reward_type: rewards.TYPE_NEW_USER }), - modal: selectCurrentModal(state), }; }; diff --git a/src/renderer/redux/actions/app.js b/src/renderer/redux/actions/app.js index 459b343ef..24e742123 100644 --- a/src/renderer/redux/actions/app.js +++ b/src/renderer/redux/actions/app.js @@ -9,6 +9,7 @@ import { doBalanceSubscribe, doFetchFileInfosAndPublishedClaims, doNotify, + selectNotification, } from 'lbry-redux'; import Native from 'native'; import { doFetchRewardedContent } from 'redux/actions/content'; @@ -18,7 +19,6 @@ import { doAuthenticate } from 'redux/actions/user'; import { doPause } from 'redux/actions/media'; import { doCheckSubscriptions } from 'redux/actions/subscriptions'; import { - selectCurrentModal, selectIsUpgradeSkipped, selectUpdateUrl, selectUpgradeDownloadItem, @@ -89,9 +89,11 @@ export function doDownloadUpgrade() { dispatch({ type: ACTIONS.UPGRADE_DOWNLOAD_STARTED, }); - dispatch(doNotify({ - id: MODALS.DOWNLOADING, - })); + dispatch( + doNotify({ + id: MODALS.DOWNLOADING, + }) + ); }; } @@ -113,15 +115,19 @@ export function doDownloadUpgradeRequested() { // electron-updater behavior if (autoUpdateDeclined) { // The user declined an update before, so show the "confirm" dialog - dispatch(doNotify({ - id: MODALS.AUTO_UPDATE_CONFIRM - })); + dispatch( + doNotify({ + id: MODALS.AUTO_UPDATE_CONFIRM, + }) + ); } else { // The user was never shown the original update dialog (e.g. because they were // watching a video). So show the inital "update downloaded" dialog. - dispatch(doNotify({ - id: MODALS.AUTO_UPDATE_DOWNLOADED - })); + dispatch( + doNotify({ + id: MODALS.AUTO_UPDATE_DOWNLOADED, + }) + ); } } else { // Old behavior for Linux @@ -136,9 +142,11 @@ export function doAutoUpdate() { type: ACTIONS.AUTO_UPDATE_DOWNLOADED, }); - dispatch(doNotify({ - id: MODALS.AUTO_UPDATE_DOWNLOADED - })); + dispatch( + doNotify({ + id: MODALS.AUTO_UPDATE_DOWNLOADED, + }) + ); }; } @@ -203,12 +211,14 @@ export function doCheckUpgradeAvailable() { if ( upgradeAvailable && - !selectCurrentModal(state) && + !selectNotification(state) && (!selectIsUpgradeSkipped(state) || remoteVersion !== selectRemoteVersion(state)) ) { - dispatch(doNotify({ - id: MODALS.UPGRADE - })); + dispatch( + doNotify({ + id: MODALS.UPGRADE, + }) + ); } }; @@ -324,7 +334,9 @@ export function doChangeVolume(volume) { export function doConditionalAuthNavigate(newSession) { return (dispatch, getState) => { const state = getState(); - if (newSession || selectCurrentModal(state) !== 'email_collection') { + const notification = selectNotification(state); + + if (newSession || (notification && notification.id !== 'email_collection')) { dispatch(doAuthNavigate()); } };