-
Notifications
You must be signed in to change notification settings - Fork 18
Clean up CldVideoPlayer and CldUploadWidget on astro:before-swap #126
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
Clean up CldVideoPlayer and CldUploadWidget on astro:before-swap #126
Conversation
Closes #10. This commit also fixes #90. Signed-off-by: Eng Zer Jun <[email protected]>
|
@Juneezee is attempting to deploy a commit to the Cloudinary DevX Team on Vercel. A member of the Team first needs to authorize it. |
Juneezee
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have performed a self-review of my code changes.
/cc @jlooper-cloudinary @devpatocld @eportis-cloudinary Please take a look. Thanks 😊
| window.addEventListener('load', state.initialise); | ||
|
|
||
| // Lifecycle events, requires <ClientRouter /> | ||
| // https://docs.astro.build/en/guides/view-transitions/#lifecycle-events | ||
| document.addEventListener('astro:after-swap', state.reset); | ||
| document.addEventListener('astro:page-load', state.initialise); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
document.addEventListener('astro:page-load', state.initialise);This is the line that fixes #90.
I am aware of another PR attempt at #99. However, that PR is insufficient because both the load event and the astro:page-load event are fired on the first page load (e.g., when you click the refresh button). Therefore, it is necessary to use a function like the useState() function above, which relies on closures
to define initialization variables and ensure that initialization runs only once.
|
@devpatocld @jlooper-cloudinary @eportis-cloudinary Will this be reviewed before October ends? 🥹 |
hi, it's under review now, please be patient. |
|
@devpatocld @jlooper-cloudinary Just a quick follow-up. This PR didn't get merged in time before the end of October. Does that mean I'm no longer eligible for the swag kit? Thanks for clarifying! |
|
Hi @Juneezee! Thank you for this thoughtful and well-authored PR, and apologies for the tardy delay. I've just put it through the paces and it does indeed solve both issues, in a clean way. Merging. I'm adding the necessary tags so that you receive swag for your Hacktoberfest contribution. Thank you!! |
|
@all-contributors please add @Juneezee for code |
|
I've put up a pull request to add @Juneezee! 🎉 |
Description
This PR adds cleanup handling for the
<CldUploadWidget />and<CldVideoPlayer />components on theastro:before-swapevent.Reference: https://cloudinary.com/documentation/upload_widget_reference#destroy
Reference: https://cloudinary.com/documentation/video_player_api_reference#dispose
Reference: https://docs.astro.build/en/guides/view-transitions/#astrobefore-swap
I created 3 minimal files locally to verify the changes:
Here is a screen recording of the testing performed with debugging
console.logstatements:2025-10-01.10-58-07.mp4
Issue Ticket Number
Closes #10.
This commit also fixes #90.
Type of change
Checklist