chore: lint and fmt
This commit is contained in:
@@ -1,8 +1,16 @@
|
||||
import { computed, ref } from 'vue'
|
||||
import { computed, ref } from "vue"
|
||||
|
||||
import { getAuthor } from '@/modules/atproto/getAuthor'
|
||||
import { restoreSession, sdkSignOut, signInWithHandle } from '@/modules/atproto/service/atprotoOAuth'
|
||||
import { clearSession, loadSession, saveSession } from '@/modules/atproto/service/atprotoSession'
|
||||
import { getAuthor } from "@/modules/atproto/getAuthor"
|
||||
import {
|
||||
restoreSession,
|
||||
sdkSignOut,
|
||||
signInWithHandle
|
||||
} from "@/modules/atproto/service/atprotoOAuth"
|
||||
import {
|
||||
clearSession,
|
||||
loadSession,
|
||||
saveSession
|
||||
} from "@/modules/atproto/service/atprotoSession"
|
||||
|
||||
const did = ref<string | null>(null)
|
||||
const handle = ref<string | null>(null)
|
||||
@@ -12,20 +20,24 @@ let init = true
|
||||
const initializeAuth = async () => {
|
||||
// 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 ?? ''
|
||||
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 ?? ''
|
||||
const resolvedHandle = author?.handle ?? ""
|
||||
|
||||
did.value = session.did
|
||||
handle.value = resolvedHandle
|
||||
await saveSession(session.did, resolvedHandle)
|
||||
|
||||
window.history.replaceState(null, '', window.location.pathname + window.location.search)
|
||||
window.history.replaceState(
|
||||
null,
|
||||
"",
|
||||
window.location.pathname + window.location.search
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,8 +59,8 @@ export const useATProtoLogin = () => {
|
||||
await sdkSignOut(did.value)
|
||||
}
|
||||
await clearSession()
|
||||
did.value = ''
|
||||
handle.value = ''
|
||||
did.value = ""
|
||||
handle.value = ""
|
||||
}
|
||||
|
||||
return {
|
||||
@@ -57,6 +69,6 @@ export const useATProtoLogin = () => {
|
||||
isLoggedIn,
|
||||
isATProtoReady,
|
||||
signIn,
|
||||
signOut,
|
||||
signOut
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user