mirror of
https://github.com/zadam/trilium.git
synced 2025-12-04 22:44:25 +01:00
fix(sorting): BC! give precedence to #top notes over #sortFolderFirst
This commit is contained in:
parent
3cc64b5764
commit
3ecdcd9ea0
@ -98,15 +98,6 @@ function sortNotes(parentNoteId: string, customSortBy: string = "title", reverse
|
|||||||
}
|
}
|
||||||
|
|
||||||
notes.sort((a, b) => {
|
notes.sort((a, b) => {
|
||||||
if (foldersFirst) {
|
|
||||||
const aHasChildren = a.hasChildren();
|
|
||||||
const bHasChildren = b.hasChildren();
|
|
||||||
|
|
||||||
if ((aHasChildren && !bHasChildren) || (!aHasChildren && bHasChildren)) {
|
|
||||||
// exactly one note of the two is a directory, so the sorting will be done based on this status
|
|
||||||
return aHasChildren ? -1 : 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function fetchValue(note: BNote, key: string) {
|
function fetchValue(note: BNote, key: string) {
|
||||||
let rawValue: string | null;
|
let rawValue: string | null;
|
||||||
@ -154,6 +145,16 @@ function sortNotes(parentNoteId: string, customSortBy: string = "title", reverse
|
|||||||
return compare(bottomBEl, bottomAEl) * (reverse ? -1 : 1);
|
return compare(bottomBEl, bottomAEl) * (reverse ? -1 : 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (foldersFirst) {
|
||||||
|
const aHasChildren = a.hasChildren();
|
||||||
|
const bHasChildren = b.hasChildren();
|
||||||
|
|
||||||
|
if ((aHasChildren && !bHasChildren) || (!aHasChildren && bHasChildren)) {
|
||||||
|
// exactly one note of the two is a directory, so the sorting will be done based on this status
|
||||||
|
return aHasChildren ? -1 : 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const customAEl = fetchValue(a, customSortBy) ?? fetchValue(a, "title") as string;
|
const customAEl = fetchValue(a, customSortBy) ?? fetchValue(a, "title") as string;
|
||||||
const customBEl = fetchValue(b, customSortBy) ?? fetchValue(b, "title") as string;
|
const customBEl = fetchValue(b, customSortBy) ?? fetchValue(b, "title") as string;
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user