Skip to content

Conversation

@Deftera186
Copy link
Contributor

@Deftera186 Deftera186 commented Mar 31, 2025

- Implement `reacquireOnPageVisible` option in the hook
- Add tests to verify `reacquireOnPageVisible` functionality
- Solves issue jorisre#273
@vercel
Copy link

vercel bot commented Mar 31, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
react-screen-wake-lock ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 31, 2025 6:25pm

Added documentation and updated the usage example
Copy link
Owner

@jorisre jorisre left a comment

Choose a reason for hiding this comment

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

LGMT! Thanks for the contribution!

@jorisre jorisre merged commit 691f1fc into jorisre:main Apr 1, 2025
5 checks passed
@github-actions
Copy link

github-actions bot commented Apr 1, 2025

🎉 This PR is included in version 3.1.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

React.useEffect(() => {
if (reacquireOnPageVisible) {
const handleVisibilityChange = async () => {
if (wakeLock.current && document.visibilityState === 'visible') {
Copy link
Contributor

Choose a reason for hiding this comment

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

@Deftera186 @jorisre hey folks, I might be missing something here, but shouldn't this check for if (wakeLock.current === null && document.visibilityState === 'visible') instead?

Navigating away from the page triggers wakeLock.current.onrelease, which then sets wakeLock.current = null.

Returning to the page then should check for wakeLock.current === null, before attempting to reacquire the lock.

Copy link
Owner

Choose a reason for hiding this comment

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

Good catch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature Request: Re-Aquire Wakelock When User Returns to Page

3 participants