mirror of
https://iceshrimp.dev/crimekillz/trashposs
synced 2024-11-22 08:53:48 +01:00
Fix note conversation ws/streaming updates, resolves #164
This commit is contained in:
parent
c1d9f5ab65
commit
17630facd8
@ -185,7 +185,7 @@ import { getNoteMenu } from "@/scripts/get-note-menu";
|
|||||||
import { useNoteCapture } from "@/scripts/use-note-capture";
|
import { useNoteCapture } from "@/scripts/use-note-capture";
|
||||||
import { deepClone } from "@/scripts/clone";
|
import { deepClone } from "@/scripts/clone";
|
||||||
import { stream } from "@/stream";
|
import { stream } from "@/stream";
|
||||||
import { NoteUpdatedEvent } from "iceshrimp-js/built/streaming.types";
|
import { NoteUpdatedEvent } from "iceshrimp-js/src/streaming.types";
|
||||||
import appear from "@/directives/appear";
|
import appear from "@/directives/appear";
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
@ -403,41 +403,24 @@ function loadTab() {
|
|||||||
async function onNoteUpdated(noteData: NoteUpdatedEvent): Promise<void> {
|
async function onNoteUpdated(noteData: NoteUpdatedEvent): Promise<void> {
|
||||||
const { type, id, body } = noteData;
|
const { type, id, body } = noteData;
|
||||||
|
|
||||||
let found = -1;
|
|
||||||
if (id === note.id) {
|
|
||||||
found = 0;
|
|
||||||
} else {
|
|
||||||
for (let i = 0; i < replies.value.length; i++) {
|
|
||||||
const reply = replies.value[i];
|
|
||||||
if (reply.id === id) {
|
|
||||||
found = i + 1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (found === -1) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case "replied":
|
case "replied":
|
||||||
const { id: createdId } = body;
|
const createdId = body.id;
|
||||||
const replyNote = await os.api("notes/show", {
|
const replyNote = await os.api("notes/show", {
|
||||||
noteId: createdId,
|
noteId: createdId,
|
||||||
});
|
});
|
||||||
|
delete replyNote.reply;
|
||||||
replies.value.splice(found, 0, replyNote);
|
replies.value.unshift(replyNote);
|
||||||
if (found === 0) {
|
if (id === note.id) {
|
||||||
directReplies.push(replyNote);
|
directReplies?.push(replyNote);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "deleted":
|
case "deleted":
|
||||||
if (found === 0) {
|
if (id === note.id) {
|
||||||
isDeleted.value = true;
|
isDeleted.value = true;
|
||||||
} else {
|
} else {
|
||||||
replies.value.splice(found - 1, 1);
|
replies.value.splice(replies.value.findIndex(p => p.id == id), 1);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -258,13 +258,13 @@ const muted = ref(getWordSoftMute(note, $i, defaultStore.state.mutedWords));
|
|||||||
const translation = ref(null);
|
const translation = ref(null);
|
||||||
const translating = ref(false);
|
const translating = ref(false);
|
||||||
const replies: misskey.entities.Note[] =
|
const replies: misskey.entities.Note[] =
|
||||||
props.conversation
|
$computed(() => props.conversation
|
||||||
?.filter(
|
?.filter(
|
||||||
(item) =>
|
(item) =>
|
||||||
item.replyId === props.note.id ||
|
item.replyId === props.note.id ||
|
||||||
item.renoteId === props.note.id,
|
item.renoteId === props.note.id,
|
||||||
)
|
)
|
||||||
.reverse() ?? [];
|
.reverse() ?? []);
|
||||||
const enableEmojiReactions = defaultStore.state.enableEmojiReactions;
|
const enableEmojiReactions = defaultStore.state.enableEmojiReactions;
|
||||||
const expandOnNoteClick = defaultStore.state.expandOnNoteClick;
|
const expandOnNoteClick = defaultStore.state.expandOnNoteClick;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user