continuing work on hoisting notes

This commit is contained in:
azivner
2018-12-12 20:39:56 +01:00
parent 6fbf28b30d
commit 17d030e800
4 changed files with 27 additions and 9 deletions

View File

@@ -38,6 +38,7 @@ async function getNotes(noteIds) {
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.
// also now with note hoisting, it is possible to have the note displayed without its parent chain being loaded
const relations = await sql.getManyRows(`SELECT branchId, noteId AS 'childNoteId', parentNoteId, notePosition FROM branches WHERE isDeleted = 0
AND (parentNoteId IN (???) OR noteId IN (???))`, noteIds);
@@ -65,6 +66,9 @@ async function getTree() {
)
SELECT branches.* FROM tree JOIN branches USING(noteId) WHERE branches.isDeleted = 0 ORDER BY branches.notePosition`, [hoistedNoteId]);
// we also want root branch in there because all the paths start with root
branches.push(await sql.getRow(`SELECT * FROM branches WHERE branchId = 'root'`));
const noteIds = Array.from(new Set(branches.map(b => b.noteId)));
const notes = await getNotes(noteIds);