diff --git a/src/entities/api_token.js b/src/entities/api_token.js index 0240f052a..7275bec79 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.js index 8e6b1dc8e..4d3dde86b 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.js index acb5a5665..395cbae9c 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.js index ce16d0111..a59adad3a 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.js index 72f4f8fdc..2270dfac3 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.js index b77ac1a17..ee5cc8367 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.js index c39e1bf04..45cc880a3 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.js index 4c956d1bd..546f1a0ac 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.js index 994fa7705..9bd3ebf06 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.js index 4761a1651..2e4e1a2dc 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