diff --git a/apps/gitness/src/framework/context/ThemeContext.tsx b/apps/gitness/src/framework/context/ThemeContext.tsx index 48dbc587c..248361308 100644 --- a/apps/gitness/src/framework/context/ThemeContext.tsx +++ b/apps/gitness/src/framework/context/ThemeContext.tsx @@ -27,11 +27,9 @@ export function ThemeProvider({ children }: { children: React.ReactNode }) { setTheme: state.setTheme })) - const [systemMode, setSystemMode] = useState(ModeType.Dark) + const mediaQuery = window.matchMedia('(prefers-color-scheme: dark)') + const [systemMode, setSystemMode] = useState(mediaQuery.matches ? ModeType.Dark : ModeType.Light) useEffect(() => { - const mediaQuery = window.matchMedia('(prefers-color-scheme: dark)') - setSystemMode(mediaQuery.matches ? ModeType.Dark : ModeType.Light) - const updateSystemTheme = () => { setSystemMode(mediaQuery.matches ? ModeType.Dark : ModeType.Light) }