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

Don't sleep mobile devices when fullscreen #11652

Merged
merged 1 commit into from
May 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
don't sleep mobile devices when fullscreen
  • Loading branch information
hawkeye217 committed May 30, 2024
commit 4023de386dd004a269ac344dd74fba7b72884d3b
6 changes: 6 additions & 0 deletions web/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
"lucide-react": "^0.379.0",
"monaco-yaml": "^5.1.1",
"next-themes": "^0.3.0",
"nosleep.js": "^0.12.0",
"react": "^18.3.1",
"react-apexcharts": "^1.4.1",
"react-day-picker": "^8.10.1",
Expand Down
5 changes: 5 additions & 0 deletions web/src/hooks/use-fullscreen.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import { RefObject, useCallback, useEffect, useState } from "react";
import nosleep from "nosleep.js";

const NoSleep = new nosleep();

function getFullscreenElement(): HTMLElement | null {
return (
Expand Down Expand Up @@ -96,9 +99,11 @@ export function useFullscreen<T extends HTMLElement = HTMLElement>(
const toggleFullscreen = useCallback(async () => {
try {
if (!getFullscreenElement()) {
NoSleep.enable();
await enterFullScreen(elementRef.current!);
} else {
await exitFullscreen();
NoSleep.disable();
}
setError(null);
} catch (err) {
Expand Down