insomnia/app/reducers/global.js

34 lines
1.0 KiB
JavaScript
Raw Normal View History

2016-03-20 04:00:40 +00:00
import * as types from '../constants/actionTypes';
import settingsReducer from './settings'
2016-03-24 05:26:04 +00:00
import requestsReducer from './requests'
2016-04-04 01:05:34 +00:00
import requestGroupsReducer from './requestGroups'
2016-03-20 04:00:40 +00:00
const initialState = {
initialized: false,
loading: false
};
export default function (state = initialState, action) {
switch (action.type) {
case types.GLOBAL_STATE_SAVED:
return state;
case types.GLOBAL_STATE_RESTORED:
return Object.assign({}, state, action.state, {initialized: true});
case types.GLOBAL_LOAD_START:
return Object.assign({}, state, {loading: true});
case types.GLOBAL_LOAD_STOP:
return Object.assign({}, state, {loading: false});
default:
// Send everything else to the child reducers
const settings = settingsReducer(state.settings, action);
2016-03-24 05:26:04 +00:00
const requests = requestsReducer(state.requests, action);
const requestGroups = requestGroupsReducer(state.requestGroups, action);
2016-04-03 22:54:39 +00:00
2016-03-20 04:00:40 +00:00
return Object.assign({}, state, {
settings,
2016-03-24 05:26:04 +00:00
requests,
2016-04-05 06:08:03 +00:00
requestGroups
2016-03-20 04:00:40 +00:00
});
}
};