Skip to content

Commit

Permalink
#120 changed way of sending image for issue creation
Browse files Browse the repository at this point in the history
  • Loading branch information
matej-vavrek committed Mar 19, 2020
1 parent 692a964 commit f3bd011
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
10 changes: 5 additions & 5 deletions js/components/userFeedback/githubApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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) {
Expand Down
9 changes: 6 additions & 3 deletions js/components/userFeedback/reportForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
}
Expand Down Expand Up @@ -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);
}}
>
Expand Down

0 comments on commit f3bd011

Please sign in to comment.