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) => {
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,

View file

@ -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);