2024-04-22 09:38:51 +02:00
|
|
|
import type { Mastodon } from "megalodon";
|
2024-04-26 01:04:45 +02:00
|
|
|
import type { Instance } from "~/types/mastodon/instance";
|
2024-04-22 09:38:51 +02:00
|
|
|
|
2024-04-27 03:28:12 +02:00
|
|
|
type InstanceWithExtra = Instance & {
|
|
|
|
|
banner?: string;
|
|
|
|
|
lysand_version?: string;
|
|
|
|
|
};
|
|
|
|
|
|
2024-04-27 06:50:30 +02:00
|
|
|
export const useInstance = (client: MaybeRef<Mastodon | null>) => {
|
|
|
|
|
if (!ref(client).value) {
|
2024-04-27 03:28:12 +02:00
|
|
|
return ref(null as InstanceWithExtra | null);
|
2024-04-22 09:38:51 +02:00
|
|
|
}
|
|
|
|
|
|
2024-04-27 03:28:12 +02:00
|
|
|
const output = ref(null as InstanceWithExtra | null);
|
|
|
|
|
|
2024-04-27 06:50:30 +02:00
|
|
|
ref(client)
|
|
|
|
|
.value?.getInstance()
|
|
|
|
|
.then((res) => {
|
|
|
|
|
output.value = res.data;
|
|
|
|
|
});
|
2024-04-27 03:28:12 +02:00
|
|
|
|
|
|
|
|
return output;
|
2024-04-22 09:38:51 +02:00
|
|
|
};
|