mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
fixed bug which caused incorrect ordering of lazy loaded branches
This commit is contained in:
parent
85215aa440
commit
65d99f3f06
@ -39,8 +39,14 @@ async function getRelations(noteIds) {
|
||||
// we need to fetch both parentNoteId and noteId matches because we can have loaded child
|
||||
// of which only some of the parents has been loaded.
|
||||
|
||||
return await sql.getManyRows(`SELECT branchId, noteId AS 'childNoteId', parentNoteId FROM branches WHERE isDeleted = 0
|
||||
const relations = await sql.getManyRows(`SELECT branchId, noteId AS 'childNoteId', parentNoteId, notePosition FROM branches WHERE isDeleted = 0
|
||||
AND (parentNoteId IN (???) OR noteId IN (???))`, noteIds);
|
||||
|
||||
// although we're fetching relations for multiple notes, ordering will stay correct for single note as well - relations are being added into tree cache in the order they were returned
|
||||
// cannot use ORDER BY because of usage of getManyRows which is not a single SQL query
|
||||
relations.sort((a, b) => a.notePosition > b.notePosition ? 1 : -1);
|
||||
|
||||
return relations;
|
||||
}
|
||||
|
||||
async function getTree() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user