fixed triggers to sort children of notes with "sorted" label, closes #1126

This commit is contained in:
zadam 2020-06-23 22:03:01 +02:00
parent a0395e9866
commit c78ca4c9db
3 changed files with 13 additions and 3 deletions

View File

@ -164,10 +164,16 @@ async function changeTitle(req) {
return [400, `Note ${noteId} is not available for change`];
}
const noteTitleChanged = note.title !== title;
note.title = title;
await note.save();
if (noteTitleChanged) {
await noteService.triggerNoteTitleChanged(note);
}
return note;
}
@ -189,4 +195,4 @@ module.exports = {
getRelationMap,
changeTitle,
duplicateNote
};
};

View File

@ -68,6 +68,9 @@ eventService.subscribe(eventService.ENTITY_CREATED, async ({ entityName, entity
await note.setContent(await targetNote.getContent());
}
else if (entity.type === 'label' && entity.name === 'sorted') {
await treeService.sortNotesAlphabetically(entity.noteId);
}
}
else if (entityName === 'notes') {
await runAttachedRelations(entity, 'runOnNoteCreation', entity);
@ -135,4 +138,4 @@ eventService.subscribe(eventService.ENTITY_DELETED, async ({ entityName, entity
targetNote.invalidateAttributeCache();
}
});
});
});

View File

@ -778,5 +778,6 @@ module.exports = {
protectNoteRecursively,
scanForLinks,
duplicateNote,
getUndeletedParentBranches
getUndeletedParentBranches,
triggerNoteTitleChanged
};