2024-08-28 00:23:29 +02:00
|
|
|
import type { Client } from "@versia/client";
|
|
|
|
|
import type { Status } from "@versia/client/types";
|
2024-04-22 09:38:51 +02:00
|
|
|
|
2024-11-04 23:55:02 +01:00
|
|
|
export const useNote = (
|
|
|
|
|
client: MaybeRef<Client | null>,
|
|
|
|
|
noteId: MaybeRef<string | null>,
|
|
|
|
|
) => {
|
|
|
|
|
if (!(toValue(client) && toValue(noteId))) {
|
2024-04-27 03:28:12 +02:00
|
|
|
return ref(null as Status | null);
|
2024-04-22 09:38:51 +02:00
|
|
|
}
|
|
|
|
|
|
2024-04-27 03:28:12 +02:00
|
|
|
const output = ref(null as Status | null);
|
|
|
|
|
|
2024-11-04 23:55:02 +01:00
|
|
|
watchEffect(() => {
|
|
|
|
|
toValue(noteId) &&
|
|
|
|
|
toValue(client)
|
|
|
|
|
?.getStatus(toValue(noteId) as string)
|
|
|
|
|
.then((res) => {
|
|
|
|
|
output.value = res.data;
|
|
|
|
|
});
|
|
|
|
|
});
|
2024-04-27 03:28:12 +02:00
|
|
|
|
|
|
|
|
return output;
|
2024-04-22 09:38:51 +02:00
|
|
|
};
|