📈 Open source, privacy-first web analytics — a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!
TypeScript chartsclickhousedockergdprgoogle-analyticsmetricsmonitoringmysqlnestjsprivacyredisself-hostedselfhostedstatisticstailwindcssweb-analyticswebanalyticswebsite
fix theme change
Maksim Mrug9790fb72c7f9
diff --git a/app/redux/reducers/ui/theme.ts b/app/redux/reducers/ui/theme.tsindex 4791a4237..9e50bed87 100644--- a/app/redux/reducers/ui/theme.ts+++ b/app/redux/reducers/ui/theme.ts@@ -3,26 +3,32 @@ import _includes from 'lodash/includes'import { LS_THEME_SETTING, SUPPORTED_THEMES, THEME_TYPE } from 'redux/constants'const setThemeToDOM = (theme: string) => {- // const root = window.document.documentElement+ if (typeof window === 'undefined') {+ return+ }++ const root = window.document.documentElementconst isDark = theme === 'dark'- // root.classList.remove(isDark ? 'light' : 'dark')- // root.classList.add(theme)+ root.classList.remove(isDark ? 'light' : 'dark')+ root.classList.add(theme)}const setTheme = (theme: string): string => {setThemeToDOM(theme)- // localStorage.setItem(LS_THEME_SETTING, theme)+ if (typeof window !== 'undefined' && window.localStorage) {+ window.localStorage.setItem(LS_THEME_SETTING, theme)+ }return theme}const getInitialTheme = (): 'light' | 'dark' => {if (typeof window !== 'undefined' && window.localStorage) {- // const lsTheme: any = window.localStorage.getItem(LS_THEME_SETTING)- // if (_includes(SUPPORTED_THEMES, lsTheme)) {- // setThemeToDOM(lsTheme)- // return lsTheme- // }+ const lsTheme: any = window.localStorage.getItem(LS_THEME_SETTING)+ if (_includes(SUPPORTED_THEMES, lsTheme)) {+ setThemeToDOM(lsTheme)+ return lsTheme+ }const userMedia = window.matchMedia('(prefers-color-scheme: dark)')if (userMedia.matches) {