Skip to content

Commit 2fc603d

Browse files
committed
loads in settings. doesnt dynamically update
1 parent c363398 commit 2fc603d

3 files changed

Lines changed: 32 additions & 4 deletions

File tree

app/components/Header/AuthModal.client.vue

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,22 @@ import { authRedirect } from '~/utils/atproto/helpers'
55
const handleInput = shallowRef('')
66
const route = useRoute()
77
const { user, logout } = useAtproto()
8+
const { settings } = useSettings()
9+
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+
watch(
13+
user,
14+
async loggedInUser => {
15+
if (!loggedInUser) return
16+
17+
const remote = await $fetch('/api/auth/settings')
18+
if (remote) {
19+
Object.assign(settings.value, remote)
20+
}
21+
},
22+
{ immediate: true },
23+
)
824
925
// https://atproto.com supports 4 locales as of 2026-02-07
1026
const { locale } = useI18n()

app/pages/settings.vue

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ const { settings } = useSettings()
55
const { locale, locales, setLocale: setNuxti18nLocale } = useI18n()
66
const colorMode = useColorMode()
77
const { currentLocaleStatus, isSourceLocale } = useI18nStatus()
8+
const { user } = useAtproto()
89
910
// Escape to go back (but not when focused on form elements or modal is open)
1011
onKeyStroke(
@@ -34,7 +35,11 @@ defineOgImageComponent('Default', {
3435
primaryColor: '#60a5fa',
3536
})
3637
37-
watch(settings.value, syncSettings)
38+
watch(settings.value, async () => {
39+
if (!user.value) return
40+
41+
await syncSettings(settings.value)
42+
})
3843
3944
const setLocale: typeof setNuxti18nLocale = locale => {
4045
settings.value.selectedLocale = locale

server/api/auth/settings.get.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1-
//Want to check the cooki login state, can be slightly more laxed?
2-
//
3-
export default defineEventHandler(async _ => {})
1+
import type { AppSettings } from '#shared/schemas/app-settings'
2+
3+
export default defineEventHandler(async event => {
4+
// Current thinking is reads can just be a normal event handler and writes use the oauth
5+
const serverSession = await useServerSession(event)
6+
7+
const storage = useStorage('atproto:generic')
8+
const storageKey = `settings:${serverSession.data.public.did}`
9+
return storage.getItem<AppSettings>(storageKey)
10+
})

0 commit comments

Comments
 (0)