pass onGreenFlag to GUI; when called, call API to register project view

This commit is contained in:
Ben Wheeler 2018-12-06 15:58:48 -05:00
parent 5235cb2ecc
commit 5c3300dd68
3 changed files with 27 additions and 0 deletions

View file

@ -884,3 +884,17 @@ module.exports.updateProjectThumbnail = (id, blob) => (dispatch => {
dispatch(module.exports.setFetchStatus('project-thumbnail', module.exports.Status.FETCHED));
});
});
module.exports.logProjectView = (id, username) => (dispatch => {
dispatch(module.exports.setFetchStatus('project-log-view', module.exports.Status.FETCHING));
api({
uri: `/users/${username}/projects/${id}/views`,
method: 'POST'
}, (err, body, res) => {
if (err || res.statusCode !== 200) {
dispatch(module.exports.setFetchStatus('project-log-view', module.exports.Status.ERROR));
return;
}
dispatch(module.exports.setFetchStatus('project-log-view', module.exports.Status.FETCHED));
});
});

View file

@ -84,6 +84,7 @@ const PreviewPresentation = ({
onCopyProjectLink,
onDeleteComment,
onFavoriteClicked,
onGreenFlag,
onLoadMore,
onLoveClicked,
onOpenAdminPanel,
@ -287,6 +288,7 @@ const PreviewPresentation = ({
previewInfoVisible="false"
projectHost={projectHost}
projectId={projectId}
onGreenFlag={onGreenFlag}
onRemixing={onRemixing}
onUpdateProjectId={onUpdateProjectId}
/>
@ -620,6 +622,7 @@ PreviewPresentation.propTypes = {
onCopyProjectLink: PropTypes.func,
onDeleteComment: PropTypes.func,
onFavoriteClicked: PropTypes.func,
onGreenFlag: PropTypes.func,
onLoadMore: PropTypes.func,
onLoveClicked: PropTypes.func,
onOpenAdminPanel: PropTypes.func,

View file

@ -59,6 +59,7 @@ class Preview extends React.Component {
'handleRestoreComment',
'handleAddToStudioClick',
'handleAddToStudioClose',
'handleGreenFlag',
'handleRemix',
'handleSeeAllComments',
'handleSeeInside',
@ -341,6 +342,9 @@ class Preview extends React.Component {
handleReportSubmit (formData) {
this.props.reportProject(this.state.projectId, formData, this.props.user.token);
}
handleGreenFlag () {
this.props.logProjectView(this.props.projectInfo.id, this.props.user.username);
}
handlePopState () {
const path = window.location.pathname.toLowerCase();
const playerMode = path.indexOf('editor') === -1;
@ -586,6 +590,7 @@ class Preview extends React.Component {
onCopyProjectLink={this.handleCopyProjectLink}
onDeleteComment={this.handleDeleteComment}
onFavoriteClicked={this.handleFavoriteToggle}
onGreenFlag={this.handleGreenFlag}
onLoadMore={this.handleLoadMore}
onLoveClicked={this.handleLoveToggle}
onOpenAdminPanel={this.handleOpenAdminPanel}
@ -629,6 +634,7 @@ class Preview extends React.Component {
projectId={this.state.projectId}
projectTitle={this.props.projectInfo.title}
renderLogin={this.renderLogin}
onGreenFlag={this.handleGreenFlag}
onLogOut={this.props.handleLogOut}
onOpenRegistration={this.props.handleOpenRegistration}
onRemixing={this.handleIsRemixing}
@ -694,6 +700,7 @@ Preview.propTypes = {
isNewScratcher: PropTypes.bool,
isScratcher: PropTypes.bool,
isShared: PropTypes.bool,
logProjectView: PropTypes.func,
loved: PropTypes.bool,
moreCommentsToLoad: PropTypes.bool,
original: projectShape,
@ -883,6 +890,9 @@ const mapDispatchToProps = dispatch => ({
getLovedStatus: (id, username, token) => {
dispatch(previewActions.getLovedStatus(id, username, token));
},
logProjectView: (id, username) => {
dispatch(previewActions.logProjectView(id, username));
},
setLovedStatus: (loved, id, username, token) => {
dispatch(previewActions.setLovedStatus(loved, id, username, token));
},