frontend/app/composables/AccountAcct.ts

24 lines
622 B
TypeScript
Raw Normal View History

2024-12-02 16:07:52 +01:00
import type { Client } from "@versia/client";
import type { Account } from "@versia/client/schemas";
import type { z } from "zod";
2024-12-02 16:07:52 +01:00
export const useAccountFromAcct = (
client: MaybeRef<Client | null>,
acct: string,
): {
account: Ref<z.infer<typeof Account> | null>;
isLoading: Ref<boolean>;
} => {
const output = ref(null as z.infer<typeof Account> | null);
const isLoading = ref(true);
2024-12-02 16:07:52 +01:00
ref(client)
.value?.lookupAccount(acct)
.then((res) => {
isLoading.value = false;
2024-12-02 16:07:52 +01:00
output.value = res.data;
});
return { account: output, isLoading };
2024-12-02 16:07:52 +01:00
};