mirror of
https://github.com/scratchfoundation/scratch-www.git
synced 2024-11-27 09:35:56 -05:00
Separate studio reducers and initial state into a helper
This commit is contained in:
parent
8a3e6155c4
commit
a8ed7410a4
2 changed files with 41 additions and 32 deletions
37
src/views/studio/studio-redux.js
Normal file
37
src/views/studio/studio-redux.js
Normal 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};
|
|
@ -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]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in a new issue