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