Code refactor

Create action for clearing upgrade timer
This commit is contained in:
Aliyev Doniyor 2018-08-07 19:02:11 +05:00
parent 30c32d4c2b
commit 90d1b18586
2 changed files with 21 additions and 11 deletions

View file

@ -139,10 +139,21 @@ export function doDownloadUpgradeRequested() {
}; };
} }
export function doAutoUpdate() { export function doClearUpgradeTimer() {
return (dispatch, getState) => { return (dispatch, getState) => {
const state = getState(); const state = getState();
if (selectUpgradeTimer(state)) {
clearInterval(selectUpgradeTimer(state));
dispatch({
type: ACTIONS.CLEAR_UPGRADE_TIMER,
});
}
};
}
export function doAutoUpdate() {
return dispatch => {
dispatch({ dispatch({
type: ACTIONS.AUTO_UPDATE_DOWNLOADED, type: ACTIONS.AUTO_UPDATE_DOWNLOADED,
}); });
@ -153,19 +164,13 @@ export function doAutoUpdate() {
}) })
); );
if (selectUpgradeTimer(state)) { dispatch(doClearUpgradeTimer());
clearInterval(selectUpgradeTimer(state));
}
}; };
} }
export function doAutoUpdateDeclined() { export function doAutoUpdateDeclined() {
return (dispatch, getState) => { return dispatch => {
const state = getState(); dispatch(doClearUpgradeTimer());
if (selectUpgradeTimer(state)) {
clearInterval(selectUpgradeTimer(state));
}
dispatch({ dispatch({
type: ACTIONS.AUTO_UPDATE_DECLINED, type: ACTIONS.AUTO_UPDATE_DECLINED,

View file

@ -184,6 +184,11 @@ reducers[ACTIONS.HISTORY_NAVIGATE] = state =>
modalProps: {}, modalProps: {},
}); });
reducers[ACTIONS.CLEAR_UPGRADE_TIMER] = state =>
Object.assign({}, state, {
checkUpgradeTimer: undefined,
});
export default function reducer(state: AppState = defaultState, action: any) { export default function reducer(state: AppState = defaultState, action: any) {
const handler = reducers[action.type]; const handler = reducers[action.type];
if (handler) return handler(state, action); if (handler) return handler(state, action);