@@ -22,14 +22,8 @@ type ThemeContextProviderProps = {
2222} ;
2323
2424function setInitialTheme ( ) : Theme {
25- if ( typeof window === 'undefined' ) return 'dark' ;
26-
27- const savedTheme = localStorage . getItem ( 'theme' ) as Theme | null ;
28- const prefersDark = window . matchMedia (
29- '(prefers-color-scheme: dark)'
30- ) . matches ;
31-
32- return savedTheme ?? ( prefersDark ? 'dark' : 'light' ) ;
25+ // Always return dark theme - no light mode option
26+ return 'dark' ;
3327}
3428
3529function setInitialAccent ( ) : Accent {
@@ -50,50 +44,60 @@ export function ThemeContextProvider({
5044 const { id : userId , theme : userTheme , accent : userAccent } = user ?? { } ;
5145
5246 useEffect ( ( ) => {
53- if ( user && userTheme ) setTheme ( userTheme ) ;
47+ // Always force dark theme, ignore user theme preference
48+ setTheme ( 'dark' ) ;
5449 } , [ userId , userTheme ] ) ;
5550
5651 useEffect ( ( ) => {
5752 if ( user && userAccent ) setAccent ( userAccent ) ;
5853 } , [ userId , userAccent ] ) ;
5954
6055 useEffect ( ( ) => {
61- const flipTheme = ( theme : Theme ) : NodeJS . Timeout | undefined => {
56+ const flipTheme = ( ) : NodeJS . Timeout | undefined => {
6257 const root = document . documentElement ;
63- const targetTheme = theme === 'dim' ? 'dark' : theme ;
64-
65- if ( targetTheme === 'dark' ) root . classList . add ( 'dark' ) ;
66- else root . classList . remove ( 'dark' ) ;
58+ // Always use dark theme
59+ const forcedTheme : Theme = 'dark' ;
60+
61+ // Always ensure dark class is present and never remove it
62+ root . classList . add ( 'dark' ) ;
63+ // Prevent any accidental removal
64+ if ( ! root . classList . contains ( 'dark' ) ) {
65+ root . classList . add ( 'dark' ) ;
66+ }
6767
6868 root . style . setProperty (
6969 '--main-background' ,
70- `var(--${ theme } -background)`
70+ `var(--${ forcedTheme } -background)`
7171 ) ;
7272
7373 root . style . setProperty (
7474 '--main-search-background' ,
75- `var(--${ theme } -search-background)`
75+ `var(--${ forcedTheme } -search-background)`
7676 ) ;
7777
7878 root . style . setProperty (
7979 '--main-sidebar-background' ,
80- `var(--${ theme } -sidebar-background)`
80+ `var(--${ forcedTheme } -sidebar-background)`
8181 ) ;
8282
8383 if ( user ) {
84- localStorage . setItem ( 'theme' , theme ) ;
84+ localStorage . setItem ( 'theme' , forcedTheme ) ;
8585 return setTimeout (
86- ( ) => void updateUserTheme ( user . id , { theme } ) ,
86+ ( ) => void updateUserTheme ( user . id , { theme : forcedTheme } ) ,
8787 500
8888 ) ;
8989 }
9090
9191 return undefined ;
9292 } ;
9393
94- const timeoutId = flipTheme ( theme ) ;
94+ const timeoutId = flipTheme ( ) ;
95+ // Ensure dark class is always applied on mount and updates
96+ const root = document . documentElement ;
97+ root . classList . add ( 'dark' ) ;
98+
9599 return ( ) => clearTimeout ( timeoutId ) ;
96- } , [ userId , theme ] ) ;
100+ } , [ userId ] ) ;
97101
98102 useEffect ( ( ) => {
99103 const flipAccent = ( accent : Accent ) : NodeJS . Timeout | undefined => {
@@ -118,7 +122,10 @@ export function ThemeContextProvider({
118122
119123 const changeTheme = ( {
120124 target : { value }
121- } : ChangeEvent < HTMLInputElement > ) : void => setTheme ( value as Theme ) ;
125+ } : ChangeEvent < HTMLInputElement > ) : void => {
126+ // Ignore theme changes - always keep dark mode
127+ setTheme ( 'dark' ) ;
128+ } ;
122129
123130 const changeAccent = ( {
124131 target : { value }
0 commit comments