refactor: Add threaded view to Notes

This commit is contained in:
Jesse Wierzbinski 2024-11-04 23:55:02 +01:00
parent 4c3b637197
commit e578fa3318
No known key found for this signature in database
4 changed files with 70 additions and 32 deletions

View file

@ -1,18 +1,24 @@
import type { Client } from "@versia/client";
import type { Status } from "@versia/client/types";
export const useNote = (client: MaybeRef<Client | null>, noteId: string) => {
if (!ref(client).value) {
export const useNote = (
client: MaybeRef<Client | null>,
noteId: MaybeRef<string | null>,
) => {
if (!(toValue(client) && toValue(noteId))) {
return ref(null as Status | null);
}
const output = ref(null as Status | null);
ref(client)
.value?.getStatus(noteId)
.then((res) => {
output.value = res.data;
});
watchEffect(() => {
toValue(noteId) &&
toValue(client)
?.getStatus(toValue(noteId) as string)
.then((res) => {
output.value = res.data;
});
});
return output;
};