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
refactoring
azivner0ce5caefe833
diff --git a/src/entities/api_token.js b/src/entities/api_token.jsindex 0240f052a9..7275bec791 100644--- a/src/entities/api_token.js+++ b/src/entities/api_token.js@@ -6,7 +6,7 @@ const dateUtils = require('../services/date_utils');class ApiToken extends Entity {static get tableName() { return "api_tokens"; }static get primaryKeyName() { return "apiTokenId"; }- static get syncedProperties() { return ["apiTokenId", "token", "dateCreated", "isDeleted"]; }+ static get hashedProperties() { return ["apiTokenId", "token", "dateCreated", "isDeleted"]; }beforeSaving() {super.beforeSaving();diff --git a/src/entities/branch.js b/src/entities/branch.jsindex 8e6b1dc8e0..4d3dde86b5 100644--- a/src/entities/branch.js+++ b/src/entities/branch.js@@ -8,7 +8,8 @@ const sql = require('../services/sql');class Branch extends Entity {static get tableName() { return "branches"; }static get primaryKeyName() { return "branchId"; }- static get syncedProperties() { return ["branchId", "noteId", "parentNoteId", "notePosition", "dateModified", "isDeleted", "prefix"]; }+ // notePosition is not part of hash because it would produce a lot of updates in case of reordering+ static get hashedProperties() { return ["branchId", "noteId", "parentNoteId", "dateModified", "isDeleted", "prefix"]; }async getNote() {return await repository.getEntity("SELECT * FROM notes WHERE noteId = ?", [this.noteId]);diff --git a/src/entities/entity.js b/src/entities/entity.jsindex acb5a56659..395cbae9cb 100644--- a/src/entities/entity.js+++ b/src/entities/entity.js@@ -17,7 +17,7 @@ class Entity {let contentToHash = "";- for (const propertyName of this.constructor.syncedProperties) {+ for (const propertyName of this.constructor.hashedProperties) {contentToHash += "|" + this[propertyName];}diff --git a/src/entities/image.js b/src/entities/image.jsindex ce16d0111c..a59adad3a1 100644--- a/src/entities/image.js+++ b/src/entities/image.js@@ -6,7 +6,7 @@ const dateUtils = require('../services/date_utils');class Image extends Entity {static get tableName() { return "images"; }static get primaryKeyName() { return "imageId"; }- static get syncedProperties() { return ["imageId", "format", "checksum", "name", "isDeleted", "dateModified", "dateCreated"]; }+ static get hashedProperties() { return ["imageId", "format", "checksum", "name", "isDeleted", "dateModified", "dateCreated"]; }beforeSaving() {super.beforeSaving();diff --git a/src/entities/label.js b/src/entities/label.jsindex 72f4f8fdcd..2270dfac35 100644--- a/src/entities/label.js+++ b/src/entities/label.js@@ -8,7 +8,7 @@ const sql = require('../services/sql');class Label extends Entity {static get tableName() { return "labels"; }static get primaryKeyName() { return "labelId"; }- static get syncedProperties() { return ["labelId", "noteId", "name", "value", "dateModified", "dateCreated"]; }+ static get hashedProperties() { return ["labelId", "noteId", "name", "value", "dateModified", "dateCreated"]; }async getNote() {return await repository.getEntity("SELECT * FROM notes WHERE noteId = ?", [this.noteId]);diff --git a/src/entities/note.js b/src/entities/note.jsindex b77ac1a172..ee5cc83678 100644--- a/src/entities/note.js+++ b/src/entities/note.js@@ -8,7 +8,7 @@ const dateUtils = require('../services/date_utils');class Note extends Entity {static get tableName() { return "notes"; }static get primaryKeyName() { return "noteId"; }- static get syncedProperties() { return ["noteId", "title", "content", "type", "dateModified", "isProtected", "isDeleted"]; }+ static get hashedProperties() { return ["noteId", "title", "content", "type", "dateModified", "isProtected", "isDeleted"]; }constructor(row) {super(row);diff --git a/src/entities/note_image.js b/src/entities/note_image.jsindex c39e1bf04e..45cc880a38 100644--- a/src/entities/note_image.js+++ b/src/entities/note_image.js@@ -7,7 +7,7 @@ const dateUtils = require('../services/date_utils');class NoteImage extends Entity {static get tableName() { return "note_images"; }static get primaryKeyName() { return "noteImageId"; }- static get syncedProperties() { return ["noteImageId", "noteId", "imageId", "isDeleted", "dateModified", "dateCreated"]; }+ static get hashedProperties() { return ["noteImageId", "noteId", "imageId", "isDeleted", "dateModified", "dateCreated"]; }async getNote() {return await repository.getEntity("SELECT * FROM notes WHERE noteId = ?", [this.noteId]);diff --git a/src/entities/note_revision.js b/src/entities/note_revision.jsindex 4c956d1bdd..546f1a0ac7 100644--- a/src/entities/note_revision.js+++ b/src/entities/note_revision.js@@ -7,7 +7,7 @@ const repository = require('../services/repository');class NoteRevision extends Entity {static get tableName() { return "note_revisions"; }static get primaryKeyName() { return "noteRevisionId"; }- static get syncedProperties() { return ["noteRevisionId", "noteId", "title", "content", "dateModifiedFrom", "dateModifiedTo"]; }+ static get hashedProperties() { return ["noteRevisionId", "noteId", "title", "content", "dateModifiedFrom", "dateModifiedTo"]; }constructor(row) {super(row);diff --git a/src/entities/option.js b/src/entities/option.jsindex 994fa77055..9bd3ebf061 100644--- a/src/entities/option.js+++ b/src/entities/option.js@@ -6,7 +6,7 @@ const dateUtils = require('../services/date_utils');class Option extends Entity {static get tableName() { return "options"; }static get primaryKeyName() { return "name"; }- static get syncedProperties() { return ["name", "value"]; }+ static get hashedProperties() { return ["name", "value"]; }beforeSaving() {super.beforeSaving();diff --git a/src/entities/recent_note.js b/src/entities/recent_note.jsindex 4761a16514..2e4e1a2dc8 100644--- a/src/entities/recent_note.js+++ b/src/entities/recent_note.js@@ -5,7 +5,7 @@ const Entity = require('./entity');class RecentNote extends Entity {static get tableName() { return "recent_notes"; }static get primaryKeyName() { return "branchId"; }- static get syncedProperties() { return ["branchId", "notePath", "dateAccessed", "isDeleted"]; }+ static get hashedProperties() { return ["branchId", "notePath", "dateAccessed", "isDeleted"]; }}module.exports = RecentNote;\ No newline at end of file