+
@@ -73,7 +73,7 @@ SPDX-License-Identifier: AGPL-3.0-only
-
+
{{ i18n.ts.continueThread }}
@@ -119,6 +119,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,6 +142,7 @@ const likeButton = shallowRef();
let appearNote = computed(() => isRenote ? props.note.renote as Misskey.entities.Note : props.note);
const defaultLike = computed(() => defaultStore.state.like ? defaultStore.state.like : null);
+const replies = ref([]);
const isRenote = (
props.note.renote != null &&
@@ -149,10 +151,26 @@ const isRenote = (
props.note.poll == null
);
+async function addReplyTo(replyNote: Misskey.entities.Note) {
+ replies.value.unshift(replyNote);
+ appearNote.value.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.value.repliesCount -= 1;
+ }
+}
+
useNoteCapture({
rootEl: el,
note: appearNote,
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) {
@@ -259,8 +277,6 @@ watch(() => props.expandAllCws, (expandAllCws) => {
if (expandAllCws !== showContent.value) showContent.value = expandAllCws;
});
-let replies = ref([]);
-
function boostVisibility() {
os.popupMenu([
{
diff --git a/packages/frontend/src/scripts/use-note-capture.ts b/packages/frontend/src/scripts/use-note-capture.ts
index ab232598c..427bc6ff3 100644
--- a/packages/frontend/src/scripts/use-note-capture.ts
+++ b/packages/frontend/src/scripts/use-note-capture.ts
@@ -14,6 +14,8 @@ export function useNoteCapture(props: {
note: Ref;
pureNote: Ref;
isDeletedRef: Ref;
+ onReplyCallback: (replyNote: Misskey.entities.Note) => void | undefined;
+ onDeleteCallback: (id: Misskey.entities.Note['id']) => void | undefined;
}) {
const note = props.note;
const pureNote = props.pureNote !== undefined ? props.pureNote : props.note;
@@ -25,6 +27,17 @@ export function useNoteCapture(props: {
if ((id !== note.value.id) && (id !== pureNote.value.id)) return;
switch (type) {
+ case 'replied': {
+ if (!props.onReplyCallback) break;
+
+ const replyNote = await os.api("notes/show", {
+ noteId: body.id,
+ });
+
+ await props.onReplyCallback(replyNote);
+ break;
+ }
+
case 'reacted': {
const reaction = body.reaction;
@@ -76,6 +89,8 @@ export function useNoteCapture(props: {
case 'deleted': {
props.isDeletedRef.value = true;
+
+ if (props.onDeleteCallback) await props.onDeleteCallback(id);
break;
}