Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent multiple codecomments to be submitted #28139

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions web_src/js/features/repo-diff.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ function initRepoDiffConversationForm() {
e.preventDefault();

const $form = $(e.target);
if ($form.hasClass('is-loading')) return;
$form.addClass('is-loading');
Comment on lines +48 to +49
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes and no.
That class exists but is used for content that has not yet been loaded, not to click buttons only once.
There is a class that ensures buttons/forms are only submitted once.
I think it is form-fetch-action for forms or link-action for buttons/links.
Please use the correct class instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The form-fetch-action uses this https://github.com/go-gitea/gitea/blob/main/web_src/js/features/common-global.js#L114-L116 and we cannot use form-fetch-action because the code comments has custom javascript code, which is initRepoDiffConversationForm.

Am I missing something?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, as @wxiaoguang pointed out in #28143, is-loading seems to be correct.
Sorry for that.
Anyway, #28143 does look better to me at the moment as it does not deadlock itself.


const $textArea = $form.find('textarea');
if (!validateTextareaNonEmpty($textArea)) {
return;
Expand Down