mirror of
https://github.com/versia-pub/frontend.git
synced 2025-12-06 16:38:20 +01:00
25 lines
604 B
TypeScript
25 lines
604 B
TypeScript
import type { Mastodon } from "megalodon";
|
|
import type { Account } from "~/types/mastodon/account";
|
|
|
|
export const useAccount = (
|
|
client: MaybeRef<Mastodon | null>,
|
|
accountId: MaybeRef<string | null>,
|
|
) => {
|
|
if (!client) {
|
|
return ref(null as Account | null);
|
|
}
|
|
|
|
const output = ref(null as Account | null);
|
|
|
|
watchEffect(() => {
|
|
if (toValue(accountId))
|
|
ref(client)
|
|
.value?.getAccount(toValue(accountId) ?? "")
|
|
.then((res) => {
|
|
output.value = res.data;
|
|
});
|
|
});
|
|
|
|
return output;
|
|
};
|