This commit is contained in:
Timo
2024-09-09 17:23:04 +02:00
parent ab457be4bb
commit f3404fbbf3
18 changed files with 121 additions and 129 deletions

View File

@@ -30,9 +30,8 @@ export function useWakeLock(): void {
// so we need to reacquire it on visibility changes
const onVisibilityChange = (): void => {
if (document.visibilityState === "visible") {
navigator.wakeLock
.request("screen")
.then((newLock) => {
navigator.wakeLock.request("screen").then(
(newLock) => {
lock = newLock;
// Handle the edge case where this component unmounts before the
// promise resolves
@@ -40,10 +39,11 @@ export function useWakeLock(): void {
lock
.release()
.catch((e) => logger.warn("Can't release wake lock", e));
})
.catch((e) => {
},
(e) => {
logger.warn("Can't acquire wake lock", e);
});
},
);
}
};