frontend/composables/NoteContext.ts

26 lines
625 B
TypeScript
Raw Normal View History

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