frontend/composables/ResolveMentions.ts
2024-04-27 19:02:27 -10:00

26 lines
636 B
TypeScript

import type { Mastodon } from "megalodon";
import type { Account } from "~/types/mastodon/account";
import type { Mention } from "~/types/mastodon/mention";
export const useResolveMentions = (
mentions: Mention[],
client: Mastodon | null,
): Ref<Account[]> => {
if (!client) {
return ref([]);
}
const output = ref<Account[]>([]);
(async () => {
output.value = await Promise.all(
mentions.map(async (mention) => {
const response = await client.getAccount(mention.id);
return response.data;
}),
);
})();
return output;
};