Separate studio reducers and initial state into a helper

This commit is contained in:
Paul Kaplan 2021-06-23 20:57:30 -04:00
parent 8a3e6155c4
commit a8ed7410a4
2 changed files with 41 additions and 32 deletions

View file

@ -0,0 +1,37 @@
import {
projects,
curators,
managers,
activity,
userProjects
} from './lib/redux-modules';
const {getInitialState, studioReducer} = require('../../redux/studio');
const {studioReportReducer} = require('../../redux/studio-report');
const {commentsReducer} = require('../../redux/comments');
const {studioMutationsReducer} = require('../../redux/studio-mutations');
const reducers = {
[projects.key]: projects.reducer,
[curators.key]: curators.reducer,
[managers.key]: managers.reducer,
[activity.key]: activity.reducer,
[userProjects.key]: userProjects.reducer,
comments: commentsReducer,
studio: studioReducer,
studioMutations: studioMutationsReducer,
studioReport: studioReportReducer
};
const initialState = {
studio: {
...getInitialState(),
// Include the studio id in the initial state to allow us
// to stop passing around the studio id in components
// when it is only needed for data fetching, not for rendering.
id: window.location.pathname.split('/')[2]
}
};
export {reducers, initialState};

View file

@ -27,18 +27,8 @@ import StudioMeta from './studio-meta.jsx';
import StudioAdminPanel from './studio-admin-panel.jsx'; import StudioAdminPanel from './studio-admin-panel.jsx';
import StudioDeleted from './studio-deleted.jsx'; import StudioDeleted from './studio-deleted.jsx';
import { import {reducers, initialState} from './studio-redux.js';
projects, import {selectStudioLoadFailed, getInfo} from '../../redux/studio';
curators,
managers,
activity,
userProjects
} from './lib/redux-modules';
const {getInitialState, studioReducer, selectStudioLoadFailed, getInfo} = require('../../redux/studio');
const {studioReportReducer} = require('../../redux/studio-report');
const {commentsReducer} = require('../../redux/comments');
const {studioMutationsReducer} = require('../../redux/studio-mutations');
import './studio.scss'; import './studio.scss';
import {selectIsAdmin, selectMuteStatus} from '../../redux/session.js'; import {selectIsAdmin, selectMuteStatus} from '../../redux/session.js';
@ -140,24 +130,6 @@ render(
</Router> </Router>
</Page>, </Page>,
document.getElementById('app'), document.getElementById('app'),
{ reducers,
[projects.key]: projects.reducer, initialState
[curators.key]: curators.reducer,
[managers.key]: managers.reducer,
[activity.key]: activity.reducer,
[userProjects.key]: userProjects.reducer,
comments: commentsReducer,
studio: studioReducer,
studioMutations: studioMutationsReducer,
studioReport: studioReportReducer
},
{
studio: {
...getInitialState(),
// Include the studio id in the initial state to allow us
// to stop passing around the studio id in components
// when it is only needed for data fetching, not for rendering.
id: window.location.pathname.split('/')[2]
}
}
); );