From d4ad3c1421ea33ba69eb58a6cb22c947048503b7 Mon Sep 17 00:00:00 2001 From: Matej Vavrek Date: Wed, 18 Mar 2020 10:23:50 +0100 Subject: [PATCH] #120 changed way of sending image for issue creation --- js/components/userFeedback/githubApi.js | 10 +++++----- js/components/userFeedback/reportForm.js | 9 ++++++--- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/js/components/userFeedback/githubApi.js b/js/components/userFeedback/githubApi.js index 7ca49e491..ee0da0479 100644 --- a/js/components/userFeedback/githubApi.js +++ b/js/components/userFeedback/githubApi.js @@ -27,13 +27,13 @@ const getHeaders = () => { /** * Upload an image from form state */ -const uploadFile = (formState, formType) => async dispatch => { +const uploadFile = (imageSource, formType) => async dispatch => { console.log('uploading new file'); let screenshotUrl = ''; - if (formState.imageSource.length > 0) { + if (imageSource.length > 0) { // https://gist.github.com/maxisam/5c6ec10cc4146adce05d62f553c5062f - const imgBase64 = formState.imageSource.split(',')[1]; + const imgBase64 = imageSource.split(',')[1]; const uid = new Date().getTime() + parseInt(Math.random() * 1e6).toString(); const fileName = 'screenshot-' + uid + '.png'; @@ -63,10 +63,10 @@ const uploadFile = (formState, formType) => async dispatch => { /** * Create issue in GitHub (thunk actions are used to stored in dispatchActions.js) */ -export const createIssue = (formState, formType, labels, afterCreateIssueCallback) => async dispatch => { +export const createIssue = (formState, imageSource, formType, labels, afterCreateIssueCallback) => async dispatch => { dispatch(setResponse('')); - const screenshotUrl = await dispatch(uploadFile(formState, formType)); + const screenshotUrl = await dispatch(uploadFile(imageSource, formType)); let body = ['- Version: ' + version, '- Name: ' + formState.name, '- Description: ' + formState.description]; if (screenshotUrl.length > 0) { diff --git a/js/components/userFeedback/reportForm.js b/js/components/userFeedback/reportForm.js index 52bd65a13..221044637 100644 --- a/js/components/userFeedback/reportForm.js +++ b/js/components/userFeedback/reportForm.js @@ -229,7 +229,7 @@ export const ReportForm = memo(({ formType }) => { const getHintText = () => { let text = 'please choose your window or screen to share'; if (isFirefox()) { - text += ' and "Allow" it'; + text += ' (ideally enter fullscreen - F11) and "Allow" it'; } else if (isChrome()) { text += ', ideally "Chrome tab" and your current tab'; } @@ -292,9 +292,12 @@ export const ReportForm = memo(({ formType }) => { return errors; }} onSubmit={async (values, { setSubmitting }) => { + // dispatch(setImageSource(getCanvasDrawDataUrl(canvasDraw))); // does not update in time // set new image from drawing before creating issue - dispatch(setImageSource(getCanvasDrawDataUrl(canvasDraw))); - await dispatch(createIssue(formState, formType.toLowerCase(), getLabels(), afterCreateIssueCallback)); + const imageSource = getCanvasDrawDataUrl(canvasDraw); + await dispatch( + createIssue(formState, imageSource, formType.toLowerCase(), getLabels(), afterCreateIssueCallback) + ); setSubmitting(false); }} >