Use the project author username in visibility request instead of viewer

/ht @chrisgarrity
This commit is contained in:
Paul Kaplan 2018-11-21 10:31:10 -05:00
parent c18ccba646
commit 0b8c13fb40
2 changed files with 8 additions and 8 deletions

View file

@ -332,7 +332,7 @@ module.exports.setVisibilityInfo = visibilityInfo => ({
visibilityInfo: visibilityInfo visibilityInfo: visibilityInfo
}); });
module.exports.getProjectInfo = (id, username, token) => (dispatch => { module.exports.getProjectInfo = (id, token) => (dispatch => {
const opts = { const opts = {
uri: `/projects/${id}` uri: `/projects/${id}`
}; };
@ -356,16 +356,16 @@ module.exports.getProjectInfo = (id, username, token) => (dispatch => {
dispatch(module.exports.setProjectInfo(body)); dispatch(module.exports.setProjectInfo(body));
// If the project is not public, make a follow-up request for why // If the project is not public, make a follow-up request for why
if (username && !body.public) { if (!body.public) {
dispatch(module.exports.getVisibilityInfo(id, username, token)); dispatch(module.exports.getVisibilityInfo(id, body.author.username, token));
} }
}); });
}); });
module.exports.getVisibilityInfo = (id, username, token) => (dispatch => { module.exports.getVisibilityInfo = (id, ownerUsername, token) => (dispatch => {
dispatch(module.exports.setFetchStatus('visibility', module.exports.Status.FETCHING)); dispatch(module.exports.setFetchStatus('visibility', module.exports.Status.FETCHING));
api({ api({
uri: `/users/${username}/projects/${id}/visibility`, uri: `/users/${ownerUsername}/projects/${id}/visibility`,
authentication: token authentication: token
}, (err, body, response) => { }, (err, body, response) => {
if (err || !body || response.statusCode !== 200) { if (err || !body || response.statusCode !== 200) {

View file

@ -140,7 +140,7 @@ class Preview extends React.Component {
this.props.getTopLevelComments(this.state.projectId, this.props.comments.length, this.props.getTopLevelComments(this.state.projectId, this.props.comments.length,
this.props.isAdmin, token); this.props.isAdmin, token);
} }
this.props.getProjectInfo(this.state.projectId, username, 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.getProjectStudios(this.state.projectId, token);
this.props.getCuratedStudios(username); this.props.getCuratedStudios(username);
@ -715,8 +715,8 @@ const mapDispatchToProps = dispatch => ({
getParentInfo: id => { getParentInfo: id => {
dispatch(previewActions.getParentInfo(id)); dispatch(previewActions.getParentInfo(id));
}, },
getProjectInfo: (id, username, token) => { getProjectInfo: (id, token) => {
dispatch(previewActions.getProjectInfo(id, username, token)); dispatch(previewActions.getProjectInfo(id, token));
}, },
getRemixes: id => { getRemixes: id => {
dispatch(previewActions.getRemixes(id)); dispatch(previewActions.getRemixes(id));