Skip to content

Commit 4b36cf8

Browse files
committed
fix theme initial icon
1 parent 09d14a5 commit 4b36cf8

File tree

1 file changed

+22
-18
lines changed

1 file changed

+22
-18
lines changed

libs/remix-ui/top-bar/src/lib/remix-ui-topbar.tsx

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)