frontend/app/composables/NoteContext.ts

21 lines
539 B
TypeScript
Raw Permalink Normal View History

import type { Context } from "@versia/client/schemas";
import type { z } from "zod";
export const useNoteContext = (noteId: MaybeRef<string | null>) => {
const authStore = useAuthStore();
const output = ref(null as z.infer<typeof Context> | null);
watchEffect(() => {
2024-06-20 02:07:56 +02:00
if (toValue(noteId)) {
authStore.client
.getStatusContext(toValue(noteId) ?? "")
.then((res) => {
output.value = res.data;
});
2024-06-20 02:07:56 +02:00
}
});
return output;
};