mirror of
https://github.com/scratchfoundation/scratch-www.git
synced 2024-11-23 07:38:07 -05:00
Merge pull request #2925 from benjiwheeler/retry-studios-for-project-endpoint
change studios for project API request to use admin status, owner status and token
This commit is contained in:
commit
4fe1bd907e
2 changed files with 14 additions and 8 deletions
|
@ -763,11 +763,16 @@ 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));
|
dispatch(module.exports.setFetchStatus('projectStudios', module.exports.Status.FETCHING));
|
||||||
api({
|
const opts = {
|
||||||
uri: `/projects/${id}/studios`
|
uri: `${isAdmin ? '/admin' : `/users/${ownerUsername}`}/projects/${id}/studios`
|
||||||
}, (err, body, res) => {
|
};
|
||||||
|
if (token) {
|
||||||
|
Object.assign(opts, {authentication: token});
|
||||||
|
}
|
||||||
|
api(opts, (err, body, res) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
dispatch(module.exports.setFetchStatus('projectStudios', module.exports.Status.ERROR));
|
dispatch(module.exports.setFetchStatus('projectStudios', module.exports.Status.ERROR));
|
||||||
dispatch(module.exports.setError(err));
|
dispatch(module.exports.setError(err));
|
||||||
|
|
|
@ -160,7 +160,10 @@ class Preview extends React.Component {
|
||||||
if (typeof this.props.projectInfo.id === 'undefined') {
|
if (typeof this.props.projectInfo.id === 'undefined') {
|
||||||
this.initCounts(0, 0);
|
this.initCounts(0, 0);
|
||||||
} else {
|
} else {
|
||||||
|
const token = this.props.user ? this.props.user.token : null;
|
||||||
this.initCounts(this.props.projectInfo.stats.favorites, this.props.projectInfo.stats.loves);
|
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) {
|
if (this.props.projectInfo.remix.parent !== null) {
|
||||||
this.props.getParentInfo(this.props.projectInfo.remix.parent);
|
this.props.getParentInfo(this.props.projectInfo.remix.parent);
|
||||||
}
|
}
|
||||||
|
@ -216,7 +219,6 @@ class Preview extends React.Component {
|
||||||
}
|
}
|
||||||
this.props.getProjectInfo(this.state.projectId, token);
|
this.props.getProjectInfo(this.state.projectId, token);
|
||||||
this.props.getRemixes(this.state.projectId, token);
|
this.props.getRemixes(this.state.projectId, token);
|
||||||
this.props.getProjectStudios(this.state.projectId, token);
|
|
||||||
this.props.getCuratedStudios(username);
|
this.props.getCuratedStudios(username);
|
||||||
this.props.getFavedStatus(this.state.projectId, username, token);
|
this.props.getFavedStatus(this.state.projectId, username, token);
|
||||||
this.props.getLovedStatus(this.state.projectId, username, token);
|
this.props.getLovedStatus(this.state.projectId, username, token);
|
||||||
|
@ -228,7 +230,6 @@ class Preview extends React.Component {
|
||||||
}
|
}
|
||||||
this.props.getProjectInfo(this.state.projectId);
|
this.props.getProjectInfo(this.state.projectId);
|
||||||
this.props.getRemixes(this.state.projectId);
|
this.props.getRemixes(this.state.projectId);
|
||||||
this.props.getProjectStudios(this.state.projectId);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
setScreenFromOrientation () {
|
setScreenFromOrientation () {
|
||||||
|
@ -984,8 +985,8 @@ const mapDispatchToProps = dispatch => ({
|
||||||
getRemixes: id => {
|
getRemixes: id => {
|
||||||
dispatch(previewActions.getRemixes(id));
|
dispatch(previewActions.getRemixes(id));
|
||||||
},
|
},
|
||||||
getProjectStudios: id => {
|
getProjectStudios: (id, ownerUsername, isAdmin, token) => {
|
||||||
dispatch(previewActions.getProjectStudios(id));
|
dispatch(previewActions.getProjectStudios(id, ownerUsername, isAdmin, token));
|
||||||
},
|
},
|
||||||
getCuratedStudios: (username, token) => {
|
getCuratedStudios: (username, token) => {
|
||||||
dispatch(previewActions.getCuratedStudios(username, token));
|
dispatch(previewActions.getCuratedStudios(username, token));
|
||||||
|
|
Loading…
Reference in a new issue