diff --git a/src/redux/preview.js b/src/redux/preview.js index 01ee7cf08..4fbf21241 100644 --- a/src/redux/preview.js +++ b/src/redux/preview.js @@ -763,15 +763,12 @@ module.exports.getRemixes = id => (dispatch => { }); }); -module.exports.getProjectStudios = (id, username, token) => (dispatch => { +module.exports.getProjectStudios = (id, ownerUsername, isAdmin, token) => (dispatch => { dispatch(module.exports.setFetchStatus('projectStudios', module.exports.Status.FETCHING)); - const apiOpts = { - uri: `/users/${username}/projects/${id}/studios` - }; - if (token) { - apiOpts.authentication = token; - } - api(apiOpts, (err, body, res) => { + api({ + uri: `${isAdmin ? '/admin' : `/users/${ownerUsername}`}/projects/${id}/studios`, + authentication: token + }, (err, body, res) => { if (err) { dispatch(module.exports.setFetchStatus('projectStudios', module.exports.Status.ERROR)); dispatch(module.exports.setError(err)); diff --git a/src/views/preview/project-view.jsx b/src/views/preview/project-view.jsx index 4d8f3833d..28a941c06 100644 --- a/src/views/preview/project-view.jsx +++ b/src/views/preview/project-view.jsx @@ -159,9 +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.user.token); + this.props.authorUsername, this.props.isAdmin, token); if (this.props.projectInfo.remix.parent !== null) { this.props.getParentInfo(this.props.projectInfo.remix.parent); } @@ -980,8 +981,8 @@ const mapDispatchToProps = dispatch => ({ getRemixes: id => { dispatch(previewActions.getRemixes(id)); }, - getProjectStudios: (id, username, token) => { - dispatch(previewActions.getProjectStudios(id, username, token)); + getProjectStudios: (id, ownerUsername, isAdmin, token) => { + dispatch(previewActions.getProjectStudios(id, ownerUsername, isAdmin, token)); }, getCuratedStudios: (username, token) => { dispatch(previewActions.getCuratedStudios(username, token));