mirror of
https://github.com/zadam/trilium.git
synced 2025-11-03 20:06:08 +01:00
added new label "sorted" which will keep children notes alphabetically sorted, fixes #82
This commit is contained in:
27
src/services/handlers.js
Normal file
27
src/services/handlers.js
Normal file
@@ -0,0 +1,27 @@
|
||||
const eventService = require('./events');
|
||||
const scriptService = require('./script');
|
||||
const relationService = require('./relations');
|
||||
const treeService = require('./tree');
|
||||
const messagingService = require('./messaging');
|
||||
|
||||
eventService.subscribe(eventService.NOTE_TITLE_CHANGED, async note => {
|
||||
const relations = await relationService.getEffectiveRelations(note.noteId, 'runOnNoteTitleChange');
|
||||
|
||||
for (const relation of relations) {
|
||||
const scriptNote = await relation.getTargetNote();
|
||||
|
||||
await scriptService.executeNote(scriptNote, scriptNote, note);
|
||||
}
|
||||
|
||||
if (!note.isRoot()) {
|
||||
const parents = await note.getParentNotes();
|
||||
|
||||
for (const parent of parents) {
|
||||
if (await parent.hasLabel("sorted")) {
|
||||
await treeService.sortNotesAlphabetically(parent.noteId);
|
||||
|
||||
messagingService.sendMessageToAllClients({ type: 'refresh-tree' });
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user