feat: show all reacted users initially in reactions tab

This commit is contained in:
naskya 2023-10-17 06:32:36 +09:00
parent 36a4f30377
commit ddbe213f59
No known key found for this signature in database
GPG Key ID: 164DFF24E2D40139

View File

@ -47,11 +47,11 @@ const props = defineProps<{
}>(); }>();
const note = ref<firefish.entities.Note>(); const note = ref<firefish.entities.Note>();
const tab = ref<string>(); const tab = ref<string | null>(null);
const reactions = ref<string[]>(); const reactions = ref<string[]>();
const users = ref(); const users = ref();
watch(tab, async () => { async function updateUsers(): void {
const res = await os.api("notes/reactions", { const res = await os.api("notes/reactions", {
noteId: props.noteId, noteId: props.noteId,
type: tab.value, type: tab.value,
@ -59,15 +59,17 @@ watch(tab, async () => {
}); });
users.value = res.map((x) => x.user); users.value = res.map((x) => x.user);
}); }
watch(tab, updateUsers);
onMounted(() => { onMounted(() => {
os.api("notes/show", { os.api("notes/show", {
noteId: props.noteId, noteId: props.noteId,
}).then((res) => { }).then(async (res) => {
reactions.value = Object.keys(res.reactions); reactions.value = Object.keys(res.reactions);
tab.value = reactions.value[0];
note.value = res; note.value = res;
await updateUsers();
}); });
}); });
</script> </script>