Code refactor
Create action for clearing upgrade timer
This commit is contained in:
parent
30c32d4c2b
commit
90d1b18586
2 changed files with 21 additions and 11 deletions
|
@ -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,
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Add table
Reference in a new issue