fix(frontend): Recieve Unrenote on streaming (#12079)

* fix(frontend): Recieve Unrenote

表示しているリノートがリノート解除されたらストリーミングで受信してすぐに消えるようにする

* fix(frontend): Recieve Unrenote lint fixing

* fix(frontend): Recieve Unrenote Decapture

Decapture忘れてたー
This commit is contained in:
atsuchan 2023-10-19 19:36:18 +09:00 committed by GitHub
parent 3c3d05ba2e
commit 7b361224f8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 1 deletions

View File

@ -232,6 +232,7 @@ const keymap = {
useNoteCapture({ useNoteCapture({
rootEl: el, rootEl: el,
note: $$(appearNote), note: $$(appearNote),
pureNote: $$(note),
isDeletedRef: isDeleted, isDeletedRef: isDeleted,
}); });

View File

@ -296,6 +296,7 @@ const reactionsPagination = $computed(() => ({
useNoteCapture({ useNoteCapture({
rootEl: el, rootEl: el,
note: $$(appearNote), note: $$(appearNote),
pureNote: $$(note),
isDeletedRef: isDeleted, isDeletedRef: isDeleted,
}); });

View File

@ -11,15 +11,17 @@ import { $i } from '@/account.js';
export function useNoteCapture(props: { export function useNoteCapture(props: {
rootEl: Ref<HTMLElement>; rootEl: Ref<HTMLElement>;
note: Ref<Misskey.entities.Note>; note: Ref<Misskey.entities.Note>;
pureNote: Ref<Misskey.entities.Note>;
isDeletedRef: Ref<boolean>; isDeletedRef: Ref<boolean>;
}) { }) {
const note = props.note; const note = props.note;
const pureNote = props.pureNote;
const connection = $i ? useStream() : null; const connection = $i ? useStream() : null;
function onStreamNoteUpdated(noteData): void { function onStreamNoteUpdated(noteData): void {
const { type, id, body } = noteData; const { type, id, body } = noteData;
if (id !== note.value.id) return; if ((id !== note.value.id) && (id !== pureNote.value.id)) return;
switch (type) { switch (type) {
case 'reacted': { case 'reacted': {
@ -82,6 +84,7 @@ export function useNoteCapture(props: {
if (connection) { if (connection) {
// TODO: このノートがストリーミング経由で流れてきた場合のみ sr する // TODO: このノートがストリーミング経由で流れてきた場合のみ sr する
connection.send(document.body.contains(props.rootEl.value) ? 'sr' : 's', { id: note.value.id }); connection.send(document.body.contains(props.rootEl.value) ? 'sr' : 's', { id: note.value.id });
if (pureNote.value.id !== note.value.id) connection.send('s', { id: pureNote.value.id });
if (withHandler) connection.on('noteUpdated', onStreamNoteUpdated); if (withHandler) connection.on('noteUpdated', onStreamNoteUpdated);
} }
} }
@ -91,6 +94,11 @@ export function useNoteCapture(props: {
connection.send('un', { connection.send('un', {
id: note.value.id, id: note.value.id,
}); });
if (pureNote.value.id !== note.value.id) {
connection.send('un', {
id: pureNote.value.id,
});
}
if (withHandler) connection.off('noteUpdated', onStreamNoteUpdated); if (withHandler) connection.off('noteUpdated', onStreamNoteUpdated);
} }
} }