Page MenuHomePhorge

D14221.1769056116.diff
No OneTemporary

Size
2 KB
Referenced Files
None
Subscribers
None

D14221.1769056116.diff

diff --git a/native/media/camera-modal.react.js b/native/media/camera-modal.react.js
--- a/native/media/camera-modal.react.js
+++ b/native/media/camera-modal.react.js
@@ -247,6 +247,7 @@
+dispatch: Dispatch,
// withOverlayContext
+overlayContext: ?OverlayContextType,
+ +isActive: boolean,
};
type State = {
+zoom: number,
@@ -506,35 +507,7 @@
);
}
- static isActive(props: Props): boolean {
- const { overlayContext } = props;
- if (!overlayContext) {
- return true;
- }
- return !overlayContext.isDismissing;
- }
-
- componentDidMount() {
- if (CameraModal.isActive(this.props)) {
- Orientation.unlockAllOrientations();
- }
- }
-
- componentWillUnmount() {
- if (CameraModal.isActive(this.props)) {
- Orientation.lockToPortrait();
- }
- }
-
componentDidUpdate(prevProps: Props, prevState: State) {
- const isActive = CameraModal.isActive(this.props);
- const wasActive = CameraModal.isActive(prevProps);
- if (isActive && !wasActive) {
- Orientation.unlockAllOrientations();
- } else if (!isActive && wasActive) {
- Orientation.lockToPortrait();
- }
-
if (!this.state.hasCamerasOnBothSides && prevState.hasCamerasOnBothSides) {
this.switchCameraButtonX.setValue(-1);
this.switchCameraButtonY.setValue(-1);
@@ -760,7 +733,7 @@
}
render(): React.Node {
- const statusBar = CameraModal.isActive(this.props) ? (
+ const statusBar = this.props.isActive ? (
<ConnectedStatusBar hidden />
) : null;
const type = this.state.useFrontCamera
@@ -1203,6 +1176,19 @@
const overlayContext = React.useContext(OverlayContext);
const dispatch = useDispatch();
+ const isActive = !overlayContext || !overlayContext.isDismissing;
+
+ React.useEffect(() => {
+ if (isActive) {
+ Orientation.unlockAllOrientations();
+ } else {
+ Orientation.lockToPortrait();
+ }
+ return () => {
+ Orientation.lockToPortrait();
+ };
+ }, [isActive]);
+
return (
<CameraModal
{...props}
@@ -1212,6 +1198,7 @@
foreground={foreground}
dispatch={dispatch}
overlayContext={overlayContext}
+ isActive={isActive}
/>
);
});

File Metadata

Mime Type
text/plain
Expires
Thu, Jan 22, 4:28 AM (10 h, 41 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5974043
Default Alt Text
D14221.1769056116.diff (2 KB)

Event Timeline