Skip to content

keep phone awake on timer#305

Merged
spring1843 merged 15 commits into
mainfrom
keep-phone-awak
Jun 30, 2026
Merged

keep phone awake on timer#305
spring1843 merged 15 commits into
mainfrom
keep-phone-awak

Conversation

@spring1843

Copy link
Copy Markdown
Owner
  • Timer app attempts to stop phone from going to sleep so user can continue to see the timer

Copilot AI review requested due to automatic review settings June 30, 2026 01:46
@netlify

netlify Bot commented Jun 30, 2026

Copy link
Copy Markdown

Deploy Preview for freedevtool ready!

Name Link
🔨 Latest commit 026959c
🔍 Latest deploy log https://app.netlify.com/projects/freedevtool/deploys/6a432cb397fe1e0008359c49
😎 Deploy Preview https://deploy-preview-305--freedevtool.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR adds screen wake-lock support to the Timer tool so the device is less likely to sleep while timers are running, improving usability for long-running countdowns.

Changes:

  • Introduces a new useWakeLock hook wrapping the Screen Wake Lock API.
  • Integrates the hook into the Timer page to request/release wake locks based on timer activity.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 6 comments.

File Description
client/src/pages/tools/timer.tsx Requests/releases a wake lock based on whether any timer is running.
client/src/hooks/use-wake-lock.ts New hook encapsulating wake lock request/release and visibility handling.

Comment thread client/src/pages/tools/timer.tsx Outdated
Comment thread client/src/hooks/use-wake-lock.ts
Comment thread client/src/hooks/use-wake-lock.ts
Comment thread client/src/hooks/use-wake-lock.ts
Comment thread client/src/hooks/use-wake-lock.ts
Comment thread client/src/hooks/use-wake-lock.ts Outdated
spring1843 and others added 5 commits June 29, 2026 18:53
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

Comment thread client/src/hooks/use-wake-lock.ts
Comment thread client/src/hooks/use-wake-lock.ts
Comment thread client/src/hooks/use-wake-lock.ts Outdated
Comment thread client/src/pages/tools/timer.tsx Outdated
spring1843 and others added 4 commits June 29, 2026 19:07
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

Comment thread client/src/pages/tools/timer.tsx
Comment thread client/src/hooks/use-wake-lock.ts
Comment thread client/src/hooks/use-wake-lock.ts
spring1843 and others added 4 commits June 29, 2026 19:16
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

Comment thread client/src/hooks/use-wake-lock.ts

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

Comment on lines +78 to +87
// Effect to manage the wake lock
useEffect(() => {
const hasRunningTimers = timers.some(timer => timer.isRunning);

if (hasRunningTimers) {
void requestWakeLock();
} else {
void releaseWakeLock();
}
}, [timers, isLocked, requestWakeLock, releaseWakeLock]);
Comment on lines +28 to +44
shouldHoldLock.current = true;

if (wakeLock.current || requestInFlight.current) {
return;
}

requestInFlight.current = true;

try {
const sentinel = await navigator.wakeLock.request("screen");

// If release() was called while the request was in flight,
// release the new sentinel immediately and do nothing.
if (!shouldHoldLock.current) {
void sentinel.release();
return;
}
Comment on lines +103 to +108
shouldHoldLock.current = false;
const sentinel = wakeLock.current;
wakeLock.current = null;
requestInFlight.current = false;
void sentinel?.release();
};
@spring1843
spring1843 merged commit ca0ea0f into main Jun 30, 2026
6 checks passed
@spring1843
spring1843 deleted the keep-phone-awak branch June 30, 2026 02:51
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.

2 participants