Skip to content

Commit 8f9ebf3

Browse files
committed
fix: sync composable usage + $fetch
1 parent 4eb5907 commit 8f9ebf3

3 files changed

Lines changed: 6 additions & 15 deletions

File tree

app/components/AuthButton.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<script setup lang="ts">
22
const showModal = ref(false)
3-
const { user } = await useAtproto()
3+
const { user } = useAtproto()
44
</script>
55

66
<template>

app/components/AuthModal.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ const open = defineModel<boolean>('open', { default: false })
33
44
const handleInput = ref('')
55
6-
const { user, logout } = await useAtproto()
6+
const { user, logout } = useAtproto()
77
88
async function handleBlueskySignIn() {
99
await navigateTo(

app/composables/useAtproto.ts

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,12 @@
11
import type { UserSession } from '#shared/schemas/userSession'
22

33
/** @public */
4-
export async function useAtproto() {
5-
const {
6-
data: user,
7-
pending,
8-
clear,
9-
} = await useAsyncData<UserSession | null>('user-state', async () => {
10-
return await useRequestFetch()<UserSession>('/api/auth/session', {
11-
headers: { accept: 'application/json' },
12-
})
13-
})
4+
export function useAtproto() {
5+
const { data: user, pending, clear } = useFetch<UserSession | null>('/api/auth/session')
146

15-
const logout = async () => {
16-
await useRequestFetch()<UserSession>('/api/auth/session', {
7+
async function logout() {
8+
await $fetch('/api/auth/session', {
179
method: 'delete',
18-
headers: { accept: 'application/json' },
1910
})
2011

2112
clear()

0 commit comments

Comments
 (0)