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
fix syncing protected notes in case there wasn't any other change, closes #1778
zadamce7e18d0b071
diff --git a/package.json b/package.jsonindex 638b0253a6..ff62d8d5a5 100644--- a/package.json+++ b/package.json@@ -14,7 +14,7 @@},"scripts": {"start-server": "cross-env TRILIUM_ENV=dev node ./src/www",- "start-electron": "cross-env TRILIUM_ENV=dev electron .",+ "start-electron": "cross-env TRILIUM_ENV=dev electron --inspect=5858 .","build-backend-docs": "./node_modules/.bin/jsdoc -c jsdoc-conf.json -d ./docs/backend_api src/entities/*.js src/services/backend_script_api.js","build-frontend-docs": "./node_modules/.bin/jsdoc -c jsdoc-conf.json -d ./docs/frontend_api src/public/app/entities/*.js src/public/app/services/frontend_script_api.js src/public/app/widgets/collapsible_widget.js","build-docs": "npm run build-backend-docs && npm run build-frontend-docs",diff --git a/src/entities/note.js b/src/entities/note.jsindex 0abd734331..78173c5827 100644--- a/src/entities/note.js+++ b/src/entities/note.js@@ -156,14 +156,14 @@ class Note extends Entity {sql.upsert("note_contents", "noteId", pojo);- const hash = utils.hash(this.noteId + "|" + content.toString());+ const hash = utils.hash(this.noteId + "|" + pojo.content.toString());entityChangesService.addEntityChange({entityName: 'note_contents',entityId: this.noteId,hash: hash,isErased: false,- utcDateChanged: this.getUtcDateChanged()+ utcDateChanged: pojo.utcDateModified}, null);}diff --git a/src/services/sync_update.js b/src/services/sync_update.jsindex 0c2a241ba9..0f89a698dc 100644--- a/src/services/sync_update.js+++ b/src/services/sync_update.js@@ -26,9 +26,7 @@ function updateEntity(entityChange, entity, sourceId) {? updateNoteReordering(entityChange, entity, sourceId): updateNormalEntity(entityChange, entity, sourceId);- // currently making exception for protected notes and note revisions because here- // the title and content are not available decrypted as listeners would expect- if (updated && !entity.isProtected && !entityChange.isErased) {+ if (updated && !entityChange.isErased) {eventService.emit(eventService.ENTITY_SYNCED, {entityName: entityChange.entityName,entity@@ -44,7 +42,7 @@ function updateNormalEntity(remoteEntityChange, entity, sourceId) {if (localEntityChange && !localEntityChange.isErased && remoteEntityChange.isErased) {sql.transactional(() => {- const primaryKey = entityConstructor.getEntityFromEntityName(entityName).primaryKeyName;+ const primaryKey = entityConstructor.getEntityFromEntityName(remoteEntityChange.entityName).primaryKeyName;sql.execute(`DELETE FROM ${remoteEntityChange.entityName} WHERE ${primaryKey} = ?`, remoteEntityChange.entityId);