Set last known app theme background color until theme is loaded

This commit is contained in:
schroda
2025-07-28 00:20:16 +02:00
parent ff58dcc480
commit fb00f51107
2 changed files with 21 additions and 0 deletions

View File

@@ -22,6 +22,7 @@ import { createAndSetTheme } from '@/modules/theme/services/ThemeCreator.ts';
import { makeToast } from '@/modules/core/utils/Toast.ts';
import { getErrorMessage } from '@/lib/HelperFunctions.ts';
import { useLocalStorage } from '@/modules/core/hooks/useStorage.tsx';
import { AppStorage } from '@/lib/storage/AppStorage.ts';
export const AppThemeContextProvider = ({ children }: { children: ReactNode }) => {
const { t, i18n } = useTranslation();
@@ -102,6 +103,13 @@ export const AppThemeContextProvider = ({ children }: { children: ReactNode }) =
}
}, [serverAppTheme, localAppTheme]);
useEffect(() => {
// The set background color is not necessary anymore, since the theme has been loaded
document.documentElement.style.backgroundColor = '';
AppStorage.local.setItem('theme_background', theme.palette.background.default);
}, [theme.palette.background.default]);
if (directionRef.current !== currentDirection) {
document.dir = currentDirection;
directionRef.current = currentDirection;