Skip to content

Commit

Permalink
Fixed linting errors 2
Browse files Browse the repository at this point in the history
  • Loading branch information
Harsh-D-2004 committed Mar 3, 2025
1 parent 77683cb commit ba36501
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
28 changes: 18 additions & 10 deletions src/Utils/cameraPermissionHandler.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,24 @@
import { useTranslation } from "react-i18next";
import { toast } from "sonner";

const { t } = useTranslation();

let toastShown = false;

export const handleCameraPermission = async (cameraFacingMode: string, onPermissionDenied: () => void) => {
toastShown = false;
try {
await navigator.mediaDevices.getUserMedia({ video: { facingMode: cameraFacingMode } });
} catch (error) {
if (!toastShown) {
toastShown = true; // Ensures only one toast is shown
toast.warning("Camera permission denied");
}
onPermissionDenied();
export const handleCameraPermission = async (
cameraFacingMode: string,
onPermissionDenied: () => void,
) => {
toastShown = false;
try {
await navigator.mediaDevices.getUserMedia({
video: { facingMode: cameraFacingMode },
});
} catch (_error) {
if (!toastShown) {
toastShown = true;
toast.warning(t("camera_permission_denied"));
}
onPermissionDenied();
}
};
2 changes: 1 addition & 1 deletion src/components/Common/AvatarEditModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import {

import useDragAndDrop from "@/hooks/useDragAndDrop";

import { handleCameraPermission } from "../../Utils/cameraPermissionHandler";
import { handleCameraPermission } from "@/Utils/cameraPermissionHandler";

interface Props {
title: string;
Expand Down

0 comments on commit ba36501

Please sign in to comment.