diff --git a/packages/frontend/src/scripts/entity-manager.ts b/packages/frontend/src/scripts/entity-manager.ts index e28e5c2264..9570c5ad54 100644 --- a/packages/frontend/src/scripts/entity-manager.ts +++ b/packages/frontend/src/scripts/entity-manager.ts @@ -208,34 +208,38 @@ export class NoteManager { interruptorUnwatch: () => void, executeInterruptor: () => Promise, } { - const note = this.get(id); - if (noteViewInterruptors.length === 0) { - // noteViewInterruptorがない場合はcomputed noteを直接渡す - return { - interruptedNote: note as InterruptedCachedNote, - interruptorUnwatch: () => { }, - executeInterruptor: () => Promise.resolve(), - }; - } + const firstNote = this.get(id); + const interruptedNote = ref(firstNote.value); - const interruptedNote = ref(deepClone(note.value)); + const executeInterruptor = async () => { + const note = this.get(id); + + if (this.isDebuggerEnabled) console.log('NoteManager: executeInterruptor', id, { note: note.value, interruptedNote, noteViewInterruptors }); - async function executeInterruptor() { if (note.value == null) { interruptedNote.value = null; return; } - let result = deepClone(note.value); + if (noteViewInterruptors.length === 0) { + interruptedNote.value = note.value; + return; + } + + let result = deepClone(firstNote.value); for (const interruptor of noteViewInterruptors) { result = await interruptor.handler(result) as Note; } interruptedNote.value = result; - } - const interruptorUnwatch = watch(note, executeInterruptor); + }; + + const interruptorUnwatch = () => { + if (this.isDebuggerEnabled) console.log('NoteManager: interruptorUnwatch', id, interruptedNote); + return watch(firstNote, executeInterruptor); + }; if (this.isDebuggerEnabled) { - console.log('NoteManager: get interrupted note (new)', id, { note, interruptedNote }); + console.log('NoteManager: get interrupted note (new)', id, { note: firstNote, interruptedNote }); } return {