From 3d7889e19a52bd94b28832c5a3ba63e3a330fdb2 Mon Sep 17 00:00:00 2001 From: Fredrik Burmester Date: Fri, 7 Mar 2025 07:53:50 +0100 Subject: [PATCH] fix: orientation lock being activated even when auto rotate is on --- app/(auth)/player/_layout.tsx | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/app/(auth)/player/_layout.tsx b/app/(auth)/player/_layout.tsx index c06c05a2..a0ff4382 100644 --- a/app/(auth)/player/_layout.tsx +++ b/app/(auth)/player/_layout.tsx @@ -1,30 +1,30 @@ -import { Stack } from "expo-router"; -import React, { useEffect } from "react"; -import { SystemBars } from "react-native-edge-to-edge"; import * as ScreenOrientation from "@/packages/expo-screen-orientation"; import { useSettings } from "@/utils/atoms/settings"; +import { Stack } from "expo-router"; +import React, { useLayoutEffect } from "react"; import { Platform } from "react-native"; +import { SystemBars } from "react-native-edge-to-edge"; export default function Layout() { const [settings] = useSettings(); - useEffect(() => { + useLayoutEffect(() => { if (Platform.isTV) return; - if (settings.defaultVideoOrientation) { + if (!settings.followDeviceOrientation && settings.defaultVideoOrientation) { ScreenOrientation.lockAsync(settings.defaultVideoOrientation); } return () => { if (Platform.isTV) return; - if (settings.autoRotate === true) { + if (settings.followDeviceOrientation === true) { ScreenOrientation.unlockAsync(); } else { ScreenOrientation.lockAsync(ScreenOrientation.OrientationLock.PORTRAIT_UP); } }; - }, [settings.defaultVideoOrientation, settings.autoRotate]); + }, [settings.autoDownload, settings.defaultVideoOrientation]); return ( <>