From 3ff3c4d69bbfe03ee22f9aa0478b7972ce2c6175 Mon Sep 17 00:00:00 2001 From: Nicola Benaglia Date: Fri, 20 Jun 2025 15:49:13 +0200 Subject: [PATCH] Refactor theme selection --- src/components/Theme/ThemeContext.tsx | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/src/components/Theme/ThemeContext.tsx b/src/components/Theme/ThemeContext.tsx index 8ce2c6a..3044045 100644 --- a/src/components/Theme/ThemeContext.tsx +++ b/src/components/Theme/ThemeContext.tsx @@ -41,21 +41,16 @@ export const ThemeProvider = ({ children }) => { userThemes.find((theme) => theme.id === currentThemeId) || defaultTheme; const muiTheme = useMemo(() => { - if (themeMode === 'light') { - return createTheme({ - ...lightThemeOptions, - palette: { - ...currentTheme.light, - }, - }); - } else { - return createTheme({ - ...lightThemeOptions, - palette: { - ...currentTheme.dark, - }, - }); - } + const baseThemeOptions = + themeMode === 'light' ? lightThemeOptions : darkThemeOptions; + + const palette = + themeMode === 'light' ? currentTheme.light : currentTheme.dark; + + return createTheme({ + ...baseThemeOptions, + palette, + }); }, [themeMode, currentTheme]); const saveSettings = (