Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
converting note properties to methods
zadama093508fbe72
diff --git a/spec/search/note_cache_mocking.js b/spec/search/note_cache_mocking.jsindex 69b17cc3ce..855b0c80a3 100644--- a/spec/search/note_cache_mocking.js+++ b/spec/search/note_cache_mocking.js@@ -17,7 +17,7 @@ class NoteBuilder {}label(name, value = '', isInheritable = false) {- new Attribute(becca, {+ new Attribute({attributeId: id(),noteId: this.note.noteId,type: 'label',@@ -30,7 +30,7 @@ class NoteBuilder {}relation(name, targetNote) {- new Attribute(becca, {+ new Attribute({attributeId: id(),noteId: this.note.noteId,type: 'relation',diff --git a/src/becca/becca_service.js b/src/becca/becca_service.jsindex 5b559c0952..dda9d53ad9 100644--- a/src/becca/becca_service.js+++ b/src/becca/becca_service.js@@ -9,7 +9,7 @@ function isNotePathArchived(notePath) {const noteId = notePath[notePath.length - 1];const note = becca.notes[noteId];- if (note.isArchived()) {+ if (note.isArchived) {return true;}@@ -123,7 +123,7 @@ function getNoteTitleForPath(notePathArray) {* Returns notePath for noteId from cache. Note hoisting is respected.* Archived notes are also returned, but non-archived paths are preferred if available* - this means that archived paths is returned only if there's no non-archived path- * - you can check whether returned path is archived using isArchived()+ * - you can check whether returned path is archived using isArchived*/function getSomePath(note, path = []) {// first try to find note within hoisted note, otherwise take any existing note pathdiff --git a/src/becca/entities/note.js b/src/becca/entities/note.jsindex 29bf4bdbb2..383ad611e7 100644--- a/src/becca/entities/note.js+++ b/src/becca/entities/note.js@@ -568,7 +568,7 @@ class Note extends AbstractEntity {return attrs.length > 0 ? attrs[0] : null;}- isArchived() {+ get isArchived() {return this.hasAttribute('label', 'archived');}diff --git a/src/public/app/entities/note_short.js b/src/public/app/entities/note_short.jsindex 3a0e6d682b..1fa8153448 100644--- a/src/public/app/entities/note_short.js+++ b/src/public/app/entities/note_short.js@@ -308,8 +308,8 @@ class NoteShort {return a.isInHoistedSubTree ? -1 : 1;} else if (a.isSearch !== b.isSearch) {return a.isSearch ? 1 : -1;- } else if (a.isArchived() !== b.isArchived()) {- return a.isArchived() ? 1 : -1;+ } else if (a.isArchived !== b.isArchived) {+ return a.isArchived ? 1 : -1;} else {return a.notePath.length - b.notePath.length;}diff --git a/src/public/app/services/zoom.js b/src/public/app/services/zoom.jsindex 1f729db875..e435ac970d 100644--- a/src/public/app/services/zoom.js+++ b/src/public/app/services/zoom.js@@ -15,7 +15,9 @@ class ZoomService extends Component {});window.addEventListener("wheel", event => {- this.setZoomFactorAndSave(this.getCurrentZoom() + event.deltaY * 0.001);+ if (event.ctrlKey) {+ this.setZoomFactorAndSave(this.getCurrentZoom() + event.deltaY * 0.001);+ }});}}diff --git a/src/public/app/widgets/note_paths.js b/src/public/app/widgets/note_paths.jsindex 7bd33f2792..d18a664af5 100644--- a/src/public/app/widgets/note_paths.js+++ b/src/public/app/widgets/note_paths.js@@ -100,7 +100,7 @@ export default class NotePathsWidget extends TabAwareWidget {icons.push(`<span class="bx bx-trending-up" title="This path is outside of hoisted note and you would have to unhoist."></span>`);}- if (notePathRecord.isArchived()) {+ if (notePathRecord.isArchived) {$noteLink.addClass("path-archived");icons.push(`<span class="bx bx-archive" title="Archived"></span>`);diff --git a/src/routes/api/attributes.js b/src/routes/api/attributes.jsindex 132c41c5e4..b11131f5a4 100644--- a/src/routes/api/attributes.js+++ b/src/routes/api/attributes.js@@ -47,10 +47,11 @@ function updateNoteAttribute(req) {return {};}- attribute = new Attribute();- attribute.noteId = noteId;- attribute.name = body.name;- attribute.type = body.type;+ attribute = new Attribute({+ noteId: noteId,+ name: body.name,+ type: body.type+ });}if (attribute.type === 'label' || body.value.trim()) {diff --git a/src/services/search/services/search.js b/src/services/search/services/search.jsindex bbf7a924c6..2138e75161 100644--- a/src/services/search/services/search.js+++ b/src/services/search/services/search.js@@ -153,6 +153,8 @@ function findResultsWithQuery(query, searchContext) {const expression = parseQueryToExpression(query, searchContext);+ console.log("expression", expression);+if (!expression) {return [];}