2021-03-20 00:54:18 +01:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* Main reducer
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
import { fromJS, Map } from 'immutable';
|
2021-03-21 17:55:14 +01:00
|
|
|
import { SET_DATABASE_CONFIG_IN_STATE, SET_FILE_CONFIG_IN_STATE, SET_LOADING_STATE } from '../../actions/Config';
|
2021-03-20 00:54:18 +01:00
|
|
|
|
2021-03-20 03:20:48 +01:00
|
|
|
const initialState = fromJS({
|
|
|
|
databaseConfig: Map({}),
|
2021-03-21 17:55:14 +01:00
|
|
|
fileConfig: Map({}),
|
|
|
|
isLoading: false,
|
2021-03-20 03:20:48 +01:00
|
|
|
});
|
2021-03-20 00:54:18 +01:00
|
|
|
|
|
|
|
export default function configReducer(state = initialState, action) {
|
|
|
|
switch (action.type) {
|
2021-03-20 03:20:48 +01:00
|
|
|
case SET_DATABASE_CONFIG_IN_STATE:
|
|
|
|
return state
|
|
|
|
.update('databaseConfig', () => fromJS(action.config))
|
|
|
|
case SET_FILE_CONFIG_IN_STATE:
|
|
|
|
return state
|
|
|
|
.update('fileConfig', () => fromJS(action.config))
|
2021-03-21 17:55:14 +01:00
|
|
|
case SET_LOADING_STATE:
|
|
|
|
return state
|
|
|
|
.update('isLoading', () => fromJS(action.value))
|
2021-03-20 00:54:18 +01:00
|
|
|
default:
|
|
|
|
return state;
|
|
|
|
}
|
|
|
|
}
|