mirror of
https://github.com/versia-pub/frontend.git
synced 2025-12-06 08:28:20 +01:00
16 lines
392 B
TypeScript
16 lines
392 B
TypeScript
import { Mastodon, type OAuth } from "megalodon";
|
|
|
|
export const useMegalodon = (
|
|
tokenData?: MaybeRef<OAuth.TokenData | null>,
|
|
disableOnServer = false,
|
|
): Ref<Mastodon | null> => {
|
|
if (disableOnServer && process.server) {
|
|
return ref(null);
|
|
}
|
|
|
|
return computed(
|
|
() =>
|
|
new Mastodon(useBaseUrl().value, toValue(tokenData)?.access_token),
|
|
);
|
|
};
|