mirror of
https://github.com/zadam/trilium.git
synced 2025-06-06 18:08:33 +02:00
fixed "create note after" position issue
This commit is contained in:
parent
ca77211b38
commit
88147f7a0a
@ -30,6 +30,23 @@ function addEntityChange(entityChange, sourceId, isSynced) {
|
||||
cls.addEntityChange(localEntityChange);
|
||||
}
|
||||
|
||||
function addNoteReorderingEntityChange(parentNoteId, sourceId) {
|
||||
addEntityChange({
|
||||
entityName: "note_reordering",
|
||||
entityId: parentNoteId,
|
||||
hash: 'N/A',
|
||||
isErased: false,
|
||||
utcDateChanged: dateUtils.utcNowDateTime()
|
||||
}, sourceId);
|
||||
|
||||
const eventService = require('./events');
|
||||
|
||||
eventService.emit(eventService.ENTITY_CHANGED, {
|
||||
entityName: 'note_reordering',
|
||||
entity: sql.getMap(`SELECT branchId, notePosition FROM branches WHERE isDeleted = 0 AND parentNoteId = ?`, [parentNoteId])
|
||||
});
|
||||
}
|
||||
|
||||
function moveEntityChangeToTop(entityName, entityId) {
|
||||
const [hash, isSynced] = sql.getRow(`SELECT * FROM entity_changes WHERE entityName = ? AND entityId = ?`, [entityName, entityId]);
|
||||
|
||||
@ -121,13 +138,7 @@ function fillAllEntityChanges() {
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
addNoteReorderingEntityChange: (parentNoteId, sourceId) => addEntityChange({
|
||||
entityName: "note_reordering",
|
||||
entityId: parentNoteId,
|
||||
hash: 'N/A',
|
||||
isErased: false,
|
||||
utcDateChanged: dateUtils.utcNowDateTime()
|
||||
}, sourceId),
|
||||
addNoteReorderingEntityChange,
|
||||
moveEntityChangeToTop,
|
||||
addEntityChange,
|
||||
fillAllEntityChanges,
|
||||
|
@ -153,6 +153,19 @@ eventService.subscribe([eventService.ENTITY_CHANGED, eventService.ENTITY_DELETED
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (entityName === 'note_reordering') {
|
||||
const parentNoteIds = new Set();
|
||||
|
||||
for (const branchId in entity) {
|
||||
const branch = noteCache.branches[branchId];
|
||||
|
||||
if (branch) {
|
||||
branch.notePosition = entity[branchId];
|
||||
|
||||
parentNoteIds.add(branch.parentNoteId);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
eventService.subscribe(eventService.ENTER_PROTECTED_SESSION, () => {
|
||||
|
Loading…
x
Reference in New Issue
Block a user