-
Notifications
You must be signed in to change notification settings - Fork 558
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Solved type error using custom function #10628
Conversation
❌ Deploy Preview for care-ohc failed.
|
WalkthroughThe pull request introduces a new method, Changes
Sequence Diagram(s)sequenceDiagram
actor User as User
participant Modal as AvatarEditModal
participant Camera as webRef (Camera Stream)
User->>Modal: Click "Close Camera" Button
Modal->>Camera: Invoke stopCamera (stop all video tracks)
Camera-->>Modal: Camera stream halted
Modal-->>User: Close camera interface
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (2)
src/components/Common/AvatarEditModal.tsx (2)
89-95
: LGTM! ThestopCamera
implementation correctly handles camera resource cleanup.The function properly stops all video tracks and updates the component state. The use of
useCallback
is appropriate for maintaining a stable reference.Consider improving type safety.
The
webRef
is typed asany
. Consider creating a proper type for the webcam reference.- const webRef = useRef<any>(null); + type WebcamRef = { + video: { + srcObject: MediaStream | null; + } | null; + getScreenshot: () => string | null; + getCanvas: () => HTMLCanvasElement | null; + }; + const webRef = useRef<WebcamRef>(null);
103-110
: Consider adding camera cleanup on component unmount.To ensure proper resource cleanup in all scenarios (e.g., when the modal is forcefully closed), consider adding the camera cleanup in a
useEffect
cleanup function.+ useEffect(() => { + return () => { + stopCamera(); + }; + }, [stopCamera]); useEffect(() => { if (!isImageFile(selectedFile)) { return; }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
src/components/Common/AvatarEditModal.tsx
(2 hunks)src/components/Medicine/MedicationRequestTable/index.tsx
(2 hunks)
✅ Files skipped from review due to trivial changes (1)
- src/components/Medicine/MedicationRequestTable/index.tsx
🔇 Additional comments (1)
src/components/Common/AvatarEditModal.tsx (1)
411-421
: LGTM! ThestopCamera
function is properly integrated.The function is correctly called when closing the camera view, ensuring proper cleanup of camera resources.
Proposed Changes
Screen.Recording.2025-02-16.at.12.48.25.PM.1.mov
@ohcnetwork/care-fe-code-reviewers
Merge Checklist
Summary by CodeRabbit
Refactor
Style