Redux changes and refactoring

This commit is contained in:
Scott E. Graves
2019-06-07 00:30:59 -05:00
parent 1dc99567f3
commit 31585fc912
6 changed files with 179 additions and 140 deletions

View File

@@ -0,0 +1,49 @@
import {createReducer} from 'redux-starter-kit';
import {setAllowDownload, SET_DOWNLOAD_BEGIN, setDownloadEnd, setDownloadProgress} from '../actions/download_actions';
const defaultDownloadState = {
DownloadActive: false,
DownloadProgress: 0.0,
DownloadingDependency: false,
DownloadName: '',
DownloadType: null,
DownloadingRelease: false,
DownloadResult: null,
DownloadingUpgrade: false
};
export const downloadReducer = createReducer({
...defaultDownloadState,
AllowDownload: false,
}, {
[setAllowDownload]: (state, action) => {
return {
...state,
AllowDownload: action.payload,
};
},
[SET_DOWNLOAD_BEGIN]: (state, action) => {
return {
...state,
DownloadActive: true,
DownloadName: action.payload.name,
DownloadProgress: 0.0,
DownloadResult: null,
DownloadType: action.payload.type,
DownloadURL: action.payload.url,
}
},
[setDownloadEnd]: (state, action) => {
return {
...state,
...defaultDownloadState,
DownloadResult: action.payload,
};
},
[setDownloadProgress]: (state, action) => {
return {
...state,
DownloadProgress: action.payload,
}
}
});