summaryrefslogtreecommitdiff
path: root/packages/frontend/src/components/MkNoteSub.vue
diff options
context:
space:
mode:
authordakkar <dakkar@thenautilus.net>2023-12-21 16:00:59 +0000
committerdakkar <dakkar@thenautilus.net>2023-12-23 14:09:52 +0000
commit576a87118c18c9354f35ee3cb207d5e6bccdba91 (patch)
treeb4c8f66083e458587337aba8fdbe60051862bbea /packages/frontend/src/components/MkNoteSub.vue
parentreal-time update: hide deleted replies (diff)
downloadsharkey-576a87118c18c9354f35ee3cb207d5e6bccdba91.tar.gz
sharkey-576a87118c18c9354f35ee3cb207d5e6bccdba91.tar.bz2
sharkey-576a87118c18c9354f35ee3cb207d5e6bccdba91.zip
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
Diffstat (limited to 'packages/frontend/src/components/MkNoteSub.vue')
-rw-r--r--packages/frontend/src/components/MkNoteSub.vue15
1 files changed, 13 insertions, 2 deletions
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
</div>
</div>
<template v-if="depth < numberOfReplies">
- <MkNoteSub v-for="reply in replies" :key="reply.id" :note="reply" :class="$style.reply" :detail="true" :depth="depth + 1" :expandAllCws="props.expandAllCws"/>
+ <MkNoteSub v-for="reply in replies" :key="reply.id" :note="reply" :class="$style.reply" :detail="true" :depth="depth + 1" :expandAllCws="props.expandAllCws" :onDeleteCallback="removeReply"/>
</template>
<div v-else :class="$style.more">
<MkA class="_link" :to="notePage(note)">{{ i18n.ts.continueThread }} <i class="ph-caret-double-right ph-bold ph-lg"></i></MkA>
@@ -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) {