Skip to content

Commit 6042015

Browse files
committed
feels very hacky and will need to change
1 parent 2fc603d commit 6042015

1 file changed

Lines changed: 19 additions & 4 deletions

File tree

app/components/Header/AuthModal.client.vue

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,32 @@ const handleInput = shallowRef('')
66
const route = useRoute()
77
const { user, logout } = useAtproto()
88
const { 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
1213
watch(
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 },

0 commit comments

Comments
 (0)