Skip to content

Commit 83eabf5

Browse files
authored
Merge branch 'master' into close-pinned-plugin
2 parents 28a69a5 + 4b36cf8 commit 83eabf5

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
@@ -129,6 +129,27 @@ export function RemixUiTopbar () {
129129
}
130130
}, [global.fs.browser.workspaces, global.fs.browser.workspaces.length])
131131

132+
useEffect(() => {
133+
plugin.on('theme', 'themeChanged', (theme) => {
134+
setCurrentTheme(theme)
135+
})
136+
return () => {
137+
plugin.off('theme', 'themeChanged')
138+
}
139+
}, [])
140+
141+
useEffect(() => {
142+
async function loadCurrentTheme() {
143+
try {
144+
const ct = await plugin.call('theme', 'currentTheme')
145+
setCurrentTheme(ct)
146+
} catch (error) {
147+
console.error("Error fetching current theme:", error)
148+
}
149+
}
150+
loadCurrentTheme()
151+
}, []);
152+
132153
const subItems = useMemo(() => {
133154
return [
134155
{ label: 'Rename', onClick: renameCurrentWorkspace, icon: 'far fa-edit' },
@@ -301,20 +322,6 @@ export function RemixUiTopbar () {
301322
)
302323
}
303324

304-
const getCurrentTheme = async () => {
305-
const theme = await plugin.call('theme', 'currentTheme')
306-
return theme
307-
}
308-
309-
useEffect(() => {
310-
plugin.on('theme', 'themeChanged', (theme) => {
311-
setCurrentTheme(theme)
312-
})
313-
return () => {
314-
plugin.off('theme', 'themeChanged')
315-
}
316-
}, [])
317-
318325
const renameModalMessage = (workspaceName?: string) => {
319326
return (
320327
<div className='d-flex flex-column'>
@@ -349,8 +356,7 @@ export function RemixUiTopbar () {
349356
)
350357
}
351358

352-
const checkIfLightTheme = (themeName: string) =>
353-
themeName.includes('dark') || themeName.includes('black') || themeName.includes('hackerOwl') ? false : true
359+
const checkIfLightTheme = (themeName: string) => themeName.includes('dark') ? false : true
354360

355361
const IsGitRepoDropDownMenuItem = (props: { isGitRepo: boolean, mName: string}) => {
356362
return (
@@ -562,8 +568,6 @@ export function RemixUiTopbar () {
562568
fontSize: '0.8rem'
563569
}}
564570
onClick={async () => {
565-
const theme = await getCurrentTheme()
566-
setCurrentTheme(theme)
567571
setShowTheme(!showTheme)
568572
}}
569573
>

0 commit comments

Comments
 (0)