mirror of
https://github.com/versia-pub/frontend.git
synced 2026-03-13 03:29:16 +01:00
refactor: ✨ Add threaded view to Notes
This commit is contained in:
parent
4c3b637197
commit
e578fa3318
4 changed files with 70 additions and 32 deletions
|
|
@ -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;
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue