diff --git a/src/components/SignInAtproto.vue b/src/components/SignInAtproto.vue index d71d706..ad545f1 100644 --- a/src/components/SignInAtproto.vue +++ b/src/components/SignInAtproto.vue @@ -3,7 +3,7 @@ import { ref } from "vue" import { useATProtoLogin } from "@/hooks/useATProtoLogin.hook" -const { handle, isLoggedIn, signIn, signOut } = useATProtoLogin() +const { handle, isLoggedIn, isATProtoReady, signIn, signOut } = useATProtoLogin() withDefaults( defineProps<{ @@ -24,13 +24,14 @@ const onSignIn = () => { diff --git a/src/hooks/useATProtoLogin.hook.ts b/src/hooks/useATProtoLogin.hook.ts index f5cdbaf..7106592 100644 --- a/src/hooks/useATProtoLogin.hook.ts +++ b/src/hooks/useATProtoLogin.hook.ts @@ -10,8 +10,13 @@ const handle = ref(null) let init = true const initializeAuth = async () => { - const session = await restoreSession() + // Load cached session from IndexedDB first (fast, local) so the UI can render immediately + const stored = await loadSession() + did.value = stored?.did ?? '' + handle.value = stored?.handle ?? '' + // Then restore OAuth session in the background (may involve network) + const session = await restoreSession() if (session) { const author = await getAuthor(session.did) const resolvedHandle = author?.handle ?? '' @@ -21,10 +26,6 @@ const initializeAuth = async () => { await saveSession(session.did, resolvedHandle) window.history.replaceState(null, '', window.location.pathname + window.location.search) - } else { - const stored = await loadSession() - did.value = stored?.did ?? '' - handle.value = stored?.handle ?? '' } } diff --git a/src/views/PublicNoteListByDidView.vue b/src/views/PublicNoteListByDidView.vue index 992a592..2f1be53 100644 --- a/src/views/PublicNoteListByDidView.vue +++ b/src/views/PublicNoteListByDidView.vue @@ -1,6 +1,7 @@