2024-06-08 01:09:15 +02:00
|
|
|
import type { LysandClient } from "@lysand-org/client";
|
2024-06-20 01:57:38 +02:00
|
|
|
import type { Context } from "@lysand-org/client/types";
|
2024-05-12 05:42:24 +02:00
|
|
|
|
|
|
|
|
export const useNoteContext = (
|
2024-06-08 01:09:15 +02:00
|
|
|
client: MaybeRef<LysandClient | null>,
|
2024-05-12 05:42:24 +02:00
|
|
|
noteId: MaybeRef<string | null>,
|
|
|
|
|
) => {
|
|
|
|
|
if (!ref(client).value) {
|
|
|
|
|
return ref(null as Context | null);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const output = ref(null as Context | null);
|
|
|
|
|
|
|
|
|
|
watchEffect(() => {
|
|
|
|
|
if (toValue(noteId))
|
|
|
|
|
ref(client)
|
|
|
|
|
.value?.getStatusContext(toValue(noteId) ?? "")
|
|
|
|
|
.then((res) => {
|
2024-06-12 03:02:30 +02:00
|
|
|
output.value = res.data;
|
2024-05-12 05:42:24 +02:00
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return output;
|
|
|
|
|
};
|