Commit b4415113 authored by Timothy J. Baek's avatar Timothy J. Baek
Browse files

enh: wake lock

parent 3af8c5b0
......@@ -36,6 +36,8 @@
let loaded = false;
const BREAKPOINT = 768;
let wakeLock = null;
onMount(async () => {
theme.set(localStorage.theme);
......@@ -50,6 +52,31 @@
window.addEventListener('resize', onResize);
const setWakeLock = async () => {
try {
wakeLock = await navigator.wakeLock.request('screen');
} catch (err) {
// The Wake Lock request has failed - usually system related, such as battery.
console.log(err);
}
wakeLock.addEventListener('release', () => {
// the wake lock has been released
console.log('Wake Lock released');
});
};
if ('wakeLock' in navigator) {
await setWakeLock();
document.addEventListener('visibilitychange', async () => {
// Re-request the wake lock if the document becomes visible
if (wakeLock !== null && document.visibilityState === 'visible') {
await setWakeLock();
}
});
}
let backendConfig = null;
try {
backendConfig = await getBackendConfig();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment