Skip to content

Build your personal knowledge base with Trilium Notes

fix note sorting with sync - deleted note trees should not be sorted

azivner651a9fb3272c
diff --git a/plugins/reddit.js b/plugins/reddit.js
index 489d385466..f12826cef9 100644
--- a/plugins/reddit.js
+++ b/plugins/reddit.js
@@ -34,7 +34,8 @@ function redditId(kind, id) {
async function getNoteStartingWith(parentNoteId, startsWith) {
return await sql.getFirstValue(`SELECT note_id FROM notes JOIN notes_tree USING(note_id)
WHERE parent_note_id = ? AND note_title LIKE '${startsWith}%'
- AND notes.is_deleted = 0 AND notes_tree.is_deleted = 0`, [parentNoteId]);
+ AND notes.is_deleted = 0 AND is_protected = 0
+ AND notes_tree.is_deleted = 0`, [parentNoteId]);
}
async function getRootNoteId() {
diff --git a/services/tree.js b/services/tree.js
index 77e786fbe0..2a0a45623b 100644
--- a/services/tree.js
+++ b/services/tree.js
@@ -83,7 +83,8 @@ async function loadSubTreeNoteIds(parentNoteId, subTreeNoteIds) {
async function sortNotesAlphabetically(parentNoteId, dataKey, sourceId) {
await sql.doInTransaction(async () => {
const notes = await sql.getAll(`SELECT note_tree_id, note_id, note_title, is_protected
- FROM notes JOIN notes_tree USING(note_id) WHERE parent_note_id = ?`, [parentNoteId]);
+ FROM notes JOIN notes_tree USING(note_id)
+ WHERE notes_tree.is_deleted = 0 AND parent_note_id = ?`, [parentNoteId]);
for (const note of notes) {
if (note.is_protected) {