Redux changes and refactoring
This commit is contained in:
49
src/redux/reducers/download_reducer.js
Normal file
49
src/redux/reducers/download_reducer.js
Normal 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,
|
||||
}
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user