@@ -14,7 +14,7 @@ import { ThemeProvider } from 'curve-ui-kit/src/shared/ui/ThemeProvider'
14
14
15
15
import { dynamicActivate , initTranslation , updateAppLocale } from '@ui-kit/lib/i18n'
16
16
import { connectWalletLocales , initOnboard } from '@ui-kit/features/connect-wallet'
17
- import { getLocaleFromUrl , getStorageValue } from '@/utils'
17
+ import { getLocaleFromUrl } from '@/utils'
18
18
import { getIsMobile , getPageWidthClassName , isSuccess } from '@/ui/utils'
19
19
import { messages as messagesEn } from '@/locales/en/messages.js'
20
20
import networks from '@/networks'
@@ -25,15 +25,14 @@ import usePageVisibleInterval from '@/hooks/usePageVisibleInterval'
25
25
import Page from '@/layout'
26
26
import GlobalStyle from '@/globalStyle'
27
27
import { ChadCssProperties } from '@ui-kit/themes/typography'
28
+ import { useUserProfileStore } from '@ui-kit/features/user-profile'
28
29
29
30
i18n . load ( { en : messagesEn } )
30
31
i18n . activate ( 'en' )
31
32
32
33
function CurveApp ( { Component } : AppProps ) {
33
34
const connectState = useStore ( ( state ) => state . connectState )
34
- const locale = useStore ( ( state ) => state . locale )
35
35
const pageWidth = useStore ( ( state ) => state . layout . pageWidth )
36
- const themeType = useStore ( ( state ) => state . themeType )
37
36
const setPageWidth = useStore ( ( state ) => state . layout . setLayoutWidth )
38
37
const updateShowScrollButton = useStore ( ( state ) => state . updateShowScrollButton )
39
38
const updateGlobalStoreByKey = useStore ( ( state ) => state . updateGlobalStoreByKey )
@@ -47,6 +46,8 @@ function CurveApp({ Component }: AppProps) {
47
46
const onboard = useStore ( ( state ) => state . wallet . onboard )
48
47
const isPageVisible = useStore ( ( state ) => state . isPageVisible )
49
48
49
+ const { locale, setLocale, theme } = useUserProfileStore ( )
50
+
50
51
const [ appLoaded , setAppLoaded ] = useState ( false )
51
52
52
53
const handleResizeListener = useCallback ( ( ) => {
@@ -57,8 +58,8 @@ function CurveApp({ Component }: AppProps) {
57
58
useEffect ( ( ) => {
58
59
if ( ! pageWidth ) return
59
60
60
- document . body . className = `theme-${ themeType } ${ pageWidth } ${ getIsMobile ( ) ? '' : 'scrollSmooth' } `
61
- document . body . setAttribute ( 'data-theme' , themeType || '' )
61
+ document . body . className = `theme-${ theme } ${ pageWidth } ${ getIsMobile ( ) ? '' : 'scrollSmooth' } `
62
+ document . body . setAttribute ( 'data-theme' , theme )
62
63
document . documentElement . lang = locale
63
64
} )
64
65
@@ -67,12 +68,6 @@ function CurveApp({ Component }: AppProps) {
67
68
updateShowScrollButton ( window . scrollY )
68
69
}
69
70
70
- const { themeType } = getStorageValue ( 'APP_CACHE' ) ?? { }
71
-
72
- // init theme
73
- const darkModeQuery = window . matchMedia ( '(prefers-color-scheme: dark)' )
74
- updateGlobalStoreByKey ( 'themeType' , themeType ? themeType : darkModeQuery . matches ? 'dark' : 'default' )
75
-
76
71
// init locale
77
72
const { rLocale } = getLocaleFromUrl ( )
78
73
const parsedLocale = rLocale ?. value ?? 'en'
@@ -81,10 +76,11 @@ function CurveApp({ Component }: AppProps) {
81
76
let data = await import ( `@/locales/${ parsedLocale } /messages` )
82
77
dynamicActivate ( parsedLocale , data )
83
78
} ) ( )
84
- updateAppLocale ( parsedLocale , updateGlobalStoreByKey )
79
+ setLocale ( parsedLocale )
80
+ updateAppLocale ( parsedLocale )
85
81
86
82
// init onboard
87
- const onboardInstance = initOnboard ( connectWalletLocales , locale , themeType , networks )
83
+ const onboardInstance = initOnboard ( connectWalletLocales , locale , theme , networks )
88
84
updateWalletStoreByKey ( 'onboard' , onboardInstance )
89
85
90
86
const handleVisibilityChange = ( ) => {
@@ -148,8 +144,8 @@ function CurveApp({ Component }: AppProps) {
148
144
)
149
145
150
146
return (
151
- < div suppressHydrationWarning style = { { ...( themeType === 'chad' && ChadCssProperties ) } } >
152
- < ThemeProvider theme = { themeType === 'default' ? 'light' : themeType } >
147
+ < div suppressHydrationWarning style = { { ...( theme === 'chad' && ChadCssProperties ) } } >
148
+ < ThemeProvider theme = { theme } >
153
149
{ typeof window === 'undefined' || ! appLoaded ? null : (
154
150
< HashRouter >
155
151
< I18nProvider i18n = { i18n } >
0 commit comments