feat(shopping): hook useWakeLock avec fallback gracieux

This commit is contained in:
2026-05-24 15:41:34 +02:00
parent ffe28cc4e3
commit 9f2ca15303
+26
View File
@@ -0,0 +1,26 @@
import { useEffect, useRef } from 'react'
export function useWakeLock(active: boolean) {
const lockRef = useRef<WakeLockSentinel | null>(null)
useEffect(() => {
if (!active) {
lockRef.current?.release().catch(() => {})
lockRef.current = null
return
}
if (!('wakeLock' in navigator)) return
navigator.wakeLock.request('screen').then(lock => {
lockRef.current = lock
}).catch(() => {
// Wake Lock non disponible (mode économie d'énergie, navigateur non supporté)
})
return () => {
lockRef.current?.release().catch(() => {})
lockRef.current = null
}
}, [active])
}