From 0b8c13fb401029857b12649e740ab531928a1517 Mon Sep 17 00:00:00 2001 From: Paul Kaplan Date: Wed, 21 Nov 2018 10:31:10 -0500 Subject: [PATCH] Use the project author username in visibility request instead of viewer /ht @chrisgarrity --- src/redux/preview.js | 10 +++++----- src/views/preview/preview.jsx | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/redux/preview.js b/src/redux/preview.js index e4f234bfd..fccdc0830 100644 --- a/src/redux/preview.js +++ b/src/redux/preview.js @@ -332,7 +332,7 @@ module.exports.setVisibilityInfo = visibilityInfo => ({ visibilityInfo: visibilityInfo }); -module.exports.getProjectInfo = (id, username, token) => (dispatch => { +module.exports.getProjectInfo = (id, token) => (dispatch => { const opts = { uri: `/projects/${id}` }; @@ -356,16 +356,16 @@ module.exports.getProjectInfo = (id, username, token) => (dispatch => { dispatch(module.exports.setProjectInfo(body)); // If the project is not public, make a follow-up request for why - if (username && !body.public) { - dispatch(module.exports.getVisibilityInfo(id, username, token)); + if (!body.public) { + 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)); api({ - uri: `/users/${username}/projects/${id}/visibility`, + uri: `/users/${ownerUsername}/projects/${id}/visibility`, authentication: token }, (err, body, response) => { if (err || !body || response.statusCode !== 200) { diff --git a/src/views/preview/preview.jsx b/src/views/preview/preview.jsx index 3fa9279f0..9a1a33f1f 100644 --- a/src/views/preview/preview.jsx +++ b/src/views/preview/preview.jsx @@ -140,7 +140,7 @@ class Preview extends React.Component { this.props.getTopLevelComments(this.state.projectId, this.props.comments.length, 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.getProjectStudios(this.state.projectId, token); this.props.getCuratedStudios(username); @@ -715,8 +715,8 @@ const mapDispatchToProps = dispatch => ({ getParentInfo: id => { dispatch(previewActions.getParentInfo(id)); }, - getProjectInfo: (id, username, token) => { - dispatch(previewActions.getProjectInfo(id, username, token)); + getProjectInfo: (id, token) => { + dispatch(previewActions.getProjectInfo(id, token)); }, getRemixes: id => { dispatch(previewActions.getRemixes(id));