mirror of
https://github.com/versia-pub/frontend.git
synced 2025-12-06 08:28:20 +01:00
33 lines
956 B
TypeScript
33 lines
956 B
TypeScript
import type { Mastodon } from "megalodon";
|
|
import type { InstanceWithExtra } from "./Instance";
|
|
|
|
export const useCacheRefresh = (client: MaybeRef<Mastodon | null>) => {
|
|
const tokenData = useTokenData();
|
|
const me = useMe();
|
|
const instance = useInstance();
|
|
const customEmojis = useCustomEmojis();
|
|
|
|
// Refresh custom emojis and instance data and me on every reload
|
|
watchEffect(async () => {
|
|
if (tokenData.value) {
|
|
await toValue(client)
|
|
?.verifyAccountCredentials()
|
|
.then((res) => {
|
|
me.value = res.data;
|
|
});
|
|
}
|
|
|
|
toValue(client)
|
|
?.getInstanceCustomEmojis()
|
|
.then((res) => {
|
|
customEmojis.value = res.data;
|
|
});
|
|
|
|
toValue(client)
|
|
?.getInstance()
|
|
.then((res) => {
|
|
instance.value = res.data as InstanceWithExtra;
|
|
});
|
|
});
|
|
};
|