From c702a8945420467e8ba2c5a6dc3a46f40fccd2d9 Mon Sep 17 00:00:00 2001 From: Sean Yesmunt Date: Thu, 19 Apr 2018 15:03:28 -0400 Subject: [PATCH] move app modal actions to doNotify type --- src/renderer/constants/action_types.js | 4 --- src/renderer/redux/actions/app.js | 18 ++++------ src/renderer/redux/reducers/app.js | 48 -------------------------- 3 files changed, 6 insertions(+), 64 deletions(-) diff --git a/src/renderer/constants/action_types.js b/src/renderer/constants/action_types.js index 1c718580c..27678804b 100644 --- a/src/renderer/constants/action_types.js +++ b/src/renderer/constants/action_types.js @@ -1,7 +1,3 @@ -export const OPEN_MODAL = 'OPEN_MODAL'; -export const CLOSE_MODAL = 'CLOSE_MODAL'; -export const SHOW_SNACKBAR = 'SHOW_SNACKBAR'; -export const REMOVE_SNACKBAR_SNACK = 'REMOVE_SNACKBAR_SNACK'; export const WINDOW_FOCUSED = 'WINDOW_FOCUSED'; export const DAEMON_READY = 'DAEMON_READY'; export const DAEMON_VERSION_MATCH = 'DAEMON_VERSION_MATCH'; diff --git a/src/renderer/redux/actions/app.js b/src/renderer/redux/actions/app.js index 09864b64d..df0a699ad 100644 --- a/src/renderer/redux/actions/app.js +++ b/src/renderer/redux/actions/app.js @@ -84,7 +84,7 @@ export function doDownloadUpgrade() { type: ACTIONS.UPGRADE_DOWNLOAD_STARTED, }); dispatch({ - type: ACTIONS.OPEN_MODAL, + type: ACTIONS.CREATE_NOTIFICATION, data: { modal: MODALS.DOWNLOADING, }, @@ -111,14 +111,14 @@ export function doDownloadUpgradeRequested() { if (autoUpdateDeclined) { // The user declined an update before, so show the "confirm" dialog dispatch({ - type: ACTIONS.OPEN_MODAL, + type: ACTIONS.CREATE_NOTIFICATION, data: { modal: 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({ - type: ACTIONS.OPEN_MODAL, + type: ACTIONS.CREATE_NOTIFICATION, data: { modal: MODALS.AUTO_UPDATE_DOWNLOADED }, }); } @@ -136,7 +136,7 @@ export function doAutoUpdate() { }); dispatch({ - type: ACTIONS.OPEN_MODAL, + type: ACTIONS.CREATE_NOTIFICATION, data: { modal: MODALS.AUTO_UPDATE_DOWNLOADED }, }); }; @@ -207,7 +207,7 @@ export function doCheckUpgradeAvailable() { (!selectIsUpgradeSkipped(state) || remoteVersion !== selectRemoteVersion(state)) ) { dispatch({ - type: ACTIONS.OPEN_MODAL, + type: ACTIONS.CREATE_NOTIFICATION, data: { modal: MODALS.UPGRADE, }, @@ -257,7 +257,7 @@ export function doCheckDaemonVersion() { export function doAlertError(errorList) { return dispatch => { dispatch({ - type: ACTIONS.OPEN_MODAL, + type: ACTIONS.CREATE_NOTIFICATION, data: { modal: MODALS.ERROR, modalProps: { error: errorList }, @@ -284,12 +284,6 @@ export function doDaemonReady() { }; } -export function doRemoveSnackBarSnack() { - return { - type: ACTIONS.REMOVE_SNACKBAR_SNACK, - }; -} - export function doClearCache() { return () => { window.cacheStore.purge(); diff --git a/src/renderer/redux/reducers/app.js b/src/renderer/redux/reducers/app.js index 188fd06e2..ab66a40f8 100644 --- a/src/renderer/redux/reducers/app.js +++ b/src/renderer/redux/reducers/app.js @@ -155,59 +155,11 @@ reducers[ACTIONS.CHECK_UPGRADE_SUBSCRIBE] = (state, action) => checkUpgradeTimer: action.data.checkUpgradeTimer, }); -reducers[ACTIONS.OPEN_MODAL] = (state, action) => { - if (!state.modalsAllowed) { - return state; - } - return Object.assign({}, state, { - modal: action.data.modal, - modalProps: action.data.modalProps || {}, - }); -}; -reducers[ACTIONS.CLOSE_MODAL] = state => - Object.assign({}, state, { - modal: undefined, - modalProps: {}, - }); - reducers[ACTIONS.UPGRADE_DOWNLOAD_PROGRESSED] = (state, action) => Object.assign({}, state, { downloadProgress: action.data.percent, }); -reducers[ACTIONS.SHOW_SNACKBAR] = (state, action) => { - const { message, linkText, linkTarget, isError } = action.data; - const snackBar = Object.assign({}, state.snackBar); - const snacks = Object.assign([], snackBar.snacks); - snacks.push({ - message, - linkText, - linkTarget, - isError, - }); - const newSnackBar = Object.assign({}, snackBar, { - snacks, - }); - - return Object.assign({}, state, { - snackBar: newSnackBar, - }); -}; - -reducers[ACTIONS.REMOVE_SNACKBAR_SNACK] = state => { - const snackBar = Object.assign({}, state.snackBar); - const snacks = Object.assign([], snackBar.snacks); - snacks.shift(); - - const newSnackBar = Object.assign({}, snackBar, { - snacks, - }); - - return Object.assign({}, state, { - snackBar: newSnackBar, - }); -}; - reducers[ACTIONS.DOWNLOADING_COMPLETED] = state => { const { badgeNumber } = state;