Page MenuHomePhabricator

[native] Migrate orientation logic in CameraModal to functional component
ClosedPublic

Authored by angelika on Jan 20 2025, 4:09 AM.
Tags
None
Referenced Files
F5911333: D14221.diff
Thu, Apr 17, 5:37 PM
Unknown Object (File)
Thu, Mar 27, 7:38 AM
Unknown Object (File)
Thu, Mar 27, 5:52 AM
Unknown Object (File)
Wed, Mar 26, 6:11 PM
Unknown Object (File)
Mar 11 2025, 4:12 PM
Unknown Object (File)
Mar 11 2025, 4:11 PM
Unknown Object (File)
Mar 11 2025, 4:09 PM
Unknown Object (File)
Mar 11 2025, 3:52 PM
Subscribers

Details

Summary

https://linear.app/comm/issue/ENG-8152/convert-cameramodal-to-reanimated-2-syntax

When entering camera modal, we unlock the orientation.
When exiting camera modal, we lock the orientation to portrait.

Test Plan

Verify that orientation is handled correctly when showing camera modal:

  • when entering in horizontal orientation it's switched to horizontal
  • when exiting in horizontal orientation it's locked to portrait

Diff Detail

Repository
rCOMM Comm
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

angelika held this revision as a draft.
tomek requested changes to this revision.Jan 20 2025, 6:29 AM
tomek added inline comments.
native/media/camera-modal.react.js
1181–1187 ↗(On Diff #46718)

Is it guaranteed that the orientation gets locked on unmount? I think we should return a function from this effect that does that when appropriate.

This revision now requires changes to proceed.Jan 20 2025, 6:29 AM
native/media/camera-modal.react.js
1181–1187 ↗(On Diff #46718)

From my testing it looks like the orientation is locked because isActive turns to false before modal is closed. But just in case I added the code to lock the orientation on unmount,

tomek added inline comments.
native/media/camera-modal.react.js
1181–1187 ↗(On Diff #46718)

The added code is correct but is a bit tricky. The cleanup function will be run before every dependency change. So there are two cases:

  1. When isActive becomes true, we will lock the orientation in the cleanup, and then unlock it in the effect.
  2. When isActive becomes false, we will lock the orientation in the cleanup, and then lock again in the effect.

So eventually, the state will be correct, but maybe we should add an if in the cleanup checking isActive?

This revision is now accepted and ready to land.Jan 22 2025, 2:39 AM