From f22d0172901014b28b705ac1d159c5ac8a9a35ee Mon Sep 17 00:00:00 2001 From: malmen237 Date: Thu, 2 May 2024 07:52:51 +0200 Subject: [PATCH] feat: not check for mediadevices before browser-supported is verified or user continues anyway --- src/use-device-permission.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/use-device-permission.ts b/src/use-device-permission.ts index c1453a41..554e6641 100644 --- a/src/use-device-permission.ts +++ b/src/use-device-permission.ts @@ -1,10 +1,16 @@ import { useEffect, useState } from "react"; -export const useDevicePermissions = () => { +export const useDevicePermissions = ({ + continueToApp, +}: { + continueToApp: boolean; +}) => { const [permission, setPermission] = useState(false); const [denied, setDenied] = useState(false); useEffect(() => { + if (!continueToApp) return; + navigator.mediaDevices .getUserMedia({ audio: true, video: false }) .then(() => { @@ -15,7 +21,7 @@ export const useDevicePermissions = () => { setDenied(true); setPermission(false); }); - }, []); + }, [continueToApp]); return { permission, denied }; };