Skip to content

Commit ae6e45c

Browse files
committed
Fetch only students in ProjectEditor
Commit c6546c7 ("Fetch users in project editor") overzealously fetched all users when this component was mounted; whilst this resulted in the correct behaviour, each user fetched results in a network request, so it's ideal to keep the number of users requested as low as possible. This is achieved by only asking the backend for users who can actually join a project.
1 parent 7652ee8 commit ae6e45c

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/components/project_editor.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ import {DropdownButton, MenuItem} from 'react-bootstrap';
2727
import update from 'immutability-helper';
2828
import Alert from 'react-s-alert';
2929
import 'react-confirm-alert/src/react-confirm-alert.css'
30-
import {fetchAllUsers} from '../actions/users';
30+
import {joinProjects} from '../constants';
31+
import {fetchUsersWithPermissions} from '../actions/users';
3132
import styledAlert from '../components/styledAlert';
3233
import './project_editor.css';
3334

@@ -46,7 +47,7 @@ class ProjectEditor extends Component {
4647
}
4748

4849
async componentDidMount() {
49-
this.props.fetchAllUsers();
50+
this.props.fetchUsersWithPermissions([joinProjects]);
5051
}
5152

5253
submitCheck() {
@@ -246,7 +247,7 @@ const mapStateToProps = state => ({
246247
})
247248

248249
const mapDispatchToProps = {
249-
fetchAllUsers,
250+
fetchUsersWithPermissions,
250251
}
251252

252253
export default connect(

0 commit comments

Comments
 (0)