2025-05-26 11:19:15 +02:00
|
|
|
import type { Context } from "@versia/client/schemas";
|
|
|
|
|
import type { z } from "zod";
|
2024-05-12 05:42:24 +02:00
|
|
|
|
2025-08-28 07:41:51 +02:00
|
|
|
export const useNoteContext = (noteId: MaybeRef<string | null>) => {
|
|
|
|
|
const authStore = useAuthStore();
|
2024-05-12 05:42:24 +02:00
|
|
|
|
2025-05-26 11:19:15 +02:00
|
|
|
const output = ref(null as z.infer<typeof Context> | null);
|
2024-05-12 05:42:24 +02:00
|
|
|
|
|
|
|
|
watchEffect(() => {
|
2024-06-20 02:07:56 +02:00
|
|
|
if (toValue(noteId)) {
|
2025-08-28 07:41:51 +02:00
|
|
|
authStore.client
|
|
|
|
|
.getStatusContext(toValue(noteId) ?? "")
|
2024-05-12 05:42:24 +02:00
|
|
|
.then((res) => {
|
2024-06-12 03:02:30 +02:00
|
|
|
output.value = res.data;
|
2024-05-12 05:42:24 +02:00
|
|
|
});
|
2024-06-20 02:07:56 +02:00
|
|
|
}
|
2024-05-12 05:42:24 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return output;
|
|
|
|
|
};
|