fix: key current instance on user server, not user id (#466)

This commit is contained in:
Daniel Roe 2022-12-20 00:16:15 +00:00 committed by GitHub
parent 7484c5c072
commit 9a7c37db24
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 26 additions and 22 deletions

View file

@ -12,8 +12,8 @@ export default defineNuxtPlugin(async (nuxtApp) => {
return initialised
if (key === 'loginTo') {
return (...args: any[]) => {
apiPromise.value = loginTo(...args).then((r) => {
return (...args: any[]): Promise<MastoClient> => {
return apiPromise.value = loginTo(...args).then((r) => {
api.value = r
return masto
}).catch(() => {
@ -23,20 +23,21 @@ export default defineNuxtPlugin(async (nuxtApp) => {
statusMessage: 'Could not log into account.',
})
})
return apiPromise
}
}
if (api.value && key in api.value)
return api.value[key as keyof MastoClient]
if (!api) {
if (!api.value) {
return new Proxy({}, {
get(_, subkey) {
return (...args: any[]) => apiPromise.value?.then((r: any) => r[key][subkey](...args))
},
})
}
return undefined
},
})