@@ -112,6 +112,27 @@ export function RemixUiTopbar () {
112112 }
113113 } , [ global . fs . browser . workspaces , global . fs . browser . workspaces . length ] )
114114
115+ useEffect ( ( ) => {
116+ plugin . on ( 'theme' , 'themeChanged' , ( theme ) => {
117+ setCurrentTheme ( theme )
118+ } )
119+ return ( ) => {
120+ plugin . off ( 'theme' , 'themeChanged' )
121+ }
122+ } , [ ] )
123+
124+ useEffect ( ( ) => {
125+ async function loadCurrentTheme ( ) {
126+ try {
127+ const ct = await plugin . call ( 'theme' , 'currentTheme' )
128+ setCurrentTheme ( ct )
129+ } catch ( error ) {
130+ console . error ( "Error fetching current theme:" , error )
131+ }
132+ }
133+ loadCurrentTheme ( )
134+ } , [ ] ) ;
135+
115136 const subItems = useMemo ( ( ) => {
116137 return [
117138 { label : 'Rename' , onClick : renameCurrentWorkspace , icon : 'far fa-edit' } ,
@@ -284,20 +305,6 @@ export function RemixUiTopbar () {
284305 )
285306 }
286307
287- const getCurrentTheme = async ( ) => {
288- const theme = await plugin . call ( 'theme' , 'currentTheme' )
289- return theme
290- }
291-
292- useEffect ( ( ) => {
293- plugin . on ( 'theme' , 'themeChanged' , ( theme ) => {
294- setCurrentTheme ( theme )
295- } )
296- return ( ) => {
297- plugin . off ( 'theme' , 'themeChanged' )
298- }
299- } , [ ] )
300-
301308 const renameModalMessage = ( workspaceName ?: string ) => {
302309 return (
303310 < div className = 'd-flex flex-column' >
@@ -332,8 +339,7 @@ export function RemixUiTopbar () {
332339 )
333340 }
334341
335- const checkIfLightTheme = ( themeName : string ) =>
336- themeName . includes ( 'dark' ) || themeName . includes ( 'black' ) || themeName . includes ( 'hackerOwl' ) ? false : true
342+ const checkIfLightTheme = ( themeName : string ) => themeName . includes ( 'dark' ) ? false : true
337343
338344 const IsGitRepoDropDownMenuItem = ( props : { isGitRepo : boolean , mName : string } ) => {
339345 return (
@@ -536,8 +542,6 @@ export function RemixUiTopbar () {
536542 fontSize : '0.8rem'
537543 } }
538544 onClick = { async ( ) => {
539- const theme = await getCurrentTheme ( )
540- setCurrentTheme ( theme )
541545 setShowTheme ( ! showTheme )
542546 } }
543547 >
0 commit comments