frontend/composables/Account.ts
Jesse Wierzbinski 6d2b607f2b
fix: 🐛 Various bugfixes
2024-05-11 23:23:38 -10:00

25 lines
602 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))
toValue(client)
?.getAccount(toValue(accountId) ?? "")
.then((res) => {
output.value = res.data;
});
});
return output;
};