From 576a87118c18c9354f35ee3cb207d5e6bccdba91 Mon Sep 17 00:00:00 2001 From: dakkar Date: Thu, 21 Dec 2023 16:00:59 +0000 Subject: real-time update: adjust replyCount up/down this also fixes the connecting lines in the Sk-style view thanks @ShittyKopper for reporting the bug! NOTE: at this point, the `isDeletedRef` boolean is pretty much useless, because we're directly removing deleted notes from the `replies` array and therefore from the DOM (we were just hiding them, before); I'm intentionally not touching `isDeletedRef` to simplify merges from upstream --- packages/frontend/src/components/MkNoteSub.vue | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'packages/frontend/src/components/MkNoteSub.vue') diff --git a/packages/frontend/src/components/MkNoteSub.vue b/packages/frontend/src/components/MkNoteSub.vue index fd8904f3c2..d1e45b30bb 100644 --- a/packages/frontend/src/components/MkNoteSub.vue +++ b/packages/frontend/src/components/MkNoteSub.vue @@ -65,7 +65,7 @@ SPDX-License-Identifier: AGPL-3.0-only
{{ i18n.ts.continueThread }} @@ -110,6 +110,7 @@ const props = withDefaults(defineProps<{ note: Misskey.entities.Note; detail?: boolean; expandAllCws?: boolean; + onDeleteCallback?: (id: Misskey.entities.Note['id']) => void; // how many notes are in between this one and the note being viewed in detail depth?: number; @@ -141,8 +142,17 @@ const isRenote = ( props.note.poll == null ); -async function addReplyTo(note, replyNote: Misskey.entities.Note) { +async function addReplyTo(replyNote: Misskey.entities.Note) { replies.value.unshift(replyNote); + appearNote.repliesCount += 1; +} + +async function removeReply(id: Misskey.entities.Note['id']) { + const replyIdx = replies.value.findIndex(note => note.id === id); + if (replyIdx >= 0) { + replies.value.splice(replyIdx, 1); + appearNote.repliesCount -= 1; + } } useNoteCapture({ @@ -151,6 +161,7 @@ useNoteCapture({ isDeletedRef: isDeleted, // only update replies if we are, in fact, showing replies onReplyCallback: props.detail && props.depth < numberOfReplies.value ? addReplyTo : undefined, + onDeleteCallback: props.detail && props.depth < numberOfReplies.value ? props.onDeleteCallback : undefined, }); if ($i) { -- cgit v1.2.3-freya