Fix permission detection system on firefox

This commit is contained in:
Koper
2023-09-26 21:27:38 +01:00
parent e92b4061fe
commit bb5888c4e7
3 changed files with 17 additions and 1 deletions

View File

@@ -44,6 +44,7 @@ const TranscriptCreate = () => {
requestPermission,
getAudioStream,
} = useAudioDevice();
const [hasRecorded, setHasRecorded] = useState(false);
const [transcriptStarted, setTranscriptStarted] = useState(false);

View File

@@ -57,7 +57,7 @@ export default function Recorder(props: RecorderProps) {
const handleKeyPress = (event: KeyboardEvent) => {
switch (event.key) {
case "~":
location.href = ""
location.href = "";
break;
case ",":
location.href = "/transcripts/new";

View File

@@ -21,6 +21,21 @@ const useAudioDevice = () => {
}, [permissionOk]);
const checkPermission = (): void => {
if (navigator.userAgent.includes("Firefox")) {
navigator.mediaDevices
.getUserMedia({ audio: true, video: false })
.then((stream) => {
setPermissionOk(true);
setPermissionDenied(false);
})
.catch((e) => {
setPermissionOk(false);
setPermissionDenied(false);
})
.finally(() => setLoading(false));
return;
}
navigator.permissions
.query(MIC_QUERY)
.then((permissionStatus) => {