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

This commit is contained in:
zadam 2022-12-25 13:46:31 +01:00
parent afb6e860ea
commit f249d6cb26
2 changed files with 8 additions and 4 deletions

View File

@ -36,7 +36,9 @@ export default class HistoryNavigationButton extends ButtonFromNoteWidget {
// API is broken and will be replaced: https://github.com/electron/electron/issues/33899 // API is broken and will be replaced: https://github.com/electron/electron/issues/33899
// until then no context menu // until then no context menu
return; if (true) { // avoid warning in dev console
return;
}
if (this.webContents.history.length < 2) { if (this.webContents.history.length < 2) {
return; return;

View File

@ -4,8 +4,6 @@ const treeService = require('./tree');
const noteService = require('./notes'); const noteService = require('./notes');
const becca = require('../becca/becca'); const becca = require('../becca/becca');
const Attribute = require('../becca/entities/attribute'); const Attribute = require('../becca/entities/attribute');
const debounce = require('debounce');
const specialNotesService = require("./special_notes");
function runAttachedRelations(note, relationName, originEntity) { function runAttachedRelations(note, relationName, originEntity) {
if (!note) { if (!note) {
@ -101,7 +99,7 @@ eventService.subscribe(eventService.ENTITY_CREATED, ({ entityName, entity }) =>
noteService.duplicateSubtreeWithoutRoot(templateNote.noteId, note.noteId); 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); handleSortedAttribute(entity);
} }
else if (entity.type === 'label') { else if (entity.type === 'label') {
@ -110,6 +108,10 @@ eventService.subscribe(eventService.ENTITY_CREATED, ({ entityName, entity }) =>
} }
else if (entityName === 'branches') { else if (entityName === 'branches') {
runAttachedRelations(entity.getNote(), 'runOnBranchCreation', entity); runAttachedRelations(entity.getNote(), 'runOnBranchCreation', entity);
if (entity.parentNote?.hasLabel("sorted")) {
treeService.sortNotesIfNeeded(entity.parentNoteId);
}
} }
else if (entityName === 'notes') { else if (entityName === 'notes') {
runAttachedRelations(entity, 'runOnNoteCreation', entity); runAttachedRelations(entity, 'runOnNoteCreation', entity);