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
1 changed files with 10 additions and 2 deletions

View File

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