Skip to content

Build your personal knowledge base with Trilium Notes

allow #newNotesOnTop=false to negate previous setting, closes #3796

zadamd100b0dc07ad
diff --git a/package-lock.json b/package-lock.json
index 8117a4a56c..f6fd5eaef0 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,11 +1,11 @@
{
"name": "trilium",
- "version": "0.59.2",
+ "version": "0.59.3",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
- "version": "0.59.2",
+ "version": "0.59.3",
"hasInstallScript": true,
"license": "AGPL-3.0-only",
"dependencies": {
diff --git a/src/becca/entities/bnote.js b/src/becca/entities/bnote.js
index 07ebd612f2..960b352343 100644
--- a/src/becca/entities/bnote.js
+++ b/src/becca/entities/bnote.js
@@ -532,6 +532,20 @@ class BNote extends AbstractBeccaEntity {
*/
hasLabel(name, value) { return this.hasAttribute(LABEL, name, value); }
+ /**
+ * @param {string} name - label name
+ * @returns {boolean} true if label exists (including inherited) and does not have "false" value.
+ */
+ isLabelTruthy(name) {
+ const label = this.getLabel(name);
+
+ if (!label) {
+ return false;
+ }
+
+ return label && label.value !== 'false';
+ }
+
/**
* @param {string} name - label name
* @param {string} [value] - label value
diff --git a/src/public/app/entities/fnote.js b/src/public/app/entities/fnote.js
index 70594d647f..1066a9341d 100644
--- a/src/public/app/entities/fnote.js
+++ b/src/public/app/entities/fnote.js
@@ -595,6 +595,20 @@ class FNote {
*/
hasLabel(name) { return this.hasAttribute(LABEL, name); }
+ /**
+ * @param {string} name - label name
+ * @returns {boolean} true if label exists (including inherited) and does not have "false" value.
+ */
+ isLabelTruthy(name) {
+ const label = this.getLabel(name);
+
+ if (!label) {
+ return false;
+ }
+
+ return label && label.value !== 'false';
+ }
+
/**
* @param {string} name - relation name
* @returns {boolean} true if relation exists (excluding inherited)
diff --git a/src/services/notes.js b/src/services/notes.js
index 6dfa34cb04..3da2f56fcd 100644
--- a/src/services/notes.js
+++ b/src/services/notes.js
@@ -23,7 +23,7 @@ const ValidationError = require("../errors/validation_error");
const noteTypesService = require("./note_types");
function getNewNotePosition(parentNote) {
- if (parentNote.hasLabel('newNotesOnTop')) {
+ if (parentNote.isLabelTruthy('newNotesOnTop')) {
const minNotePos = parentNote.getChildBranches()
.reduce((min, note) => Math.min(min, note.notePosition), 0);