From 4e8ea5c3bd7d0cfdade2ad12e161deda03bc59e0 Mon Sep 17 00:00:00 2001 From: Paul Kaplan Date: Fri, 15 Feb 2019 14:27:36 -0500 Subject: [PATCH] Get thumbnails from the project for reporting --- src/redux/preview.js | 5 ++--- src/views/preview/presentation.jsx | 3 +++ src/views/preview/project-view.jsx | 15 ++++++++++++++- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/redux/preview.js b/src/redux/preview.js index 12a06ba7b..0a3eb2a5d 100644 --- a/src/redux/preview.js +++ b/src/redux/preview.js @@ -954,9 +954,8 @@ module.exports.shareProject = (projectId, token) => (dispatch => { module.exports.reportProject = (id, jsonData, token) => (dispatch => { dispatch(module.exports.setFetchStatus('report', module.exports.Status.FETCHING)); - // scratchr2 will fail if no thumbnail base64 string provided. We don't yet have - // a way to get the actual project thumbnail in www/gui, so for now just submit - // a minimal base64 png string. + // scratchr2 will fail if no thumbnail base64 string provided. If there is not one + // included for any reason, include this minimal blank image. defaults(jsonData, { thumbnail: 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC' + '0lEQVR42mP8/x8AAwMCAO+ip1sAAAAASUVORK5CYII=' diff --git a/src/views/preview/presentation.jsx b/src/views/preview/presentation.jsx index d6cae775a..e0234396a 100644 --- a/src/views/preview/presentation.jsx +++ b/src/views/preview/presentation.jsx @@ -106,6 +106,7 @@ const PreviewPresentation = ({ onRestoreComment, onSeeAllComments, onSeeInside, + onSetProjectThumbnailer, onShare, onToggleComments, onToggleStudio, @@ -341,6 +342,7 @@ const PreviewPresentation = ({ onGreenFlag={onGreenFlag} onProjectLoaded={onProjectLoaded} onRemixing={onRemixing} + onSetProjectThumbnailer={onSetProjectThumbnailer} onUpdateProjectId={onUpdateProjectId} onUpdateProjectThumbnail={onUpdateProjectThumbnail} /> @@ -709,6 +711,7 @@ PreviewPresentation.propTypes = { onRestoreComment: PropTypes.func, onSeeAllComments: PropTypes.func, onSeeInside: PropTypes.func, + onSetProjectThumbnailer: PropTypes.func, onShare: PropTypes.func, onToggleComments: PropTypes.func, onToggleStudio: PropTypes.func, diff --git a/src/views/preview/project-view.jsx b/src/views/preview/project-view.jsx index 75a3b1f89..abcd8971e 100644 --- a/src/views/preview/project-view.jsx +++ b/src/views/preview/project-view.jsx @@ -79,6 +79,7 @@ class Preview extends React.Component { 'handleRemix', 'handleSeeAllComments', 'handleSeeInside', + 'handleSetProjectThumbnailer', 'handleShare', 'handleUpdateProjectId', 'handleUpdateProjectTitle', @@ -381,7 +382,18 @@ class Preview extends React.Component { this.setState({addToStudioOpen: false}); } handleReportSubmit (formData) { - this.props.reportProject(this.state.projectId, formData, this.props.user.token); + const submit = data => this.props.reportProject(this.state.projectId, data, this.props.user.token); + if (this.getProjectThumbnail) { + this.getProjectThumbnail(thumbnail => { + const data = Object.assign({}, formData, {thumbnail}); + submit(data); + }); + } else { + submit(formData); + } + } + handleSetProjectThumbnailer (fn) { + this.getProjectThumbnail = fn; } handleGreenFlag () { if (!this.state.greenFlagRecorded) { @@ -690,6 +702,7 @@ class Preview extends React.Component { onRestoreComment={this.handleRestoreComment} onSeeAllComments={this.handleSeeAllComments} onSeeInside={this.handleSeeInside} + onSetProjectThumbnailer={this.handleSetProjectThumbnailer} onShare={this.handleShare} onToggleComments={this.handleToggleComments} onToggleStudio={this.handleToggleStudio}