From 7e3d424e2375c3aee682360cc43cbaff5c7fcfa1 Mon Sep 17 00:00:00 2001 From: zadam Date: Mon, 22 Mar 2021 23:07:43 +0100 Subject: [PATCH 1/4] fix deleting all revisions, closes #1774 --- src/routes/api/note_revisions.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/routes/api/note_revisions.js b/src/routes/api/note_revisions.js index bebff5dd8..f6a737863 100644 --- a/src/routes/api/note_revisions.js +++ b/src/routes/api/note_revisions.js @@ -5,6 +5,7 @@ const noteCacheService = require('../../services/note_cache/note_cache_service') const protectedSessionService = require('../../services/protected_session'); const noteRevisionService = require('../../services/note_revisions'); const utils = require('../../services/utils'); +const sql = require('../../services/sql'); const path = require('path'); function getNoteRevisions(req) { From 65280d5ba3dcd66932eb33561c469a1db98749fb Mon Sep 17 00:00:00 2001 From: zadam Date: Mon, 22 Mar 2021 23:27:41 +0100 Subject: [PATCH 2/4] avoid ugly error in the logs, #1778 --- src/services/note_cache/similarity.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/services/note_cache/similarity.js b/src/services/note_cache/similarity.js index f5cf3b17d..6046e272b 100644 --- a/src/services/note_cache/similarity.js +++ b/src/services/note_cache/similarity.js @@ -233,7 +233,7 @@ async function findSimilarNotes(noteId) { const baseNote = noteCache.notes[noteId]; - if (!baseNote) { + if (!baseNote || !baseNote.utcDateCreated) { return []; } From ce7e18d0b0717e51fa8ef4283963a4d06029362a Mon Sep 17 00:00:00 2001 From: zadam Date: Tue, 23 Mar 2021 22:18:23 +0100 Subject: [PATCH 3/4] fix syncing protected notes in case there wasn't any other change, closes #1778 --- package.json | 2 +- src/entities/note.js | 4 ++-- src/services/sync_update.js | 6 ++---- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index 638b0253a..ff62d8d5a 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.js index 0abd73433..78173c582 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.js index 0c2a241ba..0f89a698d 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); From 1862acd1ff9261536ebc7118d35bbbd8449ba94d Mon Sep 17 00:00:00 2001 From: zadam Date: Tue, 23 Mar 2021 22:46:18 +0100 Subject: [PATCH 4/4] avoid getting refreshes on note title --- src/public/app/widgets/note_title.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/public/app/widgets/note_title.js b/src/public/app/widgets/note_title.js index e3f6d4ce8..e630deefc 100644 --- a/src/public/app/widgets/note_title.js +++ b/src/public/app/widgets/note_title.js @@ -36,7 +36,7 @@ export default class NoteTitleWidget extends TabAwareWidget { protectedSessionHolder.touchProtectedSessionIfNecessary(this.note); - await server.put(`notes/${this.noteId}/change-title`, {title}); + await server.put(`notes/${this.noteId}/change-title`, {title}, this.componentId); }); appContext.addBeforeUnloadListener(this);