Skip to content

Commit 70832d3

Browse files
committed
prevent comment on uploading
1 parent c4b2808 commit 70832d3

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

web_src/js/features/comp/EditorUpload.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,11 @@ async function handleUploadFiles(editor, dropzoneEl, files, e) {
9999
const {width, dppx} = await imageInfo(file);
100100
const placeholder = `[${name}](uploading ...)`;
101101

102-
editor.insertPlaceholder(placeholder);
102+
// Placeholders should be inserted on uploading the thumnail.
103+
// If not, the check upload process may fail
104+
dropzoneEl.dropzone.on('thumbnail', () => {
105+
editor.insertPlaceholder(placeholder);
106+
});
103107
await uploadFile(dropzoneEl, file); // the "file" will get its "uuid" during the upload
104108
editor.replacePlaceholder(placeholder, generateMarkdownLinkForAttachment(file, {width, dppx}));
105109
}

web_src/js/features/repo-issue.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -671,11 +671,13 @@ export async function initSingleCommentEditor($commentForm) {
671671
const commentButton = document.querySelector('#comment-button');
672672
opts.onContentChanged = (editor) => {
673673
const editorText = editor.value().trim();
674+
const isUploading = editor.attachedDropzoneInst.getUploadingFiles().length != 0;
675+
674676
if (statusButton) {
675677
statusButton.textContent = statusButton.getAttribute(editorText ? 'data-status-and-comment' : 'data-status');
676678
}
677679
if (commentButton) {
678-
commentButton.disabled = !editorText;
680+
commentButton.disabled = !editorText || isUploading;
679681
}
680682
};
681683
const editor = await initComboMarkdownEditor($commentForm.find('.combo-markdown-editor'), opts);

0 commit comments

Comments
 (0)