Merge pull request #2858 from benjiwheeler/studios-for-project-endpoint

change "studios for project" API request to include owner & token, determine endpoint using admin status
This commit is contained in:
Benjamin Wheeler 2019-03-25 13:38:27 -04:00 committed by GitHub
commit a3902acfd1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 6 deletions

View file

@ -763,10 +763,11 @@ module.exports.getRemixes = id => (dispatch => {
});
});
module.exports.getProjectStudios = id => (dispatch => {
module.exports.getProjectStudios = (id, ownerUsername, isAdmin, token) => (dispatch => {
dispatch(module.exports.setFetchStatus('projectStudios', module.exports.Status.FETCHING));
api({
uri: `/projects/${id}/studios`
uri: `${isAdmin ? '/admin' : `/users/${ownerUsername}`}/projects/${id}/studios`,
authentication: token
}, (err, body, res) => {
if (err) {
dispatch(module.exports.setFetchStatus('projectStudios', module.exports.Status.ERROR));

View file

@ -159,7 +159,10 @@ class Preview extends React.Component {
if (typeof this.props.projectInfo.id === 'undefined') {
this.initCounts(0, 0);
} else {
const token = this.props.user ? this.props.user.token : null;
this.initCounts(this.props.projectInfo.stats.favorites, this.props.projectInfo.stats.loves);
this.props.getProjectStudios(this.props.projectInfo.id,
this.props.authorUsername, this.props.isAdmin, token);
if (this.props.projectInfo.remix.parent !== null) {
this.props.getParentInfo(this.props.projectInfo.remix.parent);
}
@ -215,7 +218,6 @@ class Preview extends React.Component {
}
this.props.getProjectInfo(this.state.projectId, token);
this.props.getRemixes(this.state.projectId, token);
this.props.getProjectStudios(this.state.projectId, token);
this.props.getCuratedStudios(username);
this.props.getFavedStatus(this.state.projectId, username, token);
this.props.getLovedStatus(this.state.projectId, username, token);
@ -227,7 +229,6 @@ class Preview extends React.Component {
}
this.props.getProjectInfo(this.state.projectId);
this.props.getRemixes(this.state.projectId);
this.props.getProjectStudios(this.state.projectId);
}
}
setScreenFromOrientation () {
@ -980,8 +981,8 @@ const mapDispatchToProps = dispatch => ({
getRemixes: id => {
dispatch(previewActions.getRemixes(id));
},
getProjectStudios: id => {
dispatch(previewActions.getProjectStudios(id));
getProjectStudios: (id, ownerUsername, isAdmin, token) => {
dispatch(previewActions.getProjectStudios(id, ownerUsername, isAdmin, token));
},
getCuratedStudios: (username, token) => {
dispatch(previewActions.getCuratedStudios(username, token));