Skip to content

Commit 049b91c

Browse files
committed
New getCurrentProjectInstructions selector
1 parent df07ca0 commit 049b91c

5 files changed

Lines changed: 17 additions & 7 deletions

File tree

src/containers/Dashboard.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,18 @@ import {
55
exportRepo,
66
} from '../actions';
77
import {
8-
getCurrentProject,
8+
getCurrentProjectInstructions,
99
getCurrentUser,
1010
isDashboardOpen,
1111
isExperimental,
1212
isGistExportInProgress,
1313
} from '../selectors';
1414

1515
function mapStateToProps(state) {
16-
const project = getCurrentProject(state);
1716
return {
1817
currentUser: getCurrentUser(state),
1918
gistExportInProgress: isGistExportInProgress(state),
20-
instructions: project ? project.instructions : '',
19+
instructions: getCurrentProjectInstructions(state),
2120
isExperimental: isExperimental(state),
2221
isOpen: isDashboardOpen(state),
2322
};

src/selectors/getCurrentProject.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
import {createSelector} from 'reselect';
22
import getCurrentProjectKey from './getCurrentProjectKey';
3-
4-
function getProjects(state) {
5-
return state.get('projects');
6-
}
3+
import getProjects from './getProjects';
74

85
export default createSelector(
96
[getCurrentProjectKey, getProjects],
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import {createSelector} from 'reselect';
2+
import getCurrentProjectKey from './getCurrentProjectKey';
3+
import getProjects from './getProjects';
4+
5+
export default createSelector(
6+
[getCurrentProjectKey, getProjects],
7+
(projectKey, projects) =>
8+
projectKey ? projects.getIn([projectKey, 'instructions']) : '',
9+
);

src/selectors/getProjects.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export default function getProjects(state) {
2+
return state.get('projects');
3+
}

src/selectors/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import getAllProjectKeys from './getAllProjectKeys';
22
import getAllProjects from './getAllProjects';
33
import getCurrentProject from './getCurrentProject';
4+
import getCurrentProjectInstructions from './getCurrentProjectInstructions';
45
import getCurrentProjectKey from './getCurrentProjectKey';
56
import getCurrentUser from './getCurrentUser';
67
import getCurrentUserId from './getCurrentUserId';
@@ -27,6 +28,7 @@ export {
2728
getAllProjectKeys,
2829
getAllProjects,
2930
getCurrentProject,
31+
getCurrentProjectInstructions,
3032
getCurrentProjectKey,
3133
getCurrentUser,
3234
getCurrentUserId,

0 commit comments

Comments
 (0)