in frontend/src/store.js [36:77]
function rootReducer(state, action) {
switch(action.type) {
case 'state/clearAll':
// Keep the selected region, everything else will be retrieved again
const keep = (({ selectedRegion, sidebar, section }) => ({ selectedRegion, sidebar, section }))(state.app)
return {...appReducer(undefined, action), app: keep};
case 'state/store':
{
const {path, value} = action.payload
if(path.length > 1)
return recurseAction(state, action);
return swapIn(state, path[0], value)
}
case 'state/clear':
{
const {path} = action.payload
if(path.length > 1)
return recurseAction(state, action);
let ret = null;
if(Array.isArray(state))
{
ret = [...state];
ret.splice(path[0], 1)
} else {
ret = {...state};
delete ret[path[0]];
}
return ret
}
case 'state/update':
{
const {path, update} = action.payload
if(path.length > 1)
return recurseAction(state, action);
const existing = path[0] in state ? {...state[path[0]]} : null
return swapIn(state, path[0], update(existing));
}
default:
return appReducer(state, action);
}
}