same event handling note execute only once, closes #1278

pull/255/head
zadam 2020-10-12 22:30:30 +07:00
parent cabb78b3e4
commit a665d193eb
1 changed files with 9 additions and 11 deletions

@ -6,17 +6,15 @@ const repository = require('./repository');
const Attribute = require('../entities/attribute'); const Attribute = require('../entities/attribute');
function runAttachedRelations(note, relationName, originEntity) { function runAttachedRelations(note, relationName, originEntity) {
const runRelations = note.getRelations(relationName); // same script note can get here with multiple ways, but execute only once
const notesToRun = new Set(
for (const relation of runRelations) { note.getRelations(relationName)
const scriptNote = relation.getTargetNote(); .map(relation => relation.getTargetNote())
.filter(note => !!note)
if (scriptNote) { );
scriptService.executeNoteNoException(scriptNote, { originEntity });
} for (const noteToRun of notesToRun) {
else { scriptService.executeNoteNoException(noteToRun, { originEntity });
log.error(`Target note ${relation.value} of atttribute ${relation.attributeId} has not been found.`);
}
} }
} }