Skip to content

Commit

Permalink
feat: not check for mediadevices before browser-supported is verified…
Browse files Browse the repository at this point in the history
… or user continues anyway
  • Loading branch information
malmen237 committed May 2, 2024
1 parent 7873350 commit f22d017
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/use-device-permission.ts
Original file line number Diff line number Diff line change
@@ -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(() => {
Expand All @@ -15,7 +21,7 @@ export const useDevicePermissions = () => {
setDenied(true);
setPermission(false);
});
}, []);
}, [continueToApp]);

return { permission, denied };
};

0 comments on commit f22d017

Please sign in to comment.