Skip to content

Commit be9103e

Browse files
committed
refactor theme provider
1 parent ca05ce7 commit be9103e

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

redisinsight/ui/src/contexts/themeContext.tsx

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,17 +49,20 @@ export class ThemeProvider extends React.Component<Props> {
4949
constructor(props: any) {
5050
super(props)
5151

52-
// theme query param can be used to override the local/default theme
5352
const queryTheme = getQueryTheme()
5453
const storedThemeValue = localStorageService.get(BrowserStorageItem.theme)
55-
const theme =
56-
queryTheme ||
57-
(!storedThemeValue || !THEME_NAMES.includes(storedThemeValue)
58-
? defaultState.theme
59-
: storedThemeValue)
54+
55+
let theme = defaultState.theme
56+
57+
if (queryTheme) {
58+
theme = queryTheme
59+
} else if (storedThemeValue && THEME_NAMES.includes(storedThemeValue)) {
60+
theme = storedThemeValue
61+
}
62+
6063
const usingSystemTheme = theme === Theme.System
6164

62-
themeService.applyTheme(theme)
65+
themeService.applyTheme(theme as Theme)
6366

6467
this.state = {
6568
theme: theme === Theme.System ? this.getSystemTheme() : theme,

0 commit comments

Comments
 (0)