Skip to content

Commit

Permalink
fix: useWakeLock causing infinite loop (#1829)
Browse files Browse the repository at this point in the history
  • Loading branch information
KermanX committed Aug 20, 2024
1 parent 7c2c9e7 commit 0c30d44
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions packages/client/composables/useWakeLock.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import { useWakeLock as useVueUseWakeLock } from '@vueuse/core'
import { watchEffect } from 'vue'
import { watch } from 'vue'
import { wakeLockEnabled } from '../state'

export function useWakeLock() {
const { request, release } = useVueUseWakeLock()

watchEffect((onCleanup) => {
if (wakeLockEnabled.value)
watch(wakeLockEnabled, (enabled) => {
if (enabled)
request('screen')
onCleanup(release)
})
else
release()
}, { immediate: true })
}

0 comments on commit 0c30d44

Please sign in to comment.