fix: wakelock error causing site to not load

This commit is contained in:
Mar0xy 2023-10-22 14:43:15 +02:00
parent 83be996a3d
commit 7c922dc39b
No known key found for this signature in database
GPG key ID: 56569BBE47D2C828

View file

@ -204,11 +204,19 @@ export async function common(createVue: () => App<Element>) {
if (defaultStore.state.keepScreenOn) { if (defaultStore.state.keepScreenOn) {
if ('wakeLock' in navigator) { if ('wakeLock' in navigator) {
try {
navigator.wakeLock.request('screen'); navigator.wakeLock.request('screen');
} catch (err) {
return;
}
document.addEventListener('visibilitychange', async () => { document.addEventListener('visibilitychange', async () => {
if (document.visibilityState === 'visible') { if (document.visibilityState === 'visible') {
try {
navigator.wakeLock.request('screen'); navigator.wakeLock.request('screen');
} catch (err) {
return;
}
} }
}); });
} }