From be2e596027c88a1a0a3ecdea019e3635d7f599e9 Mon Sep 17 00:00:00 2001 From: tamaina Date: Sun, 30 Jul 2023 11:08:05 +0000 Subject: [PATCH] fix --- packages/frontend/src/components/MkNote.vue | 20 ++++++++++--------- .../src/components/MkNoteDetailed.vue | 2 +- .../frontend/src/scripts/entity-manager.ts | 17 ++++++++-------- 3 files changed, 21 insertions(+), 18 deletions(-) diff --git a/packages/frontend/src/components/MkNote.vue b/packages/frontend/src/components/MkNote.vue index 2a624c16b9..059a60392f 100644 --- a/packages/frontend/src/components/MkNote.vue +++ b/packages/frontend/src/components/MkNote.vue @@ -473,7 +473,8 @@ function showReactions(): void { } const unuse = ref<() => void>(); -unuse.value = noteManager.useNote(props.note.id, true).unuse; + +unuse.value = noteManager.useNote(appearNote.value?.id ?? props.note.id, true).unuse; onMounted(() => { executeInterruptor(); @@ -488,19 +489,20 @@ onUnmounted(() => { }); onActivated(() => { - if (!unuse.value) { - unuse.value = noteManager.useNote(props.note.id, true).unuse; + if (!unuse.value && appearNote.value) { + unuse.value = noteManager.useNote(appearNote.value?.id ?? props.note.id, true).unuse; } }); onDeactivated(() => { + const _unuse = unuse.value; + unuse.value = undefined; // 不要なキャッシュ消去や通信を防止するため遅延させる - setTimeout(() => { - if (unuse.value) { - unuse.value(); - unuse.value = undefined; - } - }, 1000); + if (_unuse) { + setTimeout(() => { + _unuse(); + }, 1000); + } }); diff --git a/packages/frontend/src/components/MkNoteDetailed.vue b/packages/frontend/src/components/MkNoteDetailed.vue index 40a089b137..10a0a5a67a 100644 --- a/packages/frontend/src/components/MkNoteDetailed.vue +++ b/packages/frontend/src/components/MkNoteDetailed.vue @@ -407,7 +407,7 @@ function blur() { el.value?.blur(); } -const { note: fetching, unuse } = noteManager.useNote(props.note.id, true); +const { note: fetching, unuse } = noteManager.useNote(appearNote.value?.id ?? props.note.id, true); onMounted(async () => { await fetching; diff --git a/packages/frontend/src/scripts/entity-manager.ts b/packages/frontend/src/scripts/entity-manager.ts index 10109f75dc..7481047cb3 100644 --- a/packages/frontend/src/scripts/entity-manager.ts +++ b/packages/frontend/src/scripts/entity-manager.ts @@ -47,6 +47,14 @@ type CachedNoteSource = Ref; type CachedNote = ComputedRef; type InterruptedCachedNote = Ref; +export function isRenote(note: Note | OmittedNote): boolean { + return note != null && + note.renoteId != null && + note.text == null && + note.fileIds?.length === 0 && + note.poll == null; +} + /** * ノートのキャッシュを管理する * 基本的な使い方: @@ -197,14 +205,7 @@ export class NoteManager { */ public getNoteViewBase(id: string) { const { interruptedNote: note, interruptorUnwatch, executeInterruptor } = this.getInterrupted(id); - //const note = this.get(id); - const isRenote = computed(() => ( - note.value != null && - note.value.renote != null && - note.value.text == null && - note.value.fileIds?.length === 0 && - note.value.poll == null - )); + const isRenote = computed(() => isRenote(note.value)); const isMyRenote = computed(() => $i && ($i.id === note.value?.userId)); const appearNote = computed(() => (isRenote.value ? note.value?.renote : note.value) ?? null);