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

trigger an error if the api script is not loaded #138

Merged
merged 7 commits into from
Jun 30, 2022
Merged

trigger an error if the api script is not loaded #138

merged 7 commits into from
Jun 30, 2022

Conversation

andrepolischuk
Copy link
Contributor

also I rewrited mounting the api script with global Promise to fix case with multiple captchas. if multiple captchas are using, handleOnLoad callback is pushed to the onLoadListeners only for first component. next captchas in componentDidMount have apiScriptRequested true, so handleOnLoad is not adding to callback's array

@andrepolischuk
Copy link
Contributor Author

@zoryana94 @DSergiu hi, could you take a look at this pr?

@andrepolischuk
Copy link
Contributor Author

@zoryana94 @DSergiu ping

src/index.js Outdated Show resolved Hide resolved
src/index.js Outdated Show resolved Hide resolved
@brdlyptrs
Copy link
Collaborator

Hi @andrepolischuk thanks for the PR. Looks pretty good overall, I've added a few comments above.

src/index.js Outdated Show resolved Hide resolved
@brdlyptrs
Copy link
Collaborator

One last note, looks good!

Just to confirm, as it looks like it, this update will handle multiple hCaptcha components loading at the same time waiting for the script tag to load correct?

@andrepolischuk
Copy link
Contributor Author

Just to confirm, as it looks like it, this update will handle multiple hCaptcha components loading at the same time waiting for the script tag to load correct?

yes. first instance of the component mounts the script and waits promise (in module root) to handle onload. the rest of instances check mounted script in dom, and wait the same promise to handle onload.

@brdlyptrs
Copy link
Collaborator

I think we can bump this version to 1.3.1 and then merge.

@andrepolischuk
Copy link
Contributor Author

andrepolischuk commented Jun 27, 2022

@brdlyptrs I pulled latest master into this branch

@andrepolischuk
Copy link
Contributor Author

@brdlyptrs are you planning to publish this soon?

@zoryana94
Copy link
Contributor

@brdlyptrs are you planning to publish this soon?

Hi @andrepolischuk,
I'm going to merge it today. We'll probably need your assistance in testing.
Thank you a lot for your work! And sorry that it took a bit longer than expected.

Copy link
Collaborator

@brdlyptrs brdlyptrs left a comment

Choose a reason for hiding this comment

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

We can version bump separately.

@zoryana94 zoryana94 merged commit 2b93013 into hCaptcha:master Jun 30, 2022
@andrepolischuk andrepolischuk deleted the api-loading-error branch June 30, 2022 09:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants