parent
bc601c6c85
commit
a753951b3d
|
|
@ -216,38 +216,34 @@ export class NoteManager {
|
||||||
interruptorUnwatch: () => void,
|
interruptorUnwatch: () => void,
|
||||||
executeInterruptor: () => Promise<void>,
|
executeInterruptor: () => Promise<void>,
|
||||||
} {
|
} {
|
||||||
const firstNote = this.get(id);
|
const note = this.get(id);
|
||||||
const interruptedNote = ref<Note | null>(firstNote.value);
|
if (noteViewInterruptors.length === 0) {
|
||||||
|
// noteViewInterruptorがない場合はcomputed noteを直接渡す
|
||||||
|
return {
|
||||||
|
interruptedNote: note as InterruptedCachedNote,
|
||||||
|
interruptorUnwatch: () => { },
|
||||||
|
executeInterruptor: () => Promise.resolve(),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
const executeInterruptor = async () => {
|
const interruptedNote = ref<Note | null>(deepClone(note.value));
|
||||||
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) {
|
if (note.value == null) {
|
||||||
interruptedNote.value = null;
|
interruptedNote.value = null;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (noteViewInterruptors.length === 0) {
|
let result = deepClone(note.value);
|
||||||
interruptedNote.value = note.value;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
let result = deepClone(firstNote.value);
|
|
||||||
for (const interruptor of noteViewInterruptors) {
|
for (const interruptor of noteViewInterruptors) {
|
||||||
result = await interruptor.handler(result) as Note;
|
result = await interruptor.handler(result) as Note;
|
||||||
}
|
}
|
||||||
interruptedNote.value = result;
|
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) {
|
if (this.isDebuggerEnabled) {
|
||||||
console.log('NoteManager: get interrupted note (new)', id, { note: firstNote, interruptedNote });
|
console.log('NoteManager: get interrupted note (new)', id, { note, interruptedNote });
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue