From 48b2c906781e365983156d8f6366959d261e29b1 Mon Sep 17 00:00:00 2001 From: StackOverflowIsBetterThanAnyAI Date: Sat, 21 Nov 2026 19:35:35 +0100 Subject: [PATCH] save image rotation value --- app/_layout.tsx | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/app/_layout.tsx b/app/_layout.tsx index 8ec8264..d237437 100644 --- a/app/_layout.tsx +++ b/app/_layout.tsx @@ -16,7 +16,7 @@ import { ContextError } from '@/context/ContextError' import { ContextImageRotation } from '@/context/ContextImageRotation' import { ContextPage } from '@/context/ContextPage' import { ContextUser, UserRoleType } from '@/context/ContextUser' -import { loadData } from '@/helper/storeData' +import { loadData, saveData } from '@/helper/storeData' import { useColorScheme } from '@/hooks/use-color-scheme' import { useThemeColor } from '@/hooks/use-theme-color' @@ -45,7 +45,16 @@ const RootLayout = () => { useEffect(() => { const autoLogin = async () => { - const data = await loadData(['authName', 'authRole', 'authToken']) + const data = await loadData([ + 'authName', + 'authRole', + 'authToken', + 'imageRotation', + ]) + const storedRotation = Number(data?.imageRotation) + if (storedRotation === 0 || storedRotation === 180) { + setImageRotation(storedRotation) + } if (data?.authToken && data?.authName && data?.authRole) { setIsUserLoggedIn(true) setUserName(data.authName) @@ -57,6 +66,12 @@ const RootLayout = () => { autoLogin() }, []) + useEffect(() => { + if (!isLoading) { + saveData({ imageRotation: `${imageRotation}` }) + } + }, [imageRotation, isLoading]) + useEffect(() => { if (!isLoading && isUserLoggedIn) { router.replace(