diff --git a/src/renderer/redux/actions/app.js b/src/renderer/redux/actions/app.js index 103ffe8d4..d3d5a56f7 100644 --- a/src/renderer/redux/actions/app.js +++ b/src/renderer/redux/actions/app.js @@ -139,10 +139,21 @@ export function doDownloadUpgradeRequested() { }; } -export function doAutoUpdate() { +export function doClearUpgradeTimer() { return (dispatch, getState) => { const state = getState(); - + + if (selectUpgradeTimer(state)) { + clearInterval(selectUpgradeTimer(state)); + dispatch({ + type: ACTIONS.CLEAR_UPGRADE_TIMER, + }); + } + }; +} + +export function doAutoUpdate() { + return dispatch => { dispatch({ type: ACTIONS.AUTO_UPDATE_DOWNLOADED, }); @@ -153,19 +164,13 @@ export function doAutoUpdate() { }) ); - if (selectUpgradeTimer(state)) { - clearInterval(selectUpgradeTimer(state)); - } + dispatch(doClearUpgradeTimer()); }; } export function doAutoUpdateDeclined() { - return (dispatch, getState) => { - const state = getState(); - - if (selectUpgradeTimer(state)) { - clearInterval(selectUpgradeTimer(state)); - } + return dispatch => { + dispatch(doClearUpgradeTimer()); dispatch({ type: ACTIONS.AUTO_UPDATE_DECLINED, diff --git a/src/renderer/redux/reducers/app.js b/src/renderer/redux/reducers/app.js index c66ae24b3..2aa59f98d 100644 --- a/src/renderer/redux/reducers/app.js +++ b/src/renderer/redux/reducers/app.js @@ -184,6 +184,11 @@ reducers[ACTIONS.HISTORY_NAVIGATE] = state => modalProps: {}, }); +reducers[ACTIONS.CLEAR_UPGRADE_TIMER] = state => + Object.assign({}, state, { + checkUpgradeTimer: undefined, + }); + export default function reducer(state: AppState = defaultState, action: any) { const handler = reducers[action.type]; if (handler) return handler(state, action);