Skip to content

Commit

Permalink
Rename function
Browse files Browse the repository at this point in the history
  • Loading branch information
imnasnainaec committed Aug 23, 2024
1 parent 6e6c855 commit b76c1c0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/components/Pronunciations/AudioRecorder.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { toast } from "react-toastify";

import RecorderContext from "components/Pronunciations/RecorderContext";
import RecorderIcon from "components/Pronunciations/RecorderIcon";
import { isNavigatorFirefox } from "components/Pronunciations/utilities";
import { isBrowserFirefox } from "components/Pronunciations/utilities";
import { useAppSelector } from "rootRedux/hooks";
import { type StoreState } from "rootRedux/types";
import { FileWithSpeakerId } from "types/word";
Expand Down Expand Up @@ -36,7 +36,7 @@ export default function AudioRecorder(props: RecorderProps): ReactElement {

if (!recorder.startRecording(props.id)) {
let errorMessage = t("pronunciations.recordingError");
if (isNavigatorFirefox()) {
if (isBrowserFirefox()) {
errorMessage += ` ${t("pronunciations.recordingPermission")}`;
}
toast.error(errorMessage);
Expand Down
6 changes: 3 additions & 3 deletions src/components/Pronunciations/utilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,16 @@ export async function uploadFileFromPronunciation(
* https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/User-Agent/Firefox */
const firefoxBrowsers = ["firefox", "focus", "fxios"];

/** Check if navigator is a Firefox browser. */
export function isNavigatorFirefox(): boolean {
/** Check if browser is a Firefox browser. */
export function isBrowserFirefox(): boolean {
const uaLower = navigator.userAgent.toLocaleLowerCase();
return firefoxBrowsers.some((browser) => uaLower.includes(browser));
}

/** Checks if the user has granted mic permission to The Combine,
* except on Firefox assumes permission is granted. */
export async function checkMicPermission(): Promise<boolean> {
if (!isNavigatorFirefox()) {
if (!isBrowserFirefox()) {
const result = await navigator.permissions.query({
name: "microphone" as PermissionName, // This causes a TypeError on Firefox.
});
Expand Down

0 comments on commit b76c1c0

Please sign in to comment.