mirror of
https://github.com/zadam/trilium.git
synced 2025-10-20 23:29:02 +02:00
fix(tree): defend against stray null values that may occur when multiple sorting overrides are defined
fixes #6820
This commit is contained in:
parent
5f647a932d
commit
7c490d8b72
@ -133,6 +133,9 @@ function sortNotes(parentNoteId: string, customSortBy: string = "title", reverse
|
|||||||
const topBEl = fetchValue(b, "top");
|
const topBEl = fetchValue(b, "top");
|
||||||
|
|
||||||
if (topAEl !== topBEl) {
|
if (topAEl !== topBEl) {
|
||||||
|
if (topAEl === null) return 1;
|
||||||
|
if (topBEl === null) return -1;
|
||||||
|
|
||||||
// since "top" should not be reversible, we'll reverse it once more to nullify this effect
|
// since "top" should not be reversible, we'll reverse it once more to nullify this effect
|
||||||
return compare(topAEl, topBEl) * (reverse ? -1 : 1);
|
return compare(topAEl, topBEl) * (reverse ? -1 : 1);
|
||||||
}
|
}
|
||||||
@ -141,6 +144,9 @@ function sortNotes(parentNoteId: string, customSortBy: string = "title", reverse
|
|||||||
const bottomBEl = fetchValue(b, "bottom");
|
const bottomBEl = fetchValue(b, "bottom");
|
||||||
|
|
||||||
if (bottomAEl !== bottomBEl) {
|
if (bottomAEl !== bottomBEl) {
|
||||||
|
if (bottomAEl === null) return -1;
|
||||||
|
if (bottomBEl === null) return 1;
|
||||||
|
|
||||||
// since "bottom" should not be reversible, we'll reverse it once more to nullify this effect
|
// since "bottom" should not be reversible, we'll reverse it once more to nullify this effect
|
||||||
return compare(bottomBEl, bottomAEl) * (reverse ? -1 : 1);
|
return compare(bottomBEl, bottomAEl) * (reverse ? -1 : 1);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user