File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -6,17 +6,32 @@ const handleInput = shallowRef('')
66const route = useRoute ()
77const { user, logout } = useAtproto ()
88const { settings } = useSettings ()
9+ const colorMode = useColorMode ()
10+ const { setLocale, locales, locale } = useI18n ()
911
10- // TODO probably need to work out some kind of hashing so it doesnt get -> post
11- // TODO also need to figure out how to sync things like locale and theme
12+ // TODO need to check them all and idk if this is the spot for it
1213watch (
1314 user ,
1415 async loggedInUser => {
1516 if (! loggedInUser ) return
1617
1718 const remote = await $fetch (' /api/auth/settings' )
18- if (remote ) {
19- Object .assign (settings .value , remote )
19+ if (! remote ) return
20+
21+ Object .assign (settings .value , remote )
22+
23+ // Sync theme with colorMode
24+ if (remote .theme ) {
25+ colorMode .preference = remote .theme
26+ }
27+
28+ // Sync locale if it's valid and different from current
29+ if (
30+ remote .selectedLocale &&
31+ remote .selectedLocale !== locale .value &&
32+ locales .value .map (l => l .code ).includes (remote .selectedLocale )
33+ ) {
34+ setLocale (remote .selectedLocale )
2035 }
2136 },
2237 { immediate: true },
You can’t perform that action at this time.
0 commit comments