1
0
Fork 1
mirror of https://github.com/elk-zone/elk.git synced 2024-11-09 10:29:57 +00:00
elk/plugins/masto.ts

27 lines
669 B
TypeScript
Raw Normal View History

export default defineNuxtPlugin(async (nuxtApp) => {
const masto = createMasto()
if (process.client) {
const { query } = useRoute()
const user = typeof query.server === 'string' && typeof query.token === 'string'
? {
server: query.server,
token: query.token,
vapidKey: typeof query.vapid_key === 'string' ? query.vapid_key : undefined,
}
: currentUser.value
2022-11-26 19:33:36 +00:00
nuxtApp.hook('app:suspense:resolve', () => {
// TODO: improve upstream to make this synchronous (delayed auth)
if (!masto.loggedIn.value)
masto.loginTo(user)
})
}
return {
provide: {
masto,
},
}
})