Skip to content

Build your personal knowledge base with Trilium Notes

fix sorting after cloning/moving notes into sorted parent, closes #3453

zadamf249d6cb261a
diff --git a/src/public/app/widgets/buttons/history_navigation.js b/src/public/app/widgets/buttons/history_navigation.js
index 15de9454f9..430aeae214 100644
--- a/src/public/app/widgets/buttons/history_navigation.js
+++ b/src/public/app/widgets/buttons/history_navigation.js
@@ -36,7 +36,9 @@ export default class HistoryNavigationButton extends ButtonFromNoteWidget {
// API is broken and will be replaced: https://github.com/electron/electron/issues/33899
// until then no context menu
- return;
+ if (true) { // avoid warning in dev console
+ return;
+ }
if (this.webContents.history.length < 2) {
return;
diff --git a/src/services/handlers.js b/src/services/handlers.js
index 80d4ce39a4..fc67b464f0 100644
--- a/src/services/handlers.js
+++ b/src/services/handlers.js
@@ -4,8 +4,6 @@ const treeService = require('./tree');
const noteService = require('./notes');
const becca = require('../becca/becca');
const Attribute = require('../becca/entities/attribute');
-const debounce = require('debounce');
-const specialNotesService = require("./special_notes");
function runAttachedRelations(note, relationName, originEntity) {
if (!note) {
@@ -101,7 +99,7 @@ eventService.subscribe(eventService.ENTITY_CREATED, ({ entityName, entity }) =>
noteService.duplicateSubtreeWithoutRoot(templateNote.noteId, note.noteId);
}
}
- else if (entity.type === 'label' && entity.name === 'sorted') {
+ else if (entity.type === 'label' && ['sorted', 'sortDirection', 'sortFoldersFirst'].includes(entity.name)) {
handleSortedAttribute(entity);
}
else if (entity.type === 'label') {
@@ -110,6 +108,10 @@ eventService.subscribe(eventService.ENTITY_CREATED, ({ entityName, entity }) =>
}
else if (entityName === 'branches') {
runAttachedRelations(entity.getNote(), 'runOnBranchCreation', entity);
+
+ if (entity.parentNote?.hasLabel("sorted")) {
+ treeService.sortNotesIfNeeded(entity.parentNoteId);
+ }
}
else if (entityName === 'notes') {
runAttachedRelations(entity, 'runOnNoteCreation', entity);