1
0
mirror of https://github.com/MisskeyIO/misskey synced 2024-11-27 22:38:30 +09:00

fix: wake lock error in safari etc (#12464)

This commit is contained in:
ragujp 2023-11-26 23:35:53 +09:00 committed by GitHub
parent d60f645d1d
commit 780b120c64
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -204,12 +204,16 @@ export async function common(createVue: () => App<Element>) {
if (defaultStore.state.keepScreenOn) {
if ('wakeLock' in navigator) {
navigator.wakeLock.request('screen');
document.addEventListener('visibilitychange', async () => {
if (document.visibilityState === 'visible') {
navigator.wakeLock.request('screen');
}
navigator.wakeLock.request('screen')
.then(() => {
document.addEventListener('visibilitychange', async () => {
if (document.visibilityState === 'visible') {
navigator.wakeLock.request('screen');
}
});
})
.catch(() => {
// If Permission fails on an AppleDevice such as Safari
});
}
}