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

Conversation

earl-warren
Copy link
Contributor

(cherry picked from commit 85048c96608004988f57a57358c9cda91f095e23)

- Utilize the existing `is-loading` class to prevent the submit code
from running twice or more.
- The `is-loading` class gives us a nice loading indicator when added to
the form.
- Resolves https://codeberg.org/forgejo/forgejo/issues/1476

(cherry picked from commit 85048c96608004988f57a57358c9cda91f095e23)
@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Nov 20, 2023
@pull-request-size pull-request-size bot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Nov 20, 2023
Comment on lines +48 to +49
if ($form.hasClass('is-loading')) return;
$form.addClass('is-loading');
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.

@GiteaBot GiteaBot added lgtm/blocked A maintainer has reservations with the PR and thus it cannot be merged and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Nov 20, 2023
Copy link
Contributor

@wxiaoguang wxiaoguang left a comment

Choose a reason for hiding this comment

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

This change is not right.

You only use straight code to do something, but some edge cases are not handled, which lead to bad user experience.

@delvh
Copy link
Member

delvh commented Nov 20, 2023

Which unimplemented edge cases do you see?

@wxiaoguang
Copy link
Contributor

-> #28143

At least 2 bugs here:

  1. The if (!validateTextareaNonEmpty($textArea)) return; , leave the is-loading forever.
  2. After success/error, leave the is-loading forever.

@lunny
Copy link
Member

lunny commented Nov 21, 2023

replaced by #28143

@lunny lunny closed this Nov 21, 2023
@go-gitea go-gitea locked as resolved and limited conversation to collaborators Feb 19, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lgtm/blocked A maintainer has reservations with the PR and thus it cannot be merged size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants