From 5247b36b6d4b84df3dd70c35972e2b67ccc53a12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=89=E5=92=B2=E6=99=BA=E5=AD=90=20Kevin=20Deng?= Date: Sun, 15 Jan 2023 17:44:36 +0800 Subject: [PATCH] fix: account server in GoToSocial --- composables/cache.ts | 4 ++-- composables/masto/account.ts | 4 ++-- composables/masto/masto.ts | 2 +- composables/users.ts | 10 +++++++++- 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/composables/cache.ts b/composables/cache.ts index 05aa7d4d..e080ce11 100644 --- a/composables/cache.ts +++ b/composables/cache.ts @@ -43,7 +43,7 @@ export function fetchAccountById(id?: string | null): Promise { if (r.acct && !r.acct.includes('@') && domain) @@ -63,7 +63,7 @@ export async function fetchAccountByHandle(acct: string): Promise>(S export const nodes = useLocalStorage>(STORAGE_KEY_NODES, {}, { deep: true }) const currentUserId = useLocalStorage(STORAGE_KEY_CURRENT_USER, mock ? mock.user.account.id : '') -export type ElkInstance = Partial & { uri: string } +export type ElkInstance = Partial & { + uri: string + /** support GoToSocial */ + accountDomain?: string | null +} export const getInstanceCache = (server: string): mastodon.v1.Instance | undefined => instances.value[server] export const currentUser = computed(() => { @@ -63,6 +67,10 @@ export const currentUser = computed(() => { const publicInstance = ref(null) export const currentInstance = computed(() => currentUser.value ? instances.value[currentUser.value.server] ?? null : publicInstance.value) +export function getInstanceDomain(instance: ElkInstance) { + return instance.accountDomain || instance.uri +} + export const publicServer = ref('') export const currentServer = computed(() => currentUser.value?.server || publicServer.value)